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

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

Issue 2383663002: Make mojo renderer capable of supporting multiple streams/tracks (Closed)
Patch Set: rebase Created 3 years, 11 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
Index: media/mojo/clients/mojo_renderer.cc
diff --git a/media/mojo/clients/mojo_renderer.cc b/media/mojo/clients/mojo_renderer.cc
index 119de6240f6467c83f12bf0784d31676373b120d..e8e779442073adab0a0229ea93d3fed7a7981db7 100644
--- a/media/mojo/clients/mojo_renderer.cc
+++ b/media/mojo/clients/mojo_renderer.cc
@@ -78,28 +78,31 @@ void MojoRenderer::InitializeRendererFromStreams(
DemuxerStream* const video =
demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO);
- mojom::DemuxerStreamPtr audio_stream;
+ std::vector<mojom::DemuxerStreamPtr> streams;
if (audio) {
- audio_stream_.reset(
+ mojom::DemuxerStreamPtr audio_stream;
+ streams_.emplace_back(
new MojoDemuxerStreamImpl(audio, MakeRequest(&audio_stream)));
- // Using base::Unretained(this) is safe because |this| owns
- // |audio_stream_|, and the error handler can't be invoked once
- // |audio_stream_| is destroyed.
- audio_stream_->set_connection_error_handler(
+ MojoDemuxerStreamImpl* mojo_stream = streams_.back().get();
+ // 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), DemuxerStream::AUDIO));
+ base::Unretained(this), mojo_stream));
xhwang 2017/01/31 00:15:21 For future discussion: I am not a fan of using poi
xhwang 2017/01/31 00:15:21 nit: It's a bit weird that we emplace_back the str
servolk 2017/01/31 01:10:40 Done. Although it's a tiny bit more inefficient, s
servolk 2017/01/31 01:10:40 I understand your concern in general, but TBH in t
+ streams.push_back(std::move(audio_stream));
}
- mojom::DemuxerStreamPtr video_stream;
if (video) {
- video_stream_.reset(
+ mojom::DemuxerStreamPtr video_stream;
+ streams_.emplace_back(
new MojoDemuxerStreamImpl(video, MakeRequest(&video_stream)));
- // Using base::Unretained(this) is safe because |this| owns
- // |video_stream_|, and the error handler can't be invoked once
- // |video_stream_| is destroyed.
- video_stream_->set_connection_error_handler(
+ MojoDemuxerStreamImpl* mojo_stream = streams_.back().get();
+ // 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), DemuxerStream::VIDEO));
+ base::Unretained(this), mojo_stream));
+ streams.push_back(std::move(video_stream));
}
BindRemoteRendererIfNeeded();
@@ -111,8 +114,8 @@ 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(audio_stream),
- std::move(video_stream), base::nullopt, base::nullopt,
+ std::move(client_ptr_info), std::move(streams), base::nullopt,
+ base::nullopt,
base::Bind(&MojoRenderer::OnInitialized, base::Unretained(this), client));
}
@@ -130,9 +133,9 @@ void MojoRenderer::InitializeRendererFromUrl(media::RendererClient* client) {
// Using base::Unretained(this) is safe because |this| owns
// |remote_renderer_|, and the callback won't be dispatched if
// |remote_renderer_| is destroyed.
+ std::vector<mojom::DemuxerStreamPtr> streams;
remote_renderer_->Initialize(
- std::move(client_ptr_info), mojom::DemuxerStreamPtr(),
- mojom::DemuxerStreamPtr(), url_params.media_url,
+ std::move(client_ptr_info), std::move(streams), url_params.media_url,
url_params.first_party_for_cookies,
base::Bind(&MojoRenderer::OnInitialized, base::Unretained(this), client));
}
@@ -315,17 +318,18 @@ void MojoRenderer::OnConnectionError() {
client_->OnError(PIPELINE_ERROR_DECODE);
}
-void MojoRenderer::OnDemuxerStreamConnectionError(DemuxerStream::Type type) {
- DVLOG(1) << __func__ << ": " << type;
+void MojoRenderer::OnDemuxerStreamConnectionError(
+ MojoDemuxerStreamImpl* stream) {
+ DVLOG(1) << __func__ << ": stream=" << stream;
DCHECK(task_runner_->BelongsToCurrentThread());
- if (type == DemuxerStream::AUDIO) {
- audio_stream_.reset();
- } else if (type == DemuxerStream::VIDEO) {
- video_stream_.reset();
- } else {
- NOTREACHED() << "Unexpected demuxer stream type: " << type;
+ for (auto& s : streams_) {
+ if (s.get() == stream) {
xhwang 2017/01/31 00:15:21 ditto about using pointer as ID for comparison...
servolk 2017/01/31 01:10:40 TBH I think that using an ID instead of pointer wo
xhwang 2017/01/31 07:49:07 If we use ID, |streams_| will probably be a map in
servolk 2017/01/31 17:38:04 Yes, I understand that we could trivially map the
+ s.reset();
+ return;
+ }
}
+ NOTREACHED() << "Unrecognized demuxer stream=" << stream;
}
void MojoRenderer::BindRemoteRendererIfNeeded() {

Powered by Google App Engine
This is Rietveld 408576698