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

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

Issue 2491043003: MediaResource refactoring to support multiple streams (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 6d284985fe0aef738012d458e51d401e03ada41c..82679c43a4676c9c702af572b659f61f38407c68 100644
--- a/media/mojo/clients/mojo_renderer.cc
+++ b/media/mojo/clients/mojo_renderer.cc
@@ -10,7 +10,7 @@
#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
-#include "media/base/demuxer_stream_provider.h"
+#include "media/base/media_resource.h"
#include "media/base/pipeline_status.h"
#include "media/base/renderer_client.h"
#include "media/base/video_renderer_sink.h"
@@ -40,12 +40,12 @@ MojoRenderer::~MojoRenderer() {
CancelPendingCallbacks();
}
-void MojoRenderer::Initialize(DemuxerStreamProvider* demuxer_stream_provider,
+void MojoRenderer::Initialize(MediaResource* media_resource,
media::RendererClient* client,
const PipelineStatusCB& init_cb) {
DVLOG(1) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(demuxer_stream_provider);
+ DCHECK(media_resource);
if (encountered_error_) {
task_runner_->PostTask(
@@ -53,14 +53,14 @@ void MojoRenderer::Initialize(DemuxerStreamProvider* demuxer_stream_provider,
return;
}
- demuxer_stream_provider_ = demuxer_stream_provider;
+ media_resource_ = media_resource;
init_cb_ = init_cb;
- switch (demuxer_stream_provider_->GetType()) {
- case DemuxerStreamProvider::Type::STREAM:
+ switch (media_resource_->GetType()) {
+ case MediaResource::Type::STREAM:
InitializeRendererFromStreams(client);
break;
- case DemuxerStreamProvider::Type::URL:
+ case MediaResource::Type::URL:
InitializeRendererFromUrl(client);
break;
}
@@ -71,40 +71,24 @@ 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 =
- demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO);
- DemuxerStream* const video =
- demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO);
+ // Create mojom::DemuxerStream for each demuxer stream and bind its lifetime
+ // to the pipe.
+ std::vector<DemuxerStream*> streams = media_resource_->GetStreams();
+ std::vector<mojom::DemuxerStreamPtr> stream_proxies;
- std::vector<mojom::DemuxerStreamPtr> streams;
- if (audio) {
- mojom::DemuxerStreamPtr audio_stream;
+ for (const auto& s : 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>(s, 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()));
+
+ stream_proxies.push_back(std::move(stream_proxy));
streams_.push_back(std::move(mojo_stream));
- streams.push_back(std::move(video_stream));
}
BindRemoteRendererIfNeeded();
@@ -116,7 +100,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));
}
@@ -130,7 +114,7 @@ void MojoRenderer::InitializeRendererFromUrl(media::RendererClient* client) {
mojom::RendererClientAssociatedPtrInfo client_ptr_info;
client_binding_.Bind(&client_ptr_info, remote_renderer_.associated_group());
- MediaUrlParams url_params = demuxer_stream_provider_->GetMediaUrlParams();
+ MediaUrlParams url_params = media_resource_->GetMediaUrlParams();
// Using base::Unretained(this) is safe because |this| owns
// |remote_renderer_|, and the callback won't be dispatched if

Powered by Google App Engine
This is Rietveld 408576698