Bug 1121342: Re-search for Moof if an initial attempt to find it failed. r=kentuckyfriedtakahe a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 16 Jan 2015 15:48:43 +1100
changeset 242900 dfbca180664d
parent 242899 7a8d1dd9fff3
child 242901 beb62e1ad523
push id4333
push userrgiles@mozilla.com
push date2015-01-17 17:47 +0000
treeherdermozilla-beta@dfbca180664d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, sledru
bugs1121342
milestone36.0
Bug 1121342: Re-search for Moof if an initial attempt to find it failed. r=kentuckyfriedtakahe a=sledru
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;