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

Unified Diff: media/filters/source_buffer_stream.cc

Issue 10836304: Add support for config changes during playback to FFmpegVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added WebM config change test so we get coverage on Chromium bots that don't have MP4 enabled. Created 8 years, 4 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
Index: media/filters/source_buffer_stream.cc
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc
index c76842391532f3b235dc3c98322035dd14ed5e05..c92b5fee737443ec2f3d980dc5e6587052693bb3 100644
--- a/media/filters/source_buffer_stream.cc
+++ b/media/filters/source_buffer_stream.cc
@@ -270,8 +270,6 @@ namespace media {
SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config)
: current_config_index_(0),
append_config_index_(0),
- audio_configs_(1),
- video_configs_(0),
stream_start_time_(kNoTimestamp()),
seek_pending_(false),
seek_buffer_timestamp_(kNoTimestamp()),
@@ -282,15 +280,14 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config)
last_buffer_timestamp_(kNoTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
memory_limit_(kDefaultAudioMemoryLimit) {
- audio_configs_[0] = new AudioDecoderConfig();
- audio_configs_[0]->CopyFrom(audio_config);
+ DCHECK(audio_config.IsValidConfig());
+ audio_configs_.push_back(new AudioDecoderConfig());
+ audio_configs_.back()->CopyFrom(audio_config);
}
SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config)
: current_config_index_(0),
append_config_index_(0),
- audio_configs_(0),
- video_configs_(1),
stream_start_time_(kNoTimestamp()),
seek_pending_(false),
seek_buffer_timestamp_(kNoTimestamp()),
@@ -301,8 +298,9 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config)
last_buffer_timestamp_(kNoTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
memory_limit_(kDefaultVideoMemoryLimit) {
- video_configs_[0] = new VideoDecoderConfig();
- video_configs_[0]->CopyFrom(video_config);
+ DCHECK(video_config.IsValidConfig());
+ video_configs_.push_back(new VideoDecoderConfig());
+ video_configs_.back()->CopyFrom(video_config);
}
SourceBufferStream::~SourceBufferStream() {
@@ -736,6 +734,7 @@ void SourceBufferStream::Seek(base::TimeDelta timestamp) {
DCHECK(timestamp >= stream_start_time_);
SetSelectedRange(NULL);
track_buffer_.clear();
+ config_change_pending_ = false;
if (ShouldSeekToStartOfBuffered(timestamp)) {
SetSelectedRange(ranges_.front());
@@ -767,9 +766,13 @@ bool SourceBufferStream::IsSeekPending() const {
SourceBufferStream::Status SourceBufferStream::GetNextBuffer(
scoped_refptr<StreamParserBuffer>* out_buffer) {
+ CHECK(!config_change_pending_);
+
if (!track_buffer_.empty()) {
- if (track_buffer_.front()->GetConfigId() != current_config_index_)
+ if (track_buffer_.front()->GetConfigId() != current_config_index_) {
+ config_change_pending_ = true;
return kConfigChange;
+ }
*out_buffer = track_buffer_.front();
track_buffer_.pop_front();
@@ -779,8 +782,10 @@ SourceBufferStream::Status SourceBufferStream::GetNextBuffer(
if (!selected_range_ || !selected_range_->HasNextBuffer())
return kNeedBuffer;
- if (selected_range_->GetNextConfigId() != current_config_index_)
+ if (selected_range_->GetNextConfigId() != current_config_index_) {
+ config_change_pending_ = true;
return kConfigChange;
+ }
CHECK(selected_range_->GetNextBuffer(out_buffer));
return kSuccess;
@@ -852,12 +857,14 @@ bool SourceBufferStream::IsEndSelected() const {
}
const AudioDecoderConfig& SourceBufferStream::GetCurrentAudioDecoderConfig() {
- CompleteConfigChange();
+ if (config_change_pending_)
+ CompleteConfigChange();
return *audio_configs_[current_config_index_];
}
const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() {
- CompleteConfigChange();
+ if (config_change_pending_)
+ CompleteConfigChange();
return *video_configs_[current_config_index_];
}
@@ -933,15 +940,15 @@ bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config) {
}
void SourceBufferStream::CompleteConfigChange() {
+ config_change_pending_ = false;
+
if (!track_buffer_.empty()) {
current_config_index_ = track_buffer_.front()->GetConfigId();
return;
}
- if (!selected_range_ || !selected_range_->HasNextBuffer())
- return;
-
- current_config_index_ = selected_range_->GetNextConfigId();
+ if (selected_range_ && selected_range_->HasNextBuffer())
+ current_config_index_ = selected_range_->GetNextConfigId();
}
SourceBufferRange::SourceBufferRange(

Powered by Google App Engine
This is Rietveld 408576698