diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 18:28:39 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 18:28:39 +0000 |
commit | 434d371706517cf720fc5827d9120b04e52d98b4 (patch) | |
tree | 606b90fb78947a015e1b5533c57a256600a54e16 /media | |
parent | 41b0021c13870f41b76884abba7a2656ea661e48 (diff) | |
download | chromium_src-434d371706517cf720fc5827d9120b04e52d98b4.zip chromium_src-434d371706517cf720fc5827d9120b04e52d98b4.tar.gz chromium_src-434d371706517cf720fc5827d9120b04e52d98b4.tar.bz2 |
Prevent SourceBufferRange.waiting_for_keyframe_ from being lost on range merges.
BUG=168682
TEST=SourceBufferStreamTest.OverlapSplitAndMergeWhileWaitingForMoreData
Review URL: https://chromiumcodereview.appspot.com/11785029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/filters/source_buffer_stream.cc | 9 | ||||
-rw-r--r-- | media/filters/source_buffer_stream_unittest.cc | 37 |
2 files changed, 44 insertions, 2 deletions
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc index 0b3ef91..c49772b 100644 --- a/media/filters/source_buffer_stream.cc +++ b/media/filters/source_buffer_stream.cc @@ -1504,8 +1504,13 @@ void SourceBufferRange::AppendRangeToEnd(const SourceBufferRange& range, DCHECK(CanAppendRangeToEnd(range)); DCHECK(!buffers_.empty()); - if (transfer_current_position) - next_buffer_index_ = range.next_buffer_index_ + buffers_.size(); + if (transfer_current_position) { + if (range.next_buffer_index_ >= 0) + next_buffer_index_ = range.next_buffer_index_ + buffers_.size(); + + waiting_for_keyframe_ = range.waiting_for_keyframe_; + next_keyframe_timestamp_ = range.next_keyframe_timestamp_; + } AppendBuffersToEnd(range.buffers_); } diff --git a/media/filters/source_buffer_stream_unittest.cc b/media/filters/source_buffer_stream_unittest.cc index 722d6d6..cd12d5d 100644 --- a/media/filters/source_buffer_stream_unittest.cc +++ b/media/filters/source_buffer_stream_unittest.cc @@ -2559,6 +2559,43 @@ TEST_F(SourceBufferStreamTest, SetExplicitDuration_DeletePartialSelectedRange) { CheckExpectedRanges("{ [0,4) [10,10) }"); } +// Test the case were the current playback position is at the end of the +// buffered data and several overlaps occur that causes the selected +// range to get split and then merged back into a single range. +TEST_F(SourceBufferStreamTest, OverlapSplitAndMergeWhileWaitingForMoreData) { + // Seek to start of stream. + SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); + + NewSegmentAppend("0K 30 60 90 120K 150"); + CheckExpectedRangesByTimestamp("{ [0,180) }"); + + // Read all the buffered data. + CheckExpectedBuffers("0K 30 60 90 120K 150"); + CheckNoNextBuffer(); + + // Append data over the current GOP so that a keyframe is needed before + // playback can continue from the current position. + NewSegmentAppend("120K 150"); + CheckExpectedRangesByTimestamp("{ [0,180) }"); + + // Append buffers that cause the range to get split. + NewSegmentAppend("0K 30"); + CheckExpectedRangesByTimestamp("{ [0,60) [120,180) }"); + + // Append buffers that cause the ranges to get merged. + AppendBuffers("60 90"); + + CheckExpectedRangesByTimestamp("{ [0,180) }"); + + // Verify that we still don't have a next buffer. + CheckNoNextBuffer(); + + // Add more data to the end and verify that this new data is read correctly. + NewSegmentAppend("180K 210"); + CheckExpectedRangesByTimestamp("{ [0,240) }"); + CheckExpectedBuffers("180K 210"); +} + // TODO(vrk): Add unit tests where keyframes are unaligned between streams. // (crbug.com/133557) |