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

Unified Diff: media/filters/source_buffer_stream.cc

Issue 1491513002: [MSE] Fix GC with media_time past the last appended buffer timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
Index: media/filters/source_buffer_stream.cc
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc
index 4c74c2ac73011195ff49609231828857ab62ca05..9c8f5cca3d14406c4d7c0712ff57aca7ba06f501 100644
--- a/media/filters/source_buffer_stream.cc
+++ b/media/filters/source_buffer_stream.cc
@@ -140,6 +140,7 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config,
media_segment_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
+ last_appended_buffer_duration_(kNoTimestamp()),
wolenetz 2015/12/01 01:12:43 nit: some of these common initializers can now hap
servolk 2015/12/01 18:51:49 Done.
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
memory_limit_(kSourceBufferAudioMemoryLimit),
@@ -156,6 +157,7 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config,
media_segment_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
+ last_appended_buffer_duration_(kNoTimestamp()),
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
memory_limit_(kSourceBufferVideoMemoryLimit),
@@ -173,6 +175,7 @@ SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config,
media_segment_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
+ last_appended_buffer_duration_(kNoTimestamp()),
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
memory_limit_(kSourceBufferAudioMemoryLimit),
@@ -202,6 +205,7 @@ void SourceBufferStream::OnNewMediaSegment(
!AreAdjacentInSequence(last_appended_buffer_timestamp_,
media_segment_start_time)) {
last_appended_buffer_timestamp_ = kNoDecodeTimestamp();
+ last_appended_buffer_duration_ = kNoTimestamp();
last_appended_buffer_is_keyframe_ = false;
DVLOG(3) << __FUNCTION__ << " next appended buffers will be in a new range";
} else if (last_range != ranges_.end()) {
@@ -269,6 +273,7 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
if (range_for_next_append_ != ranges_.end()) {
(*range_for_next_append_)->AppendBuffersToEnd(buffers);
last_appended_buffer_timestamp_ = buffers.back()->GetDecodeTimestamp();
+ last_appended_buffer_duration_ = buffers.back()->duration();
last_appended_buffer_is_keyframe_ = buffers.back()->is_key_frame();
} else {
DecodeTimestamp new_range_start_time = std::min(
@@ -292,6 +297,7 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
// buffer state and return.
if (itr == buffers.end()) {
last_appended_buffer_timestamp_ = buffers.back()->GetDecodeTimestamp();
+ last_appended_buffer_duration_ = buffers.back()->duration();
last_appended_buffer_is_keyframe_ = buffers.back()->is_key_frame();
DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName()
<< ": new buffers in the middle of media segment depend on"
@@ -319,6 +325,7 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
base::Unretained(this))));
last_appended_buffer_timestamp_ =
buffers_for_new_range->back()->GetDecodeTimestamp();
+ last_appended_buffer_duration_ = buffers_for_new_range->back()->duration();
last_appended_buffer_is_keyframe_ =
buffers_for_new_range->back()->is_key_frame();
}
@@ -656,7 +663,9 @@ bool SourceBufferStream::GarbageCollectIfNeeded(DecodeTimestamp media_time,
// If last appended buffer position was earlier than the current playback time
// then try deleting data between last append and current media_time.
if (last_appended_buffer_timestamp_ != kNoDecodeTimestamp() &&
- last_appended_buffer_timestamp_ < media_time) {
+ last_appended_buffer_duration_ != kNoTimestamp() &&
+ media_time >
+ last_appended_buffer_timestamp_ + last_appended_buffer_duration_) {
size_t between = FreeBuffersAfterLastAppended(bytes_to_free, media_time);
DVLOG(3) << __FUNCTION__ << " FreeBuffersAfterLastAppended "
<< " released " << between << " bytes"
@@ -674,6 +683,8 @@ bool SourceBufferStream::GarbageCollectIfNeeded(DecodeTimestamp media_time,
if (range_for_next_append_ != ranges_.end()) {
DCHECK((*range_for_next_append_)->GetStartTimestamp() <= media_time);
media_time = (*range_for_next_append_)->GetStartTimestamp();
+ DVLOG(3) << __FUNCTION__ << " media_time adjusted to "
+ << media_time.InSecondsF();
}
}

Powered by Google App Engine
This is Rietveld 408576698