Bug 1268868: [MSE] P2. Reset longest duration after keyframe is seen. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 30 Apr 2016 13:10:15 +1000
changeset 358121 83bcf409c4ed25b724df214e9ddcde7e312f1c0c
parent 358120 d14dc334734adccc6741093c388e13c7099a8a38
child 358122 697ce34a416e2d932cecdd845ef8f8c9ea27368d
push id16941
push userbmo:jbeich@FreeBSD.org
push dateSun, 01 May 2016 11:16:34 +0000
reviewersgerald
bugs1268868
milestone49.0a1
Bug 1268868: [MSE] P2. Reset longest duration after keyframe is seen. r=gerald This makes us closer to the spec, while still allowing some leeway in gap detection which was found to too strict in the past. MozReview-Commit-ID: 9EPT2e2F6ed
dom/media/mediasource/TrackBuffersManager.cpp
dom/media/mediasource/TrackBuffersManager.h
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1543,18 +1543,20 @@ TrackBuffersManager::ProcessFrames(Track
       Some(TimeUnit::FromMicroseconds(sample->mTimecode));
     // 18. Set last frame duration for track buffer to frame duration.
     trackBuffer.mLastFrameDuration =
       Some(TimeUnit::FromMicroseconds(sample->mDuration));
 
     trackBuffer.mLongestFrameDuration =
       Some(trackBuffer.mLongestFrameDuration.isNothing()
            ? trackBuffer.mLastFrameDuration.ref()
-           : std::max(trackBuffer.mLastFrameDuration.ref(),
-                      trackBuffer.mLongestFrameDuration.ref()));
+           : sample->mKeyframe
+             ? trackBuffer.mLastFrameDuration.ref()
+             : std::max(trackBuffer.mLastFrameDuration.ref(),
+                        trackBuffer.mLongestFrameDuration.ref()));
 
     // 19. If highest end timestamp for track buffer is unset or frame end timestamp is greater than highest end timestamp, then set highest end timestamp for track buffer to frame end timestamp.
     if (trackBuffer.mHighestEndTimestamp.isNothing() ||
         sampleInterval.mEnd > trackBuffer.mHighestEndTimestamp.ref()) {
       trackBuffer.mHighestEndTimestamp = Some(sampleInterval.mEnd);
     }
     // 20. If frame end timestamp is greater than group end timestamp, then set group end timestamp equal to frame end timestamp.
     if (sampleInterval.mEnd > mSourceBufferAttributes->GetGroupEndTimestamp()) {
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -263,17 +263,17 @@ private:
     // been appended yet.
     Maybe<media::TimeUnit> mLastFrameDuration;
     // Highest end timestamp variable that stores the highest coded frame end
     // timestamp across all coded frames in the current coded frame group that
     // were appended to this track buffer.
     // The variable is initially unset to indicate that no coded frames have
     // been appended yet.
     Maybe<media::TimeUnit> mHighestEndTimestamp;
-    // Longest frame duration seen in a coded frame group.
+    // Longest frame duration seen since last random access point.
     Maybe<media::TimeUnit> mLongestFrameDuration;
     // Need random access point flag variable that keeps track of whether the
     // track buffer is waiting for a random access point coded frame.
     // The variable is initially set to true to indicate that random access
     // point coded frame is needed before anything can be added to the track
     // buffer.
     bool mNeedRandomAccessPoint;
     RefPtr<MediaTrackDemuxer> mDemuxer;