Bug 1268868: [MSE] P1. Re-enable gap detection within a media segment. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 30 Apr 2016 12:41:32 +1000
changeset 358059 b3cf4bb92b18e8fd6d539906392eaf965d478a95
parent 357990 2b7c421063ad7e30b6491d62ed8480ca333b628a
child 358060 138fa76a495d40473b4248df81b2c9fded608a4e
push id16926
push userbmo:jyavenard@mozilla.com
push dateSat, 30 Apr 2016 09:43:42 +0000
reviewersgerald
bugs1268868
milestone49.0a1
Bug 1268868: [MSE] P1. Re-enable gap detection within a media segment. r?gerald It had originally been added to improve speed though further changes to the processing of frames made this optimization unecessary. And it means that we don't properly handle invalid media segment with discontinuities within their range. MozReview-Commit-ID: wGjWEQxLX3
dom/media/mediasource/TrackBuffersManager.cpp
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1393,21 +1393,16 @@ TrackBuffersManager::ProcessFrames(Track
     : TimeInterval(mAppendWindow.mStart, mAppendWindow.mEnd,
                    trackBuffer.mLongestFrameDuration.refOr(TimeUnit::FromMicroseconds(aSamples[0]->mDuration)));
 
   TimeIntervals samplesRange;
   uint32_t sizeNewSamples = 0;
   TrackBuffer samples; // array that will contain the frames to be added
                        // to our track buffer.
 
-  // We assume that no frames are contiguous within a media segment and as such
-  // don't need to check for discontinuity except for the first frame and should
-  // a frame be ignored due to the target window.
-  bool needDiscontinuityCheck = true;
-
   if (aSamples.Length()) {
     aTrackData.mLastParsedEndTime = TimeUnit();
   }
 
   for (auto& sample : aSamples) {
     SAMPLE_DEBUG("Processing %s frame(pts:%lld end:%lld, dts:%lld, duration:%lld, "
                "kf:%d)",
                aTrackData.mInfo->mMimeType.get(),
@@ -1458,17 +1453,17 @@ TrackBuffersManager::ProcessFrames(Track
       mSourceBufferAttributes->mGenerateTimestamps
         ? mSourceBufferAttributes->GetTimestampOffset()
         : TimeUnit::FromMicroseconds(sample->mTimecode) + mSourceBufferAttributes->GetTimestampOffset();
 
     // 6. If last decode timestamp for track buffer is set and decode timestamp is less than last decode timestamp:
     // OR
     // If last decode timestamp for track buffer is set and the difference between decode timestamp and last decode timestamp is greater than 2 times last frame duration:
 
-    if (needDiscontinuityCheck && trackBuffer.mLastDecodeTimestamp.isSome() &&
+    if (trackBuffer.mLastDecodeTimestamp.isSome() &&
         (decodeTimestamp < trackBuffer.mLastDecodeTimestamp.ref() ||
          decodeTimestamp - trackBuffer.mLastDecodeTimestamp.ref() > 2*trackBuffer.mLongestFrameDuration.ref())) {
       MSE_DEBUG("Discontinuity detected.");
       SourceBufferAppendMode appendMode = mSourceBufferAttributes->GetAppendMode();
 
       // 1a. If mode equals "segments":
       if (appendMode == SourceBufferAppendMode::Segments) {
         // Set group end timestamp to presentation timestamp.
@@ -1508,17 +1503,16 @@ TrackBuffersManager::ProcessFrames(Track
             : TimeInterval(TimeUnit::FromMicroseconds(sample->mTime) + mSourceBufferAttributes->GetTimestampOffset(),
                            TimeUnit::FromMicroseconds(sample->GetEndTime()) + mSourceBufferAttributes->GetTimestampOffset());
         decodeTimestamp =
           mSourceBufferAttributes->mGenerateTimestamps
             ? mSourceBufferAttributes->GetTimestampOffset()
             : TimeUnit::FromMicroseconds(sample->mTimecode) + mSourceBufferAttributes->GetTimestampOffset();
       }
       trackBuffer.mNeedRandomAccessPoint = false;
-      needDiscontinuityCheck = false;
     }
 
     // 7. Let frame end timestamp equal the sum of presentation timestamp and frame duration.
     // This is sampleInterval.mEnd
 
     // 8. If presentation timestamp is less than appendWindowStart, then set the need random access point flag to true, drop the coded frame, and jump to the top of the loop to start processing the next coded frame.
     // 9. If frame end timestamp is greater than appendWindowEnd, then set the need random access point flag to true, drop the coded frame, and jump to the top of the loop to start processing the next coded frame.
     if (!targetWindow.ContainsWithStrictEnd(sampleInterval)) {
@@ -1527,17 +1521,16 @@ TrackBuffersManager::ProcessFrames(Track
         // Insert the samples processed so far.
         InsertFrames(samples, samplesRange, trackBuffer);
         samples.Clear();
         samplesRange = TimeIntervals();
         trackBuffer.mSizeBuffer += sizeNewSamples;
         sizeNewSamples = 0;
       }
       trackBuffer.mNeedRandomAccessPoint = true;
-      needDiscontinuityCheck = true;
       continue;
     }
 
     samplesRange += sampleInterval;
     sizeNewSamples += sample->ComputedSizeOfIncludingThis();
     sample->mTime = sampleInterval.mStart.ToMicroseconds();
     sample->mTimecode = decodeTimestamp.ToMicroseconds();
     sample->mTrackInfo = trackBuffer.mLastInfo;