Bug 1336271 - Allow 'ftyp' after 'moov' in improperly-muxed MP4s - r?jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 02 May 2017 14:48:50 +1200
changeset 571091 ee90cf44cc0b3e0adf5205649f0e856d6727cbfe
parent 571081 4b134293293043d247f8dcfd076ca9fc853332b4
child 626667 2cd675fa55929431cb5d9264f57bfc98dcbb63c3
push id56679
push usergsquelart@mozilla.com
push dateTue, 02 May 2017 02:49:37 +0000
reviewersjya
bugs1336271
milestone55.0a1
Bug 1336271 - Allow 'ftyp' after 'moov' in improperly-muxed MP4s - r?jya MozReview-Commit-ID: BYoElOTi4mn
media/libstagefright/binding/MoofParser.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -156,21 +156,24 @@ MoofParser::ScanForMetadata(mozilla::Med
   MediaByteRangeSet byteRanges;
   byteRanges += MediaByteRange(0, length);
   RefPtr<mp4_demuxer::BlockingStream> stream = new BlockingStream(mSource);
 
   BoxContext context(stream, byteRanges);
   for (Box box(&context, mOffset); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("ftyp")) {
       aFtyp = box.Range();
-      continue;
-    }
-    if (box.IsType("moov")) {
+      if (!aMoov.IsEmpty()) {
+        break;
+      }
+    } else if (box.IsType("moov")) {
       aMoov = box.Range();
-      break;
+      if (!aFtyp.IsEmpty()) {
+        break;
+      }
     }
   }
   mInitRange = aFtyp.Span(aMoov);
 }
 
 bool
 MoofParser::HasMetadata()
 {