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

Unified Diff: media/mojo/clients/mojo_renderer.cc

Issue 2491043003: MediaResource refactoring to support multiple streams (Closed)
Patch Set: Added a TODO about DemuxerStream enabled/set_enabled methods Created 3 years, 10 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/ffmpeg_demuxer_unittest.cc ('k') | media/mojo/clients/mojo_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/clients/mojo_renderer.cc
diff --git a/media/mojo/clients/mojo_renderer.cc b/media/mojo/clients/mojo_renderer.cc
index a8b1fd35bbcbcf853ed1d0f26990c8e3bef149aa..568b9c78e315e8e7d5f21ff0742f21f49a8f04ec 100644
--- a/media/mojo/clients/mojo_renderer.cc
+++ b/media/mojo/clients/mojo_renderer.cc
@@ -71,38 +71,25 @@ void MojoRenderer::InitializeRendererFromStreams(
DVLOG(1) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
- // Create audio and video mojom::DemuxerStream and bind its lifetime to
- // the pipe.
- DemuxerStream* const audio = media_resource_->GetStream(DemuxerStream::AUDIO);
- DemuxerStream* const video = media_resource_->GetStream(DemuxerStream::VIDEO);
+ // Create mojom::DemuxerStream for each demuxer stream and bind its lifetime
+ // to the pipe.
+ std::vector<DemuxerStream*> streams = media_resource_->GetAllStreams();
+ std::vector<mojom::DemuxerStreamPtr> stream_proxies;
- std::vector<mojom::DemuxerStreamPtr> streams;
- if (audio) {
- mojom::DemuxerStreamPtr audio_stream;
+ for (const auto& stream : streams) {
+ mojom::DemuxerStreamPtr stream_proxy;
std::unique_ptr<MojoDemuxerStreamImpl> mojo_stream =
- base::MakeUnique<MojoDemuxerStreamImpl>(audio,
- MakeRequest(&audio_stream));
- // Using base::Unretained(this) is safe because |this| owns |mojo_stream|,
- // and the error handler can't be invoked once |mojo_stream| is destroyed.
- mojo_stream->set_connection_error_handler(
- base::Bind(&MojoRenderer::OnDemuxerStreamConnectionError,
- base::Unretained(this), mojo_stream.get()));
- streams_.push_back(std::move(mojo_stream));
- streams.push_back(std::move(audio_stream));
- }
+ base::MakeUnique<MojoDemuxerStreamImpl>(stream,
+ MakeRequest(&stream_proxy));
- if (video) {
- mojom::DemuxerStreamPtr video_stream;
- std::unique_ptr<MojoDemuxerStreamImpl> mojo_stream =
- base::MakeUnique<MojoDemuxerStreamImpl>(video,
- MakeRequest(&video_stream));
// Using base::Unretained(this) is safe because |this| owns |mojo_stream|,
// and the error handler can't be invoked once |mojo_stream| is destroyed.
mojo_stream->set_connection_error_handler(
base::Bind(&MojoRenderer::OnDemuxerStreamConnectionError,
base::Unretained(this), mojo_stream.get()));
+
streams_.push_back(std::move(mojo_stream));
- streams.push_back(std::move(video_stream));
+ stream_proxies.push_back(std::move(stream_proxy));
}
BindRemoteRendererIfNeeded();
@@ -114,7 +101,7 @@ void MojoRenderer::InitializeRendererFromStreams(
// |remote_renderer_|, and the callback won't be dispatched if
// |remote_renderer_| is destroyed.
remote_renderer_->Initialize(
- std::move(client_ptr_info), std::move(streams), base::nullopt,
+ std::move(client_ptr_info), std::move(stream_proxies), base::nullopt,
base::nullopt,
base::Bind(&MojoRenderer::OnInitialized, base::Unretained(this), client));
}
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/mojo/clients/mojo_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698