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

Unified Diff: media/filters/source_buffer_stream.cc

Issue 341083004: Introduce the playback time into the MSE garbage collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « media/filters/source_buffer_stream.h ('k') | 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 fe22b4a795eaf0f0ed102cdc93c748ce005ffc8e..8381ab07be5df8ab61e14de5909e6b4c104a0c1c 100644
--- a/media/filters/source_buffer_stream.cc
+++ b/media/filters/source_buffer_stream.cc
@@ -126,6 +126,10 @@ class SourceBufferRange {
base::TimeDelta start_timestamp, base::TimeDelta end_timestamp,
int bytes_to_free, base::TimeDelta* end_removal_timestamp);
+ // Indicates whether the GOP at the beginning of the range
+ // has timestamps all lower than |media_time|.
+ bool FirstGOPEarlierThanMediaTime(base::TimeDelta media_time) const;
+
// Indicates whether the GOP at the beginning or end of the range contains the
// next buffer position.
bool FirstGOPContainsNextBufferPosition() const;
@@ -351,6 +355,7 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config,
end_of_stream_(false),
seek_buffer_timestamp_(kNoTimestamp()),
selected_range_(NULL),
+ current_media_time_(kNoTimestamp()),
media_segment_start_time_(kNoTimestamp()),
range_for_next_append_(ranges_.end()),
new_media_segment_(false),
@@ -377,6 +382,7 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config,
end_of_stream_(false),
seek_buffer_timestamp_(kNoTimestamp()),
selected_range_(NULL),
+ current_media_time_(kNoTimestamp()),
media_segment_start_time_(kNoTimestamp()),
range_for_next_append_(ranges_.end()),
new_media_segment_(false),
@@ -404,6 +410,7 @@ SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config,
end_of_stream_(false),
seek_buffer_timestamp_(kNoTimestamp()),
selected_range_(NULL),
+ current_media_time_(kNoTimestamp()),
media_segment_start_time_(kNoTimestamp()),
range_for_next_append_(ranges_.end()),
new_media_segment_(false),
@@ -902,6 +909,10 @@ int SourceBufferStream::FreeBuffers(int total_bytes_to_free,
DCHECK_EQ(current_range, selected_range_);
break;
}
+ if (current_media_time_ != kNoTimestamp() &&
+ !current_range->FirstGOPEarlierThanMediaTime(current_media_time_)) {
acolwell GONE FROM CHROMIUM 2014/06/19 16:00:25 Don't you really want FirstGOPContainsMediaTime(cu
+ break;
+ }
bytes_deleted = current_range->DeleteGOPFromFront(&buffers);
}
@@ -1074,10 +1085,23 @@ void SourceBufferStream::MergeWithAdjacentRangeIfNecessary(
DeleteAndRemoveRange(&next_range_itr);
}
+void SourceBufferStream::NotifyMediaTimeUpdate(base::TimeDelta media_time) {
+ if (current_media_time_ != kNoTimestamp() &&
+ media_time < current_media_time_) {
+ LOG(WARNING) << "Time should be monotonically increasing: "
+ << media_time.InMilliseconds()
+ << " " << current_media_time_.InMilliseconds();
+ return;
+ }
+ current_media_time_ = media_time;
+}
+
void SourceBufferStream::Seek(base::TimeDelta timestamp) {
DCHECK(timestamp >= base::TimeDelta());
ResetSeekState();
+ current_media_time_ = kNoTimestamp();
+
if (ShouldSeekToStartOfBuffered(timestamp)) {
ranges_.front()->SeekToStart();
SetSelectedRange(ranges_.front());
@@ -1988,6 +2012,16 @@ int SourceBufferRange::GetRemovalGOP(
return bytes_removed;
}
+bool SourceBufferRange::FirstGOPEarlierThanMediaTime(
+ base::TimeDelta media_time) const {
+ if (keyframe_map_.size() == 1u)
+ return (GetEndTimestamp() < media_time);
+
+ KeyframeMap::const_iterator second_gop = keyframe_map_.begin();
+ ++second_gop;
+ return second_gop->first <= media_time;
+}
+
bool SourceBufferRange::FirstGOPContainsNextBufferPosition() const {
if (!HasNextBufferPosition())
return false;
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698