Bug 1268868: [MSE] P2. Reset longest duration after keyframe is seen. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 30 Apr 2016 13:10:15 +1000
changeset 358060 138fa76a495d40473b4248df81b2c9fded608a4e
parent 358059 b3cf4bb92b18e8fd6d539906392eaf965d478a95
child 358061 66adff99550e99641b07dbcdbbc2c41f8c5472d2
push id16926
push userbmo:jyavenard@mozilla.com
push dateSat, 30 Apr 2016 09:43:42 +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;