Commit cd69bc1a authored by Dan Sanders's avatar Dan Sanders Committed by Commit Bot

Add VideoDecoderProxy to RenderProcessHost registry.

This path is similar to MediaInterfaceProxy registered in
RenderFrameHost, except that VideoDecoderProxy only supports creating
video decoders. This will enable WebRTC's RTCVideoDecoderFactory to
create hardware video decoders using MojoVideoDecoder.

Bug: 857111
Change-Id: If960000688e636ade49d749bc99e9217f784e853
Reviewed-on: https://chromium-review.googlesource.com/1117214Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582779}
parent 09fe42b0
...@@ -1161,6 +1161,8 @@ jumbo_source_set("browser") { ...@@ -1161,6 +1161,8 @@ jumbo_source_set("browser") {
"media/session/media_session_uma_helper.h", "media/session/media_session_uma_helper.h",
"media/url_provision_fetcher.cc", "media/url_provision_fetcher.cc",
"media/url_provision_fetcher.h", "media/url_provision_fetcher.h",
"media/video_decoder_proxy.cc",
"media/video_decoder_proxy.h",
"memory/memory_condition_observer.cc", "memory/memory_condition_observer.cc",
"memory/memory_condition_observer.h", "memory/memory_condition_observer.h",
"memory/memory_coordinator_default_policy.cc", "memory/memory_coordinator_default_policy.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/video_decoder_proxy.h"
#include "base/logging.h"
#include "content/public/common/service_manager_connection.h"
#include "media/mojo/interfaces/constants.mojom.h"
#include "media/mojo/interfaces/media_service.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
namespace content {
VideoDecoderProxy::VideoDecoderProxy() {
DVLOG(1) << __func__;
}
VideoDecoderProxy::~VideoDecoderProxy() {
DVLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
void VideoDecoderProxy::Add(media::mojom::InterfaceFactoryRequest request) {
DVLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
bindings_.AddBinding(this, std::move(request));
}
void VideoDecoderProxy::CreateAudioDecoder(
media::mojom::AudioDecoderRequest request) {}
void VideoDecoderProxy::CreateVideoDecoder(
media::mojom::VideoDecoderRequest request) {
DVLOG(2) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
InterfaceFactory* factory = GetMediaInterfaceFactory();
if (factory)
factory->CreateVideoDecoder(std::move(request));
}
void VideoDecoderProxy::CreateRenderer(media::mojom::HostedRendererType type,
const std::string& type_specific_id,
media::mojom::RendererRequest request) {}
void VideoDecoderProxy::CreateCdm(
const std::string& key_system,
media::mojom::ContentDecryptionModuleRequest request) {}
void VideoDecoderProxy::CreateDecryptor(
int cdm_id,
media::mojom::DecryptorRequest request) {}
void VideoDecoderProxy::CreateCdmProxy(const std::string& cdm_guid,
media::mojom::CdmProxyRequest request) {}
media::mojom::InterfaceFactory* VideoDecoderProxy::GetMediaInterfaceFactory() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!interface_factory_ptr_)
ConnectToMediaService();
return interface_factory_ptr_.get();
}
void VideoDecoderProxy::ConnectToMediaService() {
DVLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!interface_factory_ptr_);
media::mojom::MediaServicePtr media_service;
// TODO(slan): Use the BrowserContext Connector instead.
// See https://crbug.com/638950.
service_manager::Connector* connector =
ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(media::mojom::kMediaServiceName, &media_service);
// TODO(sandersd): Do we need to bind an empty |interfaces| implementation?
service_manager::mojom::InterfaceProviderPtr interfaces;
media_service->CreateInterfaceFactory(MakeRequest(&interface_factory_ptr_),
std::move(interfaces));
interface_factory_ptr_.set_connection_error_handler(
base::BindOnce(&VideoDecoderProxy::OnMediaServiceConnectionError,
base::Unretained(this)));
}
void VideoDecoderProxy::OnMediaServiceConnectionError() {
DVLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
interface_factory_ptr_.reset();
}
} // namespace content
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_VIDEO_DECODER_PROXY_H_
#define CONTENT_BROWSER_MEDIA_VIDEO_DECODER_PROXY_H_
#include <string>
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "media/mojo/interfaces/interface_factory.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace content {
// This implements the media::mojom::InterfaceFactory interface for a
// RenderProcessHostImpl. Unlike MediaInterfaceProxy, only
// CreateVideoDecoder() is implemented. This allows WebRTC to create
// MojoVideoDecoder instances without a RenderFrame.
class VideoDecoderProxy : public media::mojom::InterfaceFactory {
public:
VideoDecoderProxy();
~VideoDecoderProxy() final;
void Add(media::mojom::InterfaceFactoryRequest request);
// media::mojom::InterfaceFactory implementation.
void CreateAudioDecoder(media::mojom::AudioDecoderRequest request) final;
void CreateVideoDecoder(media::mojom::VideoDecoderRequest request) final;
void CreateRenderer(media::mojom::HostedRendererType type,
const std::string& type_specific_id,
media::mojom::RendererRequest request) final;
void CreateCdm(const std::string& key_system,
media::mojom::ContentDecryptionModuleRequest request) final;
void CreateDecryptor(int cdm_id,
media::mojom::DecryptorRequest request) final;
void CreateCdmProxy(const std::string& cdm_guid,
media::mojom::CdmProxyRequest request) final;
private:
media::mojom::InterfaceFactory* GetMediaInterfaceFactory();
void ConnectToMediaService();
void OnMediaServiceConnectionError();
// Connection to the remote media InterfaceFactory.
media::mojom::InterfaceFactoryPtr interface_factory_ptr_;
// Connections to the renderer.
mojo::BindingSet<media::mojom::InterfaceFactory> bindings_;
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(VideoDecoderProxy);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_VIDEO_DECODER_PROXY_H_
...@@ -2085,6 +2085,9 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { ...@@ -2085,6 +2085,9 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
AddUIThreadInterface(registry.get(), AddUIThreadInterface(registry.get(),
base::BindRepeating(&GetNetworkChangeManager)); base::BindRepeating(&GetNetworkChangeManager));
registry->AddInterface(base::BindRepeating(
&RenderProcessHostImpl::BindVideoDecoderService, base::Unretained(this)));
// ---- Please do not register interfaces below this line ------ // ---- Please do not register interfaces below this line ------
// //
// This call should be done after registering all interfaces above, so that // This call should be done after registering all interfaces above, so that
...@@ -2167,6 +2170,13 @@ void RenderProcessHostImpl::CreateStoragePartitionService( ...@@ -2167,6 +2170,13 @@ void RenderProcessHostImpl::CreateStoragePartitionService(
storage_partition_impl_->Bind(id_, std::move(request)); storage_partition_impl_->Bind(id_, std::move(request));
} }
void RenderProcessHostImpl::BindVideoDecoderService(
media::mojom::InterfaceFactoryRequest request) {
if (!video_decoder_proxy_)
video_decoder_proxy_.reset(new VideoDecoderProxy());
video_decoder_proxy_->Add(std::move(request));
}
void RenderProcessHostImpl::CreateRendererHost( void RenderProcessHostImpl::CreateRendererHost(
mojom::RendererHostAssociatedRequest request) { mojom::RendererHostAssociatedRequest request) {
renderer_host_binding_.Bind(std::move(request)); renderer_host_binding_.Bind(std::move(request));
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "content/browser/cache_storage/cache_storage_dispatcher_host.h" #include "content/browser/cache_storage/cache_storage_dispatcher_host.h"
#include "content/browser/child_process_launcher.h" #include "content/browser/child_process_launcher.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h" #include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/browser/media/video_decoder_proxy.h"
#include "content/browser/renderer_host/embedded_frame_sink_provider_impl.h" #include "content/browser/renderer_host/embedded_frame_sink_provider_impl.h"
#include "content/browser/renderer_host/frame_sink_provider_impl.h" #include "content/browser/renderer_host/frame_sink_provider_impl.h"
#include "content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h" #include "content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h"
...@@ -495,6 +496,7 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -495,6 +496,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
void CreateStoragePartitionService( void CreateStoragePartitionService(
blink::mojom::StoragePartitionServiceRequest request); blink::mojom::StoragePartitionServiceRequest request);
void CreateRendererHost(mojom::RendererHostAssociatedRequest request); void CreateRendererHost(mojom::RendererHostAssociatedRequest request);
void BindVideoDecoderService(media::mojom::InterfaceFactoryRequest request);
// Control message handlers. // Control message handlers.
void OnUserMetricsRecordAction(const std::string& action); void OnUserMetricsRecordAction(const std::string& action);
...@@ -782,6 +784,8 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -782,6 +784,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
std::unique_ptr<MediaStreamTrackMetricsHost, BrowserThread::DeleteOnIOThread> std::unique_ptr<MediaStreamTrackMetricsHost, BrowserThread::DeleteOnIOThread>
media_stream_track_metrics_host_; media_stream_track_metrics_host_;
std::unique_ptr<VideoDecoderProxy> video_decoder_proxy_;
// Forwards messages between WebRTCInternals in the browser process // Forwards messages between WebRTCInternals in the browser process
// and PeerConnectionTracker in the renderer process. // and PeerConnectionTracker in the renderer process.
// It holds a raw pointer to webrtc_eventlog_host_, and therefore should be // It holds a raw pointer to webrtc_eventlog_host_, and therefore should be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment