diff --git a/media/libstagefright/binding/MoofParser.cpp b/media/libstagefright/binding/MoofParser.cpp index d3397047274e..687069a30ad6 100644 --- a/media/libstagefright/binding/MoofParser.cpp +++ b/media/libstagefright/binding/MoofParser.cpp @@ -46,7 +46,7 @@ MoofParser::RebuildFragmentedIndex(BoxContext& aContext) mInitRange = MediaByteRange(0, box.Range().mEnd); ParseMoov(box); } else if (box.IsType("moof")) { - Moof moof(box, mTrex, mMvhd, mMdhd, mEdts, mSinf, mIsAudio); + Moof moof(box, mTrex, mMvhd, mMdhd, mEdts, mSinf, &mLastDecodeTime, mIsAudio); if (!moof.IsValid() && !box.Next().IsAvailable()) { // Moof isn't valid abort search for now. @@ -346,13 +346,13 @@ MoofParser::ParseEncrypted(Box& aBox) } } -Moof::Moof(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, bool aIsAudio) +Moof::Moof(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, uint64_t* aDecodeTime, bool aIsAudio) : mRange(aBox.Range()) , mMaxRoundingError(35000) { for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) { if (box.IsType("traf")) { - ParseTraf(box, aTrex, aMvhd, aMdhd, aEdts, aSinf, aIsAudio); + ParseTraf(box, aTrex, aMvhd, aMdhd, aEdts, aSinf, aDecodeTime, aIsAudio); } } if (IsValid()) { @@ -425,8 +425,9 @@ Moof::ProcessCenc() } void -Moof::ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, bool aIsAudio) +Moof::ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, uint64_t* aDecodeTime, bool aIsAudio) { + MOZ_ASSERT(aDecodeTime); Tfhd tfhd(aTrex); Tfdt tfdt; for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) { @@ -445,12 +446,9 @@ Moof::ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, S if (aTrex.mTrackId && tfhd.mTrackId != aTrex.mTrackId) { return; } - if (!tfdt.IsValid()) { - LOG(Moof, "Invalid tfdt dependency"); - return; - } // Now search for TRUN boxes. - uint64_t decodeTime = tfdt.mBaseMediaDecodeTime; + uint64_t decodeTime = + tfdt.IsValid() ? tfdt.mBaseMediaDecodeTime : *aDecodeTime; for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) { if (box.IsType("trun")) { if (ParseTrun(box, tfhd, aMvhd, aMdhd, aEdts, &decodeTime, aIsAudio)) { @@ -461,6 +459,7 @@ Moof::ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, S } } } + *aDecodeTime = decodeTime; } void diff --git a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h index 42cae264392e..02987cbbd3dc 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h +++ b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h @@ -173,7 +173,7 @@ private: class Moof : public Atom { public: - Moof(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, bool aIsAudio); + Moof(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, uint64_t* aDecoderTime, bool aIsAudio); bool GetAuxInfo(AtomType aType, nsTArray* aByteRanges); void FixRounding(const Moof& aMoof); @@ -186,7 +186,8 @@ public: nsTArray mSaios; private: - void ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, bool aIsAudio); + // aDecodeTime is updated to the end of the parsed TRAF on return. + void ParseTraf(Box& aBox, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, uint64_t* aDecodeTime, bool aIsAudio); // aDecodeTime is updated to the end of the parsed TRUN on return. bool ParseTrun(Box& aBox, Tfhd& aTfhd, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, uint64_t* aDecodeTime, bool aIsAudio); void ParseSaiz(Box& aBox); @@ -203,6 +204,7 @@ public: , mOffset(0) , mTrex(aTrackId) , mIsAudio(aIsAudio) + , 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. @@ -247,6 +249,7 @@ private: nsTArray mMoofs; nsTArray mMediaRanges; bool mIsAudio; + uint64_t mLastDecodeTime; }; }