Merge mozilla-central to autoland.
authorCosmin Sabou <csabou@mozilla.com>
Tue, 15 Jan 2019 12:41:53 +0200
changeset 513895 5e9dc7f35bcf23c6c0215f423a6fd074aea5e416
parent 513894 da8b6bcd0deb5c1235d743e136ce240951eb2b8b (current diff)
parent 513848 a559b84032a8d570a64f0bb67ce917c9d696d4fc (diff)
child 513896 d5245076458f441cbd812737fdb5d515d6bc20de
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone66.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
Merge mozilla-central to autoland.
--- a/dom/media/gtest/mp4_demuxer/TestParser.cpp
+++ b/dom/media/gtest/mp4_demuxer/TestParser.cpp
@@ -89,17 +89,17 @@ TEST(MP4Metadata, EmptyStream) {
   // We can seek anywhere in any MPEG4.
   EXPECT_TRUE(metadata.CanSeek());
   EXPECT_FALSE(metadata.Crypto().Ref()->valid);
 }
 
 TEST(MoofParser, EmptyStream) {
   RefPtr<ByteStream> stream = new TestStream(nullptr, 0);
 
-  MoofParser parser(stream, 0, false, true);
+  MoofParser parser(stream, 0, false);
   EXPECT_EQ(0u, parser.mOffset);
   EXPECT_TRUE(parser.ReachedEnd());
 
   MediaByteRangeSet byteRanges;
   EXPECT_FALSE(parser.RebuildFragmentedIndex(byteRanges));
 
   EXPECT_TRUE(parser.GetCompositionRange(byteRanges).IsNull());
   EXPECT_TRUE(parser.mInitRange.IsEmpty());
@@ -399,17 +399,17 @@ TEST(MoofParser, test_case_mp4) {
   length = ArrayLength(testFiles);
 
   for (size_t test = 0; test < length; ++test) {
     nsTArray<uint8_t> buffer = ReadTestFile(tests[test].mFilename);
     ASSERT_FALSE(buffer.IsEmpty());
     RefPtr<ByteStream> stream =
         new TestStream(buffer.Elements(), buffer.Length());
 
-    MoofParser parser(stream, 0, false, true);
+    MoofParser parser(stream, 0, false);
     EXPECT_EQ(0u, parser.mOffset) << tests[test].mFilename;
     EXPECT_FALSE(parser.ReachedEnd()) << tests[test].mFilename;
     EXPECT_TRUE(parser.mInitRange.IsEmpty()) << tests[test].mFilename;
 
     RefPtr<MediaByteBuffer> metadataBuffer = parser.Metadata();
     EXPECT_TRUE(metadataBuffer) << tests[test].mFilename;
 
     EXPECT_FALSE(parser.mInitRange.IsEmpty()) << tests[test].mFilename;
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -521,18 +521,17 @@ class MP4ContainerParser : public Contai
     if (initSegment) {
       mResource = new SourceBufferResource();
       DDLINKCHILD("resource", mResource.get());
       mStream = new MP4Stream(mResource);
       // We use a timestampOffset of 0 for ContainerParser, and require
       // consumers of ParseStartAndEndTimestamps to add their timestamp offset
       // manually. This allows the ContainerParser to be shared across different
       // timestampOffsets.
-      mParser = new MoofParser(mStream, 0, /* aIsAudio = */ false,
-                               /* aIsMultitrackParser */ true);
+      mParser = new MoofParser(mStream, 0, /* aIsAudio = */ false);
       DDLINKCHILD("parser", mParser.get());
       mInitData = new MediaByteBuffer();
       mCompleteInitSegmentRange = MediaByteRange();
       mCompleteMediaHeaderRange = MediaByteRange();
       mCompleteMediaSegmentRange = MediaByteRange();
       mGlobalOffset = mTotalParsed;
     } else if (!mStream || !mParser) {
       mTotalParsed += aData->Length();
--- a/dom/media/mp4/MoofParser.cpp
+++ b/dom/media/mp4/MoofParser.cpp
@@ -222,21 +222,21 @@ void MoofParser::ParseMoov(Box& aBox) {
 }
 
 void MoofParser::ParseTrak(Box& aBox) {
   Tkhd tkhd;
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("tkhd")) {
       tkhd = Tkhd(box);
     } else if (box.IsType("mdia")) {
-      if (mIsMultitrackParser || tkhd.mTrackId == mTrex.mTrackId) {
+      if (!mTrex.mTrackId || tkhd.mTrackId == mTrex.mTrackId) {
         ParseMdia(box, tkhd);
       }
     } else if (box.IsType("edts") &&
-               (mIsMultitrackParser || tkhd.mTrackId == mTrex.mTrackId)) {
+               (!mTrex.mTrackId || tkhd.mTrackId == mTrex.mTrackId)) {
       mEdts = Edts(box);
     }
   }
 }
 
 void MoofParser::ParseMdia(Box& aBox, Tkhd& aTkhd) {
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("mdhd")) {
@@ -246,18 +246,22 @@ void MoofParser::ParseMdia(Box& aBox, Tk
     }
   }
 }
 
 void MoofParser::ParseMvex(Box& aBox) {
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("trex")) {
       Trex trex = Trex(box);
-      if (mIsMultitrackParser || trex.mTrackId == mTrex.mTrackId) {
+      if (!mTrex.mTrackId || trex.mTrackId == mTrex.mTrackId) {
+        auto trackId = mTrex.mTrackId;
         mTrex = trex;
+        // Keep the original trackId, as should it be 0 we want to continue
+        // parsing all tracks.
+        mTrex.mTrackId = trackId;
       }
     }
   }
 }
 
 void MoofParser::ParseMinf(Box& aBox) {
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("stbl")) {
@@ -290,18 +294,18 @@ void MoofParser::ParseStbl(Box& aBox) {
           return;
         }
       }
     }
   }
 }
 
 void MoofParser::ParseStsd(Box& aBox) {
-  if (mIsMultitrackParser) {
-    // If mIsMultitrackParser, then the parser is being used to read multiple
+  if (mTrex.mTrackId == 0) {
+    // If mTrex.mTrackId is 0, then the parser is being used to read multiple
     // tracks metadata, and it is not a sane operation to try and map multiple
     // sample description boxes, from different tracks, onto the parser, which
     // is modeled around storing metadata for a single track.
     return;
   }
   MOZ_ASSERT(
       mSampleDescriptions.IsEmpty(),
       "Shouldn't have any sample descriptions when starting to parse stsd");
--- a/dom/media/mp4/MoofParser.h
+++ b/dom/media/mp4/MoofParser.h
@@ -262,28 +262,24 @@ class Moof final : public Atom {
   bool ProcessCencAuxInfo(AtomType aScheme);
   uint64_t mMaxRoundingError;
 };
 
 DDLoggedTypeDeclName(MoofParser);
 
 class MoofParser : public DecoderDoctorLifeLogger<MoofParser> {
  public:
-  MoofParser(ByteStream* aSource, uint32_t aTrackId, bool aIsAudio,
-             bool aIsMultitrackParser = false)
+  MoofParser(ByteStream* aSource, uint32_t aTrackId, bool aIsAudio)
       : mSource(aSource),
         mOffset(0),
         mTrex(aTrackId),
         mIsAudio(aIsAudio),
-        mLastDecodeTime(0),
-        mIsMultitrackParser(aIsMultitrackParser) {
-    // Setting mIsMultitrackParser is a nasty work around for calculating
-    // the composition range for MSE that causes the parser to parse multiple
-    // tracks. Ideally we'd store an array of tracks with different metadata
-    // for each.
+        mLastDecodeTime(0) {
+    // Setting the mTrex.mTrackId to 0 is a nasty work around for calculating
+    // the composition range for MSE. We need an array of tracks.
     DDLINKCHILD("source", aSource);
   }
   bool RebuildFragmentedIndex(const mozilla::MediaByteRangeSet& aByteRanges);
   // If *aCanEvict is set to true. then will remove all moofs already parsed
   // from index then rebuild the index. *aCanEvict is set to true upon return if
   // some moofs were removed.
   bool RebuildFragmentedIndex(const mozilla::MediaByteRangeSet& aByteRanges,
                               bool* aCanEvict);
@@ -325,13 +321,12 @@ class MoofParser : public DecoderDoctorL
   nsTArray<Moof>& Moofs() { return mMoofs; }
 
  private:
   void ScanForMetadata(mozilla::MediaByteRange& aMoov);
   nsTArray<Moof> mMoofs;
   nsTArray<MediaByteRange> mMediaRanges;
   bool mIsAudio;
   uint64_t mLastDecodeTime;
-  bool mIsMultitrackParser;
 };
 }  // namespace mozilla
 
 #endif