From 14053289287828f58d579e52ce06e3a8673bbd38 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 16 Jan 2015 15:48:43 +1100 Subject: [PATCH] Bug 1121342: Re-search for Moof if an initial attempt to find it failed. r=kentuckyfriedtakahe --HG-- extra : rebase_source : 009d8048a8917d5ff1a1660b0b6cf8220743cba8 --- .../av/media/libstagefright/MPEG4Extractor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp index 611c2186831..06ebd1b4fec 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp @@ -111,7 +111,7 @@ private: 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 { @@ -3204,14 +3204,14 @@ size_t MPEG4Source::parseNALSize(const uint8_t *data) const { 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]); @@ -3220,10 +3220,10 @@ void MPEG4Source::lookForMoof() { 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; } @@ -3237,8 +3237,7 @@ status_t MPEG4Source::read( CHECK(mStarted); if (!mLookedForMoof) { - mLookedForMoof = true; - lookForMoof(); + mLookedForMoof = lookForMoof() == OK; } if (mFirstMoofOffset > 0) {