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
--- 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;