Index: media/renderers/renderer_impl.cc |
diff --git a/media/renderers/renderer_impl.cc b/media/renderers/renderer_impl.cc |
index b10dbd05bfe3b86a56e10e79873ba40c0567087f..0d7d2aaf6763890b66da12f33452868469bf6a2e 100644 |
--- a/media/renderers/renderer_impl.cc |
+++ b/media/renderers/renderer_impl.cc |
@@ -350,15 +350,16 @@ bool RendererImpl::GetWallClockTimes( |
} |
bool RendererImpl::HasEncryptedStream() { |
- DemuxerStream* audio_stream = |
- media_resource_->GetStream(DemuxerStream::AUDIO); |
- if (audio_stream && audio_stream->audio_decoder_config().is_encrypted()) |
- return true; |
+ std::vector<DemuxerStream*> demuxer_streams = media_resource_->GetStreams(); |
- DemuxerStream* video_stream = |
- media_resource_->GetStream(DemuxerStream::VIDEO); |
- if (video_stream && video_stream->video_decoder_config().is_encrypted()) |
- return true; |
+ for (const auto& stream : demuxer_streams) { |
+ if (stream->type() == DemuxerStream::AUDIO && |
+ stream->audio_decoder_config().is_encrypted()) |
+ return true; |
+ if (stream->type() == DemuxerStream::VIDEO && |
+ stream->video_decoder_config().is_encrypted()) |
+ return true; |
+ } |
return false; |
} |
@@ -381,17 +382,22 @@ void RendererImpl::InitializeAudioRenderer() { |
PipelineStatusCB done_cb = |
base::Bind(&RendererImpl::OnAudioRendererInitializeDone, weak_this_); |
- DemuxerStream* audio_stream = |
- media_resource_->GetStream(DemuxerStream::AUDIO); |
+ // TODO(servolk): Implement proper support for multiple streams. But for now |
+ // pick the first enabled stream to preserve the existing behavior. |
+ std::vector<DemuxerStream*> streams = media_resource_->GetStreams(); |
+ DemuxerStream* audio_stream = nullptr; |
+ for (const auto& stream : streams) { |
+ if (stream->type() == DemuxerStream::AUDIO && stream->enabled()) { |
+ audio_stream = stream; |
+ break; |
+ } |
+ } |
if (!audio_stream) { |
audio_renderer_.reset(); |
task_runner_->PostTask(FROM_HERE, base::Bind(done_cb, PIPELINE_OK)); |
return; |
} |
- audio_stream->SetStreamStatusChangeCB(base::Bind( |
- &RendererImpl::OnStreamStatusChanged, weak_this_, audio_stream)); |
- |
audio_renderer_client_.reset( |
new RendererClientInternal(DemuxerStream::AUDIO, this)); |
// Note: After the initialization of a renderer, error events from it may |
@@ -430,17 +436,22 @@ void RendererImpl::InitializeVideoRenderer() { |
PipelineStatusCB done_cb = |
base::Bind(&RendererImpl::OnVideoRendererInitializeDone, weak_this_); |
- DemuxerStream* video_stream = |
- media_resource_->GetStream(DemuxerStream::VIDEO); |
+ // TODO(servolk): Implement proper support for multiple streams. But for now |
+ // pick the first enabled stream to preserve the existing behavior. |
+ std::vector<DemuxerStream*> streams = media_resource_->GetStreams(); |
+ DemuxerStream* video_stream = nullptr; |
+ for (const auto& stream : streams) { |
+ if (stream->type() == DemuxerStream::VIDEO && stream->enabled()) { |
+ video_stream = stream; |
+ break; |
+ } |
+ } |
if (!video_stream) { |
video_renderer_.reset(); |
task_runner_->PostTask(FROM_HERE, base::Bind(done_cb, PIPELINE_OK)); |
return; |
} |
- video_stream->SetStreamStatusChangeCB(base::Bind( |
- &RendererImpl::OnStreamStatusChanged, weak_this_, video_stream)); |
- |
video_renderer_client_.reset( |
new RendererClientInternal(DemuxerStream::VIDEO, this)); |
video_renderer_->Initialize( |
@@ -469,6 +480,9 @@ void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { |
return; |
} |
+ media_resource_->SetStreamStatusChangeCB( |
+ base::Bind(&RendererImpl::OnStreamStatusChanged, weak_this_)); |
+ |
if (audio_renderer_) { |
time_source_ = audio_renderer_->GetTimeSource(); |
} else if (!time_source_) { |