Chromium Code Reviews| Index: media/filters/source_buffer_stream.cc |
| diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc |
| index 9da441ee65de2bb8827e6a518a6bf414ed6ce274..f8b1894e51bbc4bc7b4c3a47277de00e950ed9ea 100644 |
| --- a/media/filters/source_buffer_stream.cc |
| +++ b/media/filters/source_buffer_stream.cc |
| @@ -153,6 +153,11 @@ class SourceBufferRange { |
| const scoped_refptr<media::StreamParserBuffer>& buffer, |
| base::TimeDelta timestamp) const; |
| + // Returns true if |second_timestamp| is the timestamp of the next buffer in |
| + // sequence after |first_timestamp|, false otherwise. |
| + bool AreAdjacentInSequence( |
| + base::TimeDelta first_timestamp, base::TimeDelta second_timestamp) const; |
| + |
| int size_in_bytes() const { return size_in_bytes_; } |
| private: |
| @@ -319,12 +324,20 @@ SourceBufferStream::~SourceBufferStream() { |
| void SourceBufferStream::OnNewMediaSegment( |
| base::TimeDelta media_segment_start_time) { |
| media_segment_start_time_ = media_segment_start_time; |
| + new_media_segment_ = true; |
| - // Find the range that will house the buffers appended through the next |
| - // Append() call. |
| + RangeList::iterator last_range = range_for_next_append_; |
| range_for_next_append_ = FindExistingRangeFor(media_segment_start_time); |
| - new_media_segment_ = true; |
| - last_buffer_timestamp_ = kNoTimestamp(); |
| + |
| + // Only reset |last_buffer_timestamp_| if this new media segment is not |
| + // adjacent to the previous media segment appended to the stream. |
| + if (range_for_next_append_ == ranges_.end() || |
| + !(*range_for_next_append_)->AreAdjacentInSequence( |
|
acolwell GONE FROM CHROMIUM
2012/09/19 23:15:51
This is a little awkward because it calls into the
vrk (LEFT CHROMIUM)
2012/09/20 00:00:59
Done.
|
| + last_buffer_timestamp_, media_segment_start_time)) { |
| + last_buffer_timestamp_ = kNoTimestamp(); |
| + } else { |
| + DCHECK(last_range == range_for_next_append_); |
| + } |
| } |
| bool SourceBufferStream::Append( |
| @@ -1406,8 +1419,13 @@ base::TimeDelta SourceBufferRange::GetBufferedEndTimestamp() const { |
| bool SourceBufferRange::IsNextInSequence( |
| const scoped_refptr<media::StreamParserBuffer>& buffer, |
| base::TimeDelta timestamp) const { |
| - return buffer->GetDecodeTimestamp() < timestamp && |
| - timestamp <= buffer->GetDecodeTimestamp() + GetFudgeRoom(); |
| + return AreAdjacentInSequence(buffer->GetDecodeTimestamp(), timestamp); |
| +} |
| + |
| +bool SourceBufferRange::AreAdjacentInSequence( |
| + base::TimeDelta first_timestamp, base::TimeDelta second_timestamp) const { |
| + return first_timestamp < second_timestamp && |
| + second_timestamp <= first_timestamp + GetFudgeRoom(); |
| } |
| base::TimeDelta SourceBufferRange::GetFudgeRoom() const { |