Bug 1096157 - Add IsMediaSegmentPresent() for MP4; r=mattwoodrow
authorAnthony Jones <ajones@mozilla.com>
Wed, 12 Nov 2014 16:37:43 +1300
changeset 215163 7783bd22ca1d
parent 215162 2e37ad545154
child 215164 ab237570a07e
push id27810
push usercbook@mozilla.com
push dateWed, 12 Nov 2014 15:03:31 +0000
treeherdermozilla-central@cf9eafef4ffa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1096157
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1096157 - Add IsMediaSegmentPresent() for MP4; r=mattwoodrow
dom/media/mediasource/ContainerParser.cpp
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -213,16 +213,32 @@ public:
     if (chunk_size < 8) {
       return false;
     }
 
     return aData[4] == 'f' && aData[5] == 't' && aData[6] == 'y' &&
            aData[7] == 'p';
   }
 
+  bool IsMediaSegmentPresent(const uint8_t* aData, uint32_t aLength)
+  {
+    ContainerParser::IsMediaSegmentPresent(aData, aLength);
+    if (aLength < 8) {
+      return false;
+    }
+
+    uint32_t chunk_size = BigEndian::readUint32(aData);
+    if (chunk_size < 8) {
+      return false;
+    }
+
+    return aData[4] == 'm' && aData[5] == 'o' && aData[6] == 'o' &&
+           aData[7] == 'f';
+  }
+
   bool ParseStartAndEndTimestamps(const uint8_t* aData, uint32_t aLength,
                                   int64_t& aStart, int64_t& aEnd)
   {
     bool initSegment = IsInitSegmentPresent(aData, aLength);
     if (initSegment) {
       mStream = new mp4_demuxer::BufferStream();
       mParser = new mp4_demuxer::MoofParser(mStream, 0);
     } else if (!mStream || !mParser) {