Index: media/remoting/courier_renderer.cc |
diff --git a/media/remoting/courier_renderer.cc b/media/remoting/courier_renderer.cc |
index 30a3dce4a27ed3a9d728e2cc7ecc6a4f8b8c05b8..15f09d057c13b05a2c1a5f426db77a84bb18108e 100644 |
--- a/media/remoting/courier_renderer.cc |
+++ b/media/remoting/courier_renderer.cc |
@@ -18,7 +18,7 @@ |
#include "base/time/time.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/buffering_state.h" |
-#include "media/base/demuxer_stream_provider.h" |
+#include "media/base/media_resource.h" |
#include "media/base/renderer_client.h" |
#include "media/remoting/demuxer_stream_adapter.h" |
#include "media/remoting/proto_enum_utils.h" |
@@ -64,7 +64,7 @@ CourierRenderer::CourierRenderer( |
: state_(STATE_UNINITIALIZED), |
main_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
media_task_runner_(std::move(media_task_runner)), |
- demuxer_stream_provider_(nullptr), |
+ media_resource_(nullptr), |
client_(nullptr), |
controller_(controller), |
rpc_broker_(controller_->GetRpcBroker()), |
@@ -104,12 +104,12 @@ CourierRenderer::~CourierRenderer() { |
rpc_broker_, rpc_handle_)); |
} |
-void CourierRenderer::Initialize(DemuxerStreamProvider* demuxer_stream_provider, |
+void CourierRenderer::Initialize(MediaResource* media_resource, |
RendererClient* client, |
const PipelineStatusCB& init_cb) { |
VLOG(2) << __func__; |
DCHECK(media_task_runner_->BelongsToCurrentThread()); |
- DCHECK(demuxer_stream_provider); |
+ DCHECK(media_resource); |
DCHECK(client); |
if (state_ != STATE_UNINITIALIZED) { |
@@ -118,22 +118,31 @@ void CourierRenderer::Initialize(DemuxerStreamProvider* demuxer_stream_provider, |
return; |
} |
- demuxer_stream_provider_ = demuxer_stream_provider; |
+ media_resource_ = media_resource; |
client_ = client; |
init_workflow_done_callback_ = init_cb; |
state_ = STATE_CREATE_PIPE; |
+ |
+ std::vector<::media::DemuxerStream*> streams = media_resource_->GetStreams(); |
+ ::media::DemuxerStream* audio_demuxer_stream = nullptr; |
+ ::media::DemuxerStream* video_demuxer_stream = nullptr; |
+ for (const auto& s : streams) { |
+ if (s->type() == DemuxerStream::AUDIO && s->enabled() && |
+ !audio_demuxer_stream) |
+ audio_demuxer_stream = s; |
+ if (s->type() == DemuxerStream::VIDEO && s->enabled() && |
+ !video_demuxer_stream) |
+ video_demuxer_stream = s; |
+ } |
+ |
// Create audio mojo data pipe handles if audio is available. |
- DemuxerStream* audio_demuxer_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
std::unique_ptr<mojo::DataPipe> audio_data_pipe; |
if (audio_demuxer_stream) { |
audio_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe()); |
} |
// Create video mojo data pipe handles if video is available. |
- DemuxerStream* video_demuxer_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
std::unique_ptr<mojo::DataPipe> video_data_pipe; |
if (video_demuxer_stream) { |
video_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe()); |
@@ -323,9 +332,20 @@ void CourierRenderer::OnDataPipeCreated( |
return; // Abort because something went wrong in the meantime. |
DCHECK_EQ(state_, STATE_CREATE_PIPE); |
+ // TODO(erickung): Make remote renderer multi-stream capable. |
+ std::vector<::media::DemuxerStream*> streams = media_resource_->GetStreams(); |
+ ::media::DemuxerStream* audio_demuxer_stream = nullptr; |
+ ::media::DemuxerStream* video_demuxer_stream = nullptr; |
+ for (const auto& s : streams) { |
+ if (s->type() == DemuxerStream::AUDIO && s->enabled() && |
+ !audio_demuxer_stream) |
+ audio_demuxer_stream = s; |
+ if (s->type() == DemuxerStream::VIDEO && s->enabled() && |
+ !video_demuxer_stream) |
+ video_demuxer_stream = s; |
+ } |
+ |
// Create audio demuxer stream adapter if audio is available. |
- DemuxerStream* audio_demuxer_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
if (audio_demuxer_stream && audio.is_valid() && audio_handle.is_valid() && |
audio_rpc_handle != RpcBroker::kInvalidHandle) { |
VLOG(2) << "Initialize audio"; |
@@ -337,8 +357,6 @@ void CourierRenderer::OnDataPipeCreated( |
} |
// Create video demuxer stream adapter if video is available. |
- DemuxerStream* video_demuxer_stream = |
- demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
if (video_demuxer_stream && video.is_valid() && video_handle.is_valid() && |
video_rpc_handle != RpcBroker::kInvalidHandle) { |
VLOG(2) << "Initialize video"; |