Bug 1188238: [MSE] P2. Don't assert when unable to find position in frames array. r=gerald

Instead return an error which will terminate the video element.
This commit is contained in:
Jean-Yves Avenard 2015-09-12 20:49:56 +10:00
parent 3e080a3d22
commit 7cc0172170
2 changed files with 15 additions and 9 deletions

View File

@ -1568,19 +1568,19 @@ TrackBuffersManager::ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData)
} }
} }
void bool
TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData, TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData,
const TimeUnit& aSampleTime) const TimeUnit& aSampleTime)
{ {
if (aTrackData.mNextInsertionIndex.isSome()) { if (aTrackData.mNextInsertionIndex.isSome()) {
return; return true;
} }
TrackBuffer& data = aTrackData.mBuffers.LastElement(); TrackBuffer& data = aTrackData.mBuffers.LastElement();
if (data.IsEmpty() || aSampleTime < aTrackData.mBufferedRanges.GetStart()) { if (data.IsEmpty() || aSampleTime < aTrackData.mBufferedRanges.GetStart()) {
aTrackData.mNextInsertionIndex = Some(size_t(0)); aTrackData.mNextInsertionIndex = Some(size_t(0));
return; return true;
} }
// Find which discontinuity we should insert the frame before. // Find which discontinuity we should insert the frame before.
@ -1594,17 +1594,20 @@ TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData,
if (target.IsEmpty()) { if (target.IsEmpty()) {
// No target found, it will be added at the end of the track buffer. // No target found, it will be added at the end of the track buffer.
aTrackData.mNextInsertionIndex = Some(data.Length()); aTrackData.mNextInsertionIndex = Some(data.Length());
return; return true;
} }
// We now need to find the first frame of the searched interval.
// We will insert our new frames right before.
for (uint32_t i = 0; i < data.Length(); i++) { for (uint32_t i = 0; i < data.Length(); i++) {
const nsRefPtr<MediaRawData>& sample = data[i]; const nsRefPtr<MediaRawData>& sample = data[i];
if (sample->mTime >= target.mStart.ToMicroseconds() || if (sample->mTime >= target.mStart.ToMicroseconds() ||
sample->GetEndTime() > target.mStart.ToMicroseconds()) { sample->GetEndTime() > target.mStart.ToMicroseconds()) {
aTrackData.mNextInsertionIndex = Some(size_t(i)); aTrackData.mNextInsertionIndex = Some(size_t(i));
return; return true;
} }
} }
MOZ_CRASH("Insertion Index Not Found"); NS_ASSERTION(false, "Insertion Index Not Found");
return false;
} }
void void
@ -1650,8 +1653,11 @@ TrackBuffersManager::InsertFrames(TrackBuffer& aSamples,
} }
// 16. Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer. // 16. Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer.
CheckNextInsertionIndex(aTrackData, if (!CheckNextInsertionIndex(aTrackData,
TimeUnit::FromMicroseconds(aSamples[0]->mTime)); TimeUnit::FromMicroseconds(aSamples[0]->mTime))) {
RejectProcessing(NS_ERROR_FAILURE, __func__);
return;
}
// Adjust our demuxing index if necessary. // Adjust our demuxing index if necessary.
if (trackBuffer.mNextGetSampleIndex.isSome() && if (trackBuffer.mNextGetSampleIndex.isSome() &&

View File

@ -282,7 +282,7 @@ private:
void CheckSequenceDiscontinuity(); void CheckSequenceDiscontinuity();
void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData); void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData);
void CheckNextInsertionIndex(TrackData& aTrackData, bool CheckNextInsertionIndex(TrackData& aTrackData,
const media::TimeUnit& aSampleTime); const media::TimeUnit& aSampleTime);
void InsertFrames(TrackBuffer& aSamples, void InsertFrames(TrackBuffer& aSamples,
const media::TimeIntervals& aIntervals, const media::TimeIntervals& aIntervals,