Index: media/renderers/renderer_impl.cc |
diff --git a/media/renderers/renderer_impl.cc b/media/renderers/renderer_impl.cc |
index 5e99061138485fd732b5012ee1e561f22cd0e01f..aa61d0606d516c1f8dab233b84148ee517965cee 100644 |
--- a/media/renderers/renderer_impl.cc |
+++ b/media/renderers/renderer_impl.cc |
@@ -17,8 +17,8 @@ |
#include "media/base/audio_decoder_config.h" |
#include "media/base/audio_renderer.h" |
#include "media/base/bind_to_current_loop.h" |
-#include "media/base/demuxer_stream_provider.h" |
#include "media/base/media_log.h" |
+#include "media/base/media_resource.h" |
#include "media/base/media_switches.h" |
#include "media/base/renderer_client.h" |
#include "media/base/time_source.h" |
@@ -129,7 +129,7 @@ RendererImpl::~RendererImpl() { |
} |
} |
-void RendererImpl::Initialize(DemuxerStreamProvider* demuxer_stream_provider, |
+void RendererImpl::Initialize(MediaResource* media_resource, |
RendererClient* client, |
const PipelineStatusCB& init_cb) { |
DVLOG(1) << __func__; |
@@ -139,7 +139,7 @@ void RendererImpl::Initialize(DemuxerStreamProvider* demuxer_stream_provider, |
DCHECK(client); |
client_ = client; |
- demuxer_stream_provider_ = demuxer_stream_provider; |
+ media_resource_ = media_resource; |
init_cb_ = init_cb; |
if (HasEncryptedStream() && !cdm_context_) { |
@@ -350,15 +350,16 @@ bool RendererImpl::GetWallClockTimes( |
} |
bool RendererImpl::HasEncryptedStream() { |
- DemuxerStream* audio_stream = |
- demuxer_stream_provider_->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 = |
- demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
- if (video_stream && video_stream->video_decoder_config().is_encrypted()) |
- return true; |
+ for (const auto& s : demuxer_streams) { |
+ if (s->type() == DemuxerStream::AUDIO && |
+ s->audio_decoder_config().is_encrypted()) |
+ return true; |
+ if (s->type() == DemuxerStream::VIDEO && |
+ s->video_decoder_config().is_encrypted()) |
+ return true; |
+ } |
xhwang
2017/02/01 18:26:04
Do we care about disabled streams? This is another
servolk
2017/02/01 22:29:21
Actually I think this, and the unit tests make a g
|
return false; |
} |
@@ -381,17 +382,20 @@ void RendererImpl::InitializeAudioRenderer() { |
PipelineStatusCB done_cb = |
base::Bind(&RendererImpl::OnAudioRendererInitializeDone, weak_this_); |
- DemuxerStream* audio_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
+ std::vector<DemuxerStream*> streams = media_resource_->GetStreams(); |
xhwang
2017/02/01 18:26:04
ditto about comment and TODO
|
+ DemuxerStream* audio_stream = nullptr; |
+ for (const auto& s : streams) { |
+ if (s->type() == DemuxerStream::AUDIO && s->enabled()) { |
+ audio_stream = s; |
+ 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 +434,21 @@ void RendererImpl::InitializeVideoRenderer() { |
PipelineStatusCB done_cb = |
base::Bind(&RendererImpl::OnVideoRendererInitializeDone, weak_this_); |
- DemuxerStream* video_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
+ std::vector<DemuxerStream*> streams = media_resource_->GetStreams(); |
+ DemuxerStream* video_stream = nullptr; |
+ for (const auto& s : streams) { |
+ if (s->type() == DemuxerStream::VIDEO && s->enabled()) { |
+ video_stream = s; |
+ 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 +477,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_) { |