Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: media/filters/source_buffer_stream.cc

Issue 10952034: Remove lingering frames of old data when appending a new segment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reset last buffer timestamp only if appended media segments are not adjacent Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698