Bug 1139271: Part2. Ignore partial moof. r=k17e

This commit is contained in:
Jean-Yves Avenard 2015-03-16 23:08:56 +11:00
parent 24ffd0669a
commit 6d7c84df95
2 changed files with 18 additions and 8 deletions

View File

@ -30,17 +30,19 @@ namespace mp4_demuxer
using namespace stagefright;
using namespace mozilla;
void
bool
MoofParser::RebuildFragmentedIndex(
const nsTArray<mozilla::MediaByteRange>& aByteRanges)
{
BoxContext context(mSource, aByteRanges);
RebuildFragmentedIndex(context);
return RebuildFragmentedIndex(context);
}
void
bool
MoofParser::RebuildFragmentedIndex(BoxContext& aContext)
{
bool foundValidMoof = false;
for (Box box(&aContext, mOffset); box.IsAvailable(); box = box.Next()) {
if (box.IsType("moov")) {
mInitRange = MediaByteRange(0, box.Range().mEnd);
@ -48,6 +50,11 @@ MoofParser::RebuildFragmentedIndex(BoxContext& aContext)
} else if (box.IsType("moof")) {
Moof moof(box, mTrex, mMdhd, mEdts, mSinf, mIsAudio);
if (!moof.IsValid() && !box.Next().IsAvailable()) {
// Moof isn't valid abort search for now.
break;
}
if (!mMoofs.IsEmpty()) {
// Stitch time ranges together in the case of a (hopefully small) time
// range gap between moofs.
@ -55,9 +62,11 @@ MoofParser::RebuildFragmentedIndex(BoxContext& aContext)
}
mMoofs.AppendElement(moof);
foundValidMoof = true;
}
mOffset = box.NextOffset();
}
return foundValidMoof;
}
class BlockingStream : public Stream {
@ -100,8 +109,7 @@ MoofParser::BlockingReadNextMoof()
if (box.IsType("moof")) {
byteRanges.Clear();
byteRanges.AppendElement(MediaByteRange(mOffset, box.Range().mEnd));
RebuildFragmentedIndex(context);
return true;
return RebuildFragmentedIndex(context);
}
}
return false;
@ -240,7 +248,9 @@ Moof::Moof(Box& aBox, Trex& aTrex, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, bool a
ParseTraf(box, aTrex, aMdhd, aEdts, aSinf, aIsAudio);
}
}
ProcessCenc();
if (IsValid()) {
ProcessCenc();
}
}
bool

View File

@ -202,9 +202,9 @@ public:
// Setting the mTrex.mTrackId to 0 is a nasty work around for calculating
// the composition range for MSE. We need an array of tracks.
}
void RebuildFragmentedIndex(
bool RebuildFragmentedIndex(
const nsTArray<mozilla::MediaByteRange>& aByteRanges);
void RebuildFragmentedIndex(BoxContext& aContext);
bool RebuildFragmentedIndex(BoxContext& aContext);
Interval<Microseconds> GetCompositionRange(
const nsTArray<mozilla::MediaByteRange>& aByteRanges);
bool ReachedEnd();