diff --git a/media/libstagefright/binding/Box.cpp b/media/libstagefright/binding/Box.cpp index d33cfcc634ac..8e28806066cc 100644 --- a/media/libstagefright/binding/Box.cpp +++ b/media/libstagefright/binding/Box.cpp @@ -58,7 +58,7 @@ Box::Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent) } MediaByteRange boxRange(aOffset, aOffset + size); - if (boxRange.mEnd > mChildOffset || + if (mChildOffset >= boxRange.mEnd || (mParent && !mParent->mRange.Contains(boxRange)) || !byteRange->Contains(boxRange)) { return; diff --git a/media/libstagefright/binding/mp4_demuxer.cpp b/media/libstagefright/binding/mp4_demuxer.cpp index f4d9242bb129..5daf7dd75bf9 100644 --- a/media/libstagefright/binding/mp4_demuxer.cpp +++ b/media/libstagefright/binding/mp4_demuxer.cpp @@ -24,11 +24,11 @@ struct StageFrightPrivate sp mAudio; MediaSource::ReadOptions mAudioOptions; - nsAutoPtr mAudioIndex; sp mVideo; MediaSource::ReadOptions mVideoOptions; - nsAutoPtr mVideoIndex; + + nsTArray> mIndexes; }; class DataSourceAdapter : public DataSource @@ -101,14 +101,14 @@ MP4Demuxer::Init() mPrivate->mAudio = e->getTrack(i); mPrivate->mAudio->start(); mAudioConfig.Update(metaData, mimeType); - auto index = mPrivate->mAudio->exportIndex(); - mPrivate->mAudioIndex = new Index(index, mSource, mAudioConfig.mTrackId); + mPrivate->mIndexes.AppendElement(new Index( + mPrivate->mAudio->exportIndex(), mSource, mAudioConfig.mTrackId)); } else if (!mPrivate->mVideo.get() && !strncmp(mimeType, "video/", 6)) { mPrivate->mVideo = e->getTrack(i); mPrivate->mVideo->start(); mVideoConfig.Update(metaData, mimeType); - auto index = mPrivate->mVideo->exportIndex(); - mPrivate->mVideoIndex = new Index(index, mSource, mVideoConfig.mTrackId); + mPrivate->mIndexes.AppendElement(new Index( + mPrivate->mVideo->exportIndex(), mSource, mVideoConfig.mTrackId)); } } sp metaData = e->getMetaData(); @@ -199,33 +199,20 @@ MP4Demuxer::ConvertByteRangesToTime( const nsTArray& aByteRanges, nsTArray>* aIntervals) { - if (!HasValidVideo() && !HasValidAudio()) { + if (mPrivate->mIndexes.IsEmpty()) { return; } - nsTArray> video; - if (HasValidVideo()) { - nsTArray> ranges; - if (!HasValidAudio()) { - mPrivate->mVideoIndex->ConvertByteRangesToTimeRanges(aByteRanges, - aIntervals); - return; - } - mPrivate->mVideoIndex->ConvertByteRangesToTimeRanges(aByteRanges, &video); - } + mPrivate->mIndexes[0]->ConvertByteRangesToTimeRanges(aByteRanges, aIntervals); - nsTArray> audio; - if (HasValidAudio()) { + for (int i = 1; i < mPrivate->mIndexes.Length(); i++) { nsTArray> ranges; - if (!HasValidVideo()) { - mPrivate->mAudioIndex->ConvertByteRangesToTimeRanges(aByteRanges, - aIntervals); - return; - } - mPrivate->mAudioIndex->ConvertByteRangesToTimeRanges(aByteRanges, &audio); - } + mPrivate->mIndexes[i]->ConvertByteRangesToTimeRanges(aByteRanges, &ranges); - Interval::Intersection(audio, video, aIntervals); + nsTArray> intersection; + Interval::Intersection(*aIntervals, ranges, &intersection); + *aIntervals = intersection; + } } } // namespace mp4_demuxer