Commit 674907fe authored by wolenetz's avatar wolenetz Committed by Commit bot

MSE: Reduce spurious buffered range discontinuities

Includes last frame's duration in the determination of
SourceBufferStream's |max_interbuffer_distance_|, to prevent an
unusually long segment-ending frame from triggering discontinuity when
adjacent buffers are appended.  A more correct fix requires
StreamParsers to always emit valid frame durations (crbug 351166), and
would use them exclusively to determine discontinuity.

BUG=351489
R=dalecurtis@chromium.org
TEST=No media_unittest, layout, or yt-dash-mse ToT conformance regression. Fixes b/17570928.

Review URL: https://codereview.chromium.org/597293004

Cr-Commit-Position: refs/heads/master@{#296599}
parent aae4fd51
...@@ -33,6 +33,11 @@ static bool IsRangeListSorted( ...@@ -33,6 +33,11 @@ static bool IsRangeListSorted(
// Returns an estimate of how far from the beginning or end of a range a buffer // Returns an estimate of how far from the beginning or end of a range a buffer
// can be to still be considered in the range, given the |approximate_duration| // can be to still be considered in the range, given the |approximate_duration|
// of a buffer in the stream. // of a buffer in the stream.
// TODO(wolenetz): Once all stream parsers emit accurate frame durations, use
// logic like FrameProcessor (2*last_frame_duration + last_decode_timestamp)
// instead of an overall maximum interbuffer delta for range discontinuity
// detection, and adjust similarly for splice frame discontinuity detection.
// See http://crbug.com/351489 and http://crbug.com/351166.
static base::TimeDelta ComputeFudgeRoom(base::TimeDelta approximate_duration) { static base::TimeDelta ComputeFudgeRoom(base::TimeDelta approximate_duration) {
// Because we do not know exactly when is the next timestamp, any buffer // Because we do not know exactly when is the next timestamp, any buffer
// that starts within 2x the approximate duration of a buffer is considered // that starts within 2x the approximate duration of a buffer is considered
...@@ -149,6 +154,8 @@ SourceBufferStream::~SourceBufferStream() { ...@@ -149,6 +154,8 @@ SourceBufferStream::~SourceBufferStream() {
void SourceBufferStream::OnNewMediaSegment( void SourceBufferStream::OnNewMediaSegment(
DecodeTimestamp media_segment_start_time) { DecodeTimestamp media_segment_start_time) {
DVLOG(1) << __FUNCTION__ << "(" << media_segment_start_time.InSecondsF()
<< ")";
DCHECK(!end_of_stream_); DCHECK(!end_of_stream_);
media_segment_start_time_ = media_segment_start_time; media_segment_start_time_ = media_segment_start_time;
new_media_segment_ = true; new_media_segment_ = true;
...@@ -163,8 +170,11 @@ void SourceBufferStream::OnNewMediaSegment( ...@@ -163,8 +170,11 @@ void SourceBufferStream::OnNewMediaSegment(
media_segment_start_time)) { media_segment_start_time)) {
last_appended_buffer_timestamp_ = kNoDecodeTimestamp(); last_appended_buffer_timestamp_ = kNoDecodeTimestamp();
last_appended_buffer_is_keyframe_ = false; last_appended_buffer_is_keyframe_ = false;
DVLOG(3) << __FUNCTION__ << " next appended buffers will be in a new range";
} else if (last_range != ranges_.end()) { } else if (last_range != ranges_.end()) {
DCHECK(last_range == range_for_next_append_); DCHECK(last_range == range_for_next_append_);
DVLOG(3) << __FUNCTION__ << " next appended buffers will continue range "
<< "unless intervening remove makes discontinuity";
} }
} }
...@@ -503,8 +513,15 @@ void SourceBufferStream::UpdateMaxInterbufferDistance( ...@@ -503,8 +513,15 @@ void SourceBufferStream::UpdateMaxInterbufferDistance(
DecodeTimestamp current_timestamp = (*itr)->GetDecodeTimestamp(); DecodeTimestamp current_timestamp = (*itr)->GetDecodeTimestamp();
DCHECK(current_timestamp != kNoDecodeTimestamp()); DCHECK(current_timestamp != kNoDecodeTimestamp());
base::TimeDelta interbuffer_distance = (*itr)->duration();
DCHECK(interbuffer_distance >= base::TimeDelta());
if (prev_timestamp != kNoDecodeTimestamp()) { if (prev_timestamp != kNoDecodeTimestamp()) {
base::TimeDelta interbuffer_distance = current_timestamp - prev_timestamp; interbuffer_distance =
std::max(current_timestamp - prev_timestamp, interbuffer_distance);
}
if (interbuffer_distance > base::TimeDelta()) {
if (max_interbuffer_distance_ == kNoTimestamp()) { if (max_interbuffer_distance_ == kNoTimestamp()) {
max_interbuffer_distance_ = interbuffer_distance; max_interbuffer_distance_ = interbuffer_distance;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment