Bug 1121342: Re-search for Moof if an initial attempt to find it failed. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 16 Jan 2015 15:48:43 +1100
changeset 224148 a801540e3d141aafd04b19a627fd2c9b6b10e3f4
parent 224147 0bbf63496d8d7cbb6803aab4c8bed5f8b0595478
child 224149 47b586de56613cd97e2a380a769c41ab155fd4e3
push id54139
push userjyavenard@mozilla.com
push dateFri, 16 Jan 2015 09:23:23 +0000
treeherdermozilla-inbound@a801540e3d14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1121342
milestone38.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 1121342: Re-search for Moof if an initial attempt to find it failed. r=kentuckyfriedtakahe
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -106,17 +106,17 @@ private:
 
     size_t parseNALSize(const uint8_t *data) const;
     status_t parseChunk(off64_t *offset);
     status_t parseTrackFragmentData(off64_t offset, off64_t size);
     status_t parseTrackFragmentHeader(off64_t offset, off64_t size);
     status_t parseTrackFragmentRun(off64_t offset, off64_t size);
     status_t parseSampleAuxiliaryInformationSizes(off64_t offset, off64_t size);
     status_t parseSampleAuxiliaryInformationOffsets(off64_t offset, off64_t size);
-    void lookForMoof();
+    status_t lookForMoof();
     status_t moveToNextFragment();
 
     struct TrackFragmentHeaderInfo {
         enum Flags {
             kBaseDataOffsetPresent         = 0x01,
             kSampleDescriptionIndexPresent = 0x02,
             kDefaultSampleDurationPresent  = 0x08,
             kDefaultSampleSizePresent      = 0x10,
@@ -3199,51 +3199,50 @@ size_t MPEG4Source::parseNALSize(const u
 
     // This cannot happen, mNALLengthSize springs to life by adding 1 to
     // a 2-bit integer.
     CHECK(!"Should not be here.");
 
     return 0;
 }
 
-void MPEG4Source::lookForMoof() {
+status_t MPEG4Source::lookForMoof() {
     off64_t offset = 0;
     off64_t size;
     while (true) {
         uint32_t hdr[2];
         auto x = mDataSource->readAt(offset, hdr, 8);
         if (x < 8) {
-            break;
+            return NOT_ENOUGH_DATA;
         }
         uint32_t chunk_size = ntohl(hdr[0]);
         uint32_t chunk_type = ntohl(hdr[1]);
         char chunk[5];
         MakeFourCCString(chunk_type, chunk);
         if (chunk_type == FOURCC('m', 'o', 'o', 'f')) {
             mFirstMoofOffset = mCurrentMoofOffset = offset;
             parseChunk(&offset);
-            break;
+            return OK;
         }
         if (chunk_type == FOURCC('m', 'd', 'a', 't')) {
-            break;
+            return OK;
         }
         offset += chunk_size;
     }
 }
 
 
 status_t MPEG4Source::read(
         MediaBuffer **out, const ReadOptions *options) {
     Mutex::Autolock autoLock(mLock);
 
     CHECK(mStarted);
 
     if (!mLookedForMoof) {
-      mLookedForMoof = true;
-      lookForMoof();
+        mLookedForMoof = lookForMoof() == OK;
     }
 
     if (mFirstMoofOffset > 0) {
         return fragmentedRead(out, options);
     }
 
     *out = NULL;