author | Jean-Yves Avenard <jyavenard@mozilla.com> |
Sat, 12 Sep 2015 20:49:56 +1000 | |
changeset 262117 | 78b76b57de21c0e91732217de2db85728465f137 |
parent 262116 | f760a0088a813ae91c79f6df83f0caf25b71c9b4 |
child 262118 | 1794ed0461559432d6685eab79bf41f6351e46d6 |
push id | 64927 |
push user | jyavenard@mozilla.com |
push date | Sat, 12 Sep 2015 11:17:15 +0000 |
treeherder | mozilla-inbound@f72d4bfd2811 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gerald |
bugs | 1188238 |
milestone | 43.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
|
dom/media/mediasource/TrackBuffersManager.cpp | file | annotate | diff | comparison | revisions | |
dom/media/mediasource/TrackBuffersManager.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -1563,53 +1563,56 @@ TrackBuffersManager::ProcessFrames(Track } if (samples.Length()) { InsertFrames(samples, samplesRange, trackBuffer); trackBuffer.mSizeBuffer += sizeNewSamples; } } -void +bool TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData, const TimeUnit& aSampleTime) { if (aTrackData.mNextInsertionIndex.isSome()) { - return; + return true; } TrackBuffer& data = aTrackData.mBuffers.LastElement(); if (data.IsEmpty() || aSampleTime < aTrackData.mBufferedRanges.GetStart()) { aTrackData.mNextInsertionIndex = Some(size_t(0)); - return; + return true; } // Find which discontinuity we should insert the frame before. TimeInterval target; for (const auto& interval : aTrackData.mBufferedRanges) { if (aSampleTime < interval.mStart) { target = interval; break; } } if (target.IsEmpty()) { // No target found, it will be added at the end of the track buffer. 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++) { const nsRefPtr<MediaRawData>& sample = data[i]; if (sample->mTime >= target.mStart.ToMicroseconds() || sample->GetEndTime() > target.mStart.ToMicroseconds()) { 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 TrackBuffersManager::InsertFrames(TrackBuffer& aSamples, const TimeIntervals& aIntervals, TrackData& aTrackData) { // 5. Let track buffer equal the track buffer that the coded frame will be added to. @@ -1645,18 +1648,21 @@ TrackBuffersManager::InsertFrames(TrackB TimeIntervals intersection = trackBuffer.mBufferedRanges; intersection.Intersection(aIntervals); if (intersection.Length()) { RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0)); } // 16. Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer. - CheckNextInsertionIndex(aTrackData, - TimeUnit::FromMicroseconds(aSamples[0]->mTime)); + if (!CheckNextInsertionIndex(aTrackData, + TimeUnit::FromMicroseconds(aSamples[0]->mTime))) { + RejectProcessing(NS_ERROR_FAILURE, __func__); + return; + } // Adjust our demuxing index if necessary. if (trackBuffer.mNextGetSampleIndex.isSome() && (trackBuffer.mNextInsertionIndex.ref() < trackBuffer.mNextGetSampleIndex.ref() || (trackBuffer.mNextInsertionIndex.ref() == trackBuffer.mNextGetSampleIndex.ref() && aIntervals.GetEnd() < trackBuffer.mNextSampleTime))) { trackBuffer.mNextGetSampleIndex.ref() += aSamples.Length(); }
--- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -277,17 +277,17 @@ private: mLongestFrameDuration.reset(); mNextInsertionIndex.reset(); } }; void CheckSequenceDiscontinuity(); void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData); - void CheckNextInsertionIndex(TrackData& aTrackData, + bool CheckNextInsertionIndex(TrackData& aTrackData, const media::TimeUnit& aSampleTime); void InsertFrames(TrackBuffer& aSamples, const media::TimeIntervals& aIntervals, TrackData& aTrackData); void RemoveFrames(const media::TimeIntervals& aIntervals, TrackData& aTrackData, uint32_t aStartIndex); void UpdateBufferedRanges();