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

Unified Diff: media/filters/source_buffer_stream.cc

Issue 10828425: Add support for config changes during playback to FFmpegVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add config_change_pending_ initializers to constructors. 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
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | 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 c76842391532f3b235dc3c98322035dd14ed5e05..f66cdb9b16af2ec131719835cfd375dda39c9445 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()),
@@ -281,16 +279,16 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config)
new_media_segment_(false),
last_buffer_timestamp_(kNoTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
- memory_limit_(kDefaultAudioMemoryLimit) {
- audio_configs_[0] = new AudioDecoderConfig();
- audio_configs_[0]->CopyFrom(audio_config);
+ memory_limit_(kDefaultAudioMemoryLimit),
+ config_change_pending_(false) {
+ 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()),
@@ -300,9 +298,11 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config)
new_media_segment_(false),
last_buffer_timestamp_(kNoTimestamp()),
max_interbuffer_distance_(kNoTimestamp()),
- memory_limit_(kDefaultVideoMemoryLimit) {
- video_configs_[0] = new VideoDecoderConfig();
- video_configs_[0]->CopyFrom(video_config);
+ memory_limit_(kDefaultVideoMemoryLimit),
+ config_change_pending_(false) {
+ DCHECK(video_config.IsValidConfig());
+ video_configs_.push_back(new VideoDecoderConfig());
+ video_configs_.back()->CopyFrom(video_config);
}
SourceBufferStream::~SourceBufferStream() {
@@ -736,6 +736,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 +768,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 +784,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 +859,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 +942,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(
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698