Commit ddcd9180 authored by Yuchen Liu's avatar Yuchen Liu Committed by Commit Bot

Reland "[Fuchsia][EME] Basic skeleton for EME support on Fuchsia"

This is a reland of 510e0f76

Original change's description:
> [Fuchsia][EME] Basic skeleton for EME support on Fuchsia
> 
> In renderer process, FuchsiaCdmFactory initiates the request to Fuchsia
> CDM service. The request is passed to browser process via new mojo
> FuchsiaCdmProvider. FuchsiaCdm implements
> media::ContentDecryptionModule by calling Fuchsia CDM APIs directly from
> renderer process.
> 
> In browser process, FuchsiaCdmManager will complete the provision flow
> (if needed) and setup the channel between Chromium and the remote CDM
> service.
> 
> Bug: 966191
> Test: Shaka Player WV audio only test (with other CLs).
> Change-Id: I401e581214d945a2acbefa926f73fdb2ca84d780
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715908
> Reviewed-by: Wez <wez@chromium.org>
> Reviewed-by: John Rummell <jrummell@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
> Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
> Commit-Queue: Yuchen Liu <yucliu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#684087}

Bug: 966191
Change-Id: I186e8a041922a6694e224906e3732f12a76b6409
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737566Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684242}
parent 8fd9a5d1
...@@ -261,6 +261,7 @@ const service_manager::Manifest& GetContentBrowserManifest() { ...@@ -261,6 +261,7 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"device.mojom.VibrationManager", "device.mojom.VibrationManager",
"device.mojom.VRService", "device.mojom.VRService",
"discardable_memory.mojom.DiscardableSharedMemoryManager", "discardable_memory.mojom.DiscardableSharedMemoryManager",
"media.mojom.FuchsiaCdmProvider",
"media.mojom.ImageCapture", "media.mojom.ImageCapture",
"media.mojom.InterfaceFactory", "media.mojom.InterfaceFactory",
"media.mojom.MediaMetricsProvider", "media.mojom.MediaMetricsProvider",
......
...@@ -620,6 +620,8 @@ target(link_target_type, "renderer") { ...@@ -620,6 +620,8 @@ target(link_target_type, "renderer") {
"render_view_fuchsia.cc", "render_view_fuchsia.cc",
"renderer_main_platform_delegate_fuchsia.cc", "renderer_main_platform_delegate_fuchsia.cc",
] ]
deps += [ "//media/fuchsia/cdm" ]
} }
if (enable_media_remoting) { if (enable_media_remoting) {
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#endif #endif
#if defined(OS_FUCHSIA) #if defined(OS_FUCHSIA)
#include "media/cdm/fuchsia/fuchsia_cdm_factory.h" #include "media/fuchsia/cdm/fuchsia_cdm_factory.h"
#elif BUILDFLAG(ENABLE_MOJO_CDM) #elif BUILDFLAG(ENABLE_MOJO_CDM)
#include "media/mojo/clients/mojo_cdm_factory.h" // nogncheck #include "media/mojo/clients/mojo_cdm_factory.h" // nogncheck
#else #else
...@@ -610,7 +610,7 @@ media::CdmFactory* MediaFactory::GetCdmFactory() { ...@@ -610,7 +610,7 @@ media::CdmFactory* MediaFactory::GetCdmFactory() {
return cdm_factory_.get(); return cdm_factory_.get();
#if defined(OS_FUCHSIA) #if defined(OS_FUCHSIA)
cdm_factory_ = std::make_unique<media::FuchsiaCdmFactory>(); cdm_factory_ = std::make_unique<media::FuchsiaCdmFactory>(remote_interfaces_);
#elif BUILDFLAG(ENABLE_MOJO_CDM) #elif BUILDFLAG(ENABLE_MOJO_CDM)
cdm_factory_ = cdm_factory_ =
std::make_unique<media::MojoCdmFactory>(GetMediaInterfaceFactory()); std::make_unique<media::MojoCdmFactory>(GetMediaInterfaceFactory());
......
...@@ -80,6 +80,8 @@ component("web_engine_core") { ...@@ -80,6 +80,8 @@ component("web_engine_core") {
"//fuchsia/base", "//fuchsia/base",
"//fuchsia/base:message_port", "//fuchsia/base:message_port",
"//fuchsia/base:modular", "//fuchsia/base:modular",
"//media/fuchsia/cdm/service",
"//media/fuchsia/mojom",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
"//services/network/public/cpp", "//services/network/public/cpp",
"//services/service_manager/sandbox", "//services/service_manager/sandbox",
...@@ -119,6 +121,8 @@ component("web_engine_core") { ...@@ -119,6 +121,8 @@ component("web_engine_core") {
"browser/web_engine_browser_main.h", "browser/web_engine_browser_main.h",
"browser/web_engine_browser_main_parts.cc", "browser/web_engine_browser_main_parts.cc",
"browser/web_engine_browser_main_parts.h", "browser/web_engine_browser_main_parts.h",
"browser/web_engine_cdm_service.cc",
"browser/web_engine_cdm_service.h",
"browser/web_engine_content_browser_client.cc", "browser/web_engine_content_browser_client.cc",
"browser/web_engine_content_browser_client.h", "browser/web_engine_content_browser_client.h",
"browser/web_engine_devtools_manager_delegate.cc", "browser/web_engine_devtools_manager_delegate.cc",
......
...@@ -4,6 +4,9 @@ include_rules = [ ...@@ -4,6 +4,9 @@ include_rules = [
"+content/public/common", "+content/public/common",
"+content/public/browser", "+content/public/browser",
"+content/public/test", "+content/public/test",
"+media/base",
"+media/fuchsia/cdm/service",
"+media/fuchsia/mojom",
"+mojo/public/cpp/bindings", "+mojo/public/cpp/bindings",
"+mojo/public/cpp/system", "+mojo/public/cpp/system",
"+third_party/blink/public/common/associated_interfaces", "+third_party/blink/public/common/associated_interfaces",
......
// Copyright 2019 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 "fuchsia/engine/browser/web_engine_cdm_service.h"
#include <fuchsia/media/drm/cpp/fidl.h>
#include <string>
#include "base/bind.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/provision_fetcher_factory.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "media/base/provision_fetcher.h"
#include "media/fuchsia/mojom/fuchsia_cdm_provider.mojom.h"
namespace {
class FuchsiaCdmProviderImpl
: public content::FrameServiceBase<media::mojom::FuchsiaCdmProvider> {
public:
FuchsiaCdmProviderImpl(media::FuchsiaCdmManager* cdm_manager,
media::CreateFetcherCB create_fetcher_cb,
content::RenderFrameHost* render_frame_host,
media::mojom::FuchsiaCdmProviderRequest request);
~FuchsiaCdmProviderImpl() final;
// media::mojom::FuchsiaCdmProvider implementation.
void CreateCdmInterface(
const std::string& key_system,
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request) final;
private:
media::FuchsiaCdmManager* const cdm_manager_;
const media::CreateFetcherCB create_fetcher_cb_;
DISALLOW_COPY_AND_ASSIGN(FuchsiaCdmProviderImpl);
};
FuchsiaCdmProviderImpl::FuchsiaCdmProviderImpl(
media::FuchsiaCdmManager* cdm_manager,
media::CreateFetcherCB create_fetcher_cb,
content::RenderFrameHost* render_frame_host,
media::mojom::FuchsiaCdmProviderRequest request)
: FrameServiceBase(render_frame_host, std::move(request)),
cdm_manager_(cdm_manager),
create_fetcher_cb_(std::move(create_fetcher_cb)) {
DCHECK(cdm_manager_);
}
FuchsiaCdmProviderImpl::~FuchsiaCdmProviderImpl() = default;
void FuchsiaCdmProviderImpl::CreateCdmInterface(
const std::string& key_system,
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request) {
cdm_manager_->CreateAndProvision(key_system, origin(), create_fetcher_cb_,
std::move(request));
}
void BindFuchsiaCdmProvider(media::FuchsiaCdmManager* cdm_manager,
media::mojom::FuchsiaCdmProviderRequest request,
content::RenderFrameHost* const frame_host) {
scoped_refptr<network::SharedURLLoaderFactory> loader_factory =
content::BrowserContext::GetDefaultStoragePartition(
frame_host->GetProcess()->GetBrowserContext())
->GetURLLoaderFactoryForBrowserProcess();
// The object will delete itself when connection to the frame is broken.
new FuchsiaCdmProviderImpl(
cdm_manager,
base::BindRepeating(&content::CreateProvisionFetcher,
std::move(loader_factory)),
frame_host, std::move(request));
}
} // namespace
WebEngineCdmService::WebEngineCdmService(
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>*
registry)
: registry_(registry) {
DCHECK(registry_);
registry_->AddInterface(
base::BindRepeating(&BindFuchsiaCdmProvider, &cdm_manager_));
}
WebEngineCdmService::~WebEngineCdmService() {
registry_->RemoveInterface<media::mojom::FuchsiaCdmProvider>();
}
// Copyright 2019 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 FUCHSIA_ENGINE_BROWSER_WEB_ENGINE_CDM_SERVICE_H_
#define FUCHSIA_ENGINE_BROWSER_WEB_ENGINE_CDM_SERVICE_H_
#include "media/fuchsia/cdm/service/fuchsia_cdm_manager.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace content {
class RenderFrameHost;
}
class WebEngineCdmService {
public:
explicit WebEngineCdmService(
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>*
registry);
~WebEngineCdmService();
private:
media::FuchsiaCdmManager cdm_manager_;
// Not owned pointer. |registry_| must outlive |this|.
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>* const
registry_;
DISALLOW_COPY_AND_ASSIGN(WebEngineCdmService);
};
#endif // FUCHSIA_ENGINE_BROWSER_WEB_ENGINE_CDM_SERVICE_H_
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
WebEngineContentBrowserClient::WebEngineContentBrowserClient( WebEngineContentBrowserClient::WebEngineContentBrowserClient(
fidl::InterfaceRequest<fuchsia::web::Context> request) fidl::InterfaceRequest<fuchsia::web::Context> request)
: request_(std::move(request)) {} : request_(std::move(request)), cdm_service_(&mojo_service_registry_) {}
WebEngineContentBrowserClient::~WebEngineContentBrowserClient() = default; WebEngineContentBrowserClient::~WebEngineContentBrowserClient() = default;
...@@ -60,3 +60,11 @@ void WebEngineContentBrowserClient::OverrideWebkitPrefs( ...@@ -60,3 +60,11 @@ void WebEngineContentBrowserClient::OverrideWebkitPrefs(
// Disable WebSQL support since it's being removed from the web platform. // Disable WebSQL support since it's being removed from the web platform.
web_prefs->databases_enabled = false; web_prefs->databases_enabled = false;
} }
void WebEngineContentBrowserClient::BindInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
mojo_service_registry_.BindInterface(
interface_name, std::move(interface_pipe), render_frame_host);
}
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "fuchsia/engine/browser/web_engine_cdm_service.h"
#include "services/service_manager/public/cpp/binder_registry.h"
class WebEngineBrowserMainParts; class WebEngineBrowserMainParts;
...@@ -31,6 +33,10 @@ class WebEngineContentBrowserClient : public content::ContentBrowserClient { ...@@ -31,6 +33,10 @@ class WebEngineContentBrowserClient : public content::ContentBrowserClient {
std::string GetUserAgent() override; std::string GetUserAgent() override;
void OverrideWebkitPrefs(content::RenderViewHost* rvh, void OverrideWebkitPrefs(content::RenderViewHost* rvh,
content::WebPreferences* web_prefs) override; content::WebPreferences* web_prefs) override;
void BindInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override;
private: private:
fidl::InterfaceRequest<fuchsia::web::Context> request_; fidl::InterfaceRequest<fuchsia::web::Context> request_;
...@@ -38,6 +44,10 @@ class WebEngineContentBrowserClient : public content::ContentBrowserClient { ...@@ -38,6 +44,10 @@ class WebEngineContentBrowserClient : public content::ContentBrowserClient {
// Owned by content::BrowserMainLoop. // Owned by content::BrowserMainLoop.
WebEngineBrowserMainParts* main_parts_; WebEngineBrowserMainParts* main_parts_;
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>
mojo_service_registry_;
WebEngineCdmService cdm_service_;
DISALLOW_COPY_AND_ASSIGN(WebEngineContentBrowserClient); DISALLOW_COPY_AND_ASSIGN(WebEngineContentBrowserClient);
}; };
......
...@@ -104,13 +104,6 @@ source_set("cdm") { ...@@ -104,13 +104,6 @@ source_set("cdm") {
] ]
} }
} }
if (is_fuchsia) {
sources += [
"fuchsia/fuchsia_cdm_factory.cc",
"fuchsia/fuchsia_cdm_factory.h",
]
}
} }
static_library("cdm_paths") { static_library("cdm_paths") {
......
sergeyu@chromium.org
yucliu@chromium.org
wez@chromium.org
# Copyright 2019 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.
assert(is_fuchsia)
source_set("cdm") {
sources = [
"fuchsia_cdm.cc",
"fuchsia_cdm.h",
"fuchsia_cdm_factory.cc",
"fuchsia_cdm_factory.h",
]
deps = [
"//media",
"//media/fuchsia/mojom",
"//services/service_manager/public/cpp",
"//third_party/fuchsia-sdk/sdk:media_drm",
]
}
include_rules = [
"+services/service_manager/public",
]
// Copyright 2019 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 "media/fuchsia/cdm/fuchsia_cdm.h"
#include "base/logging.h"
#include "media/base/callback_registry.h"
#include "media/base/cdm_promise.h"
namespace media {
FuchsiaCdm::SessionCallbacks::SessionCallbacks() = default;
FuchsiaCdm::SessionCallbacks::SessionCallbacks(SessionCallbacks&&) = default;
FuchsiaCdm::SessionCallbacks::~SessionCallbacks() = default;
FuchsiaCdm::SessionCallbacks& FuchsiaCdm::SessionCallbacks::operator=(
SessionCallbacks&&) = default;
FuchsiaCdm::FuchsiaCdm(fuchsia::media::drm::ContentDecryptionModulePtr cdm,
SessionCallbacks callbacks)
: cdm_(std::move(cdm)), session_callbacks_(std::move(callbacks)) {
DCHECK(cdm_);
}
FuchsiaCdm::~FuchsiaCdm() = default;
void FuchsiaCdm::SetServerCertificate(
const std::vector<uint8_t>& certificate,
std::unique_ptr<SimpleCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
void FuchsiaCdm::CreateSessionAndGenerateRequest(
CdmSessionType session_type,
EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data,
std::unique_ptr<NewSessionCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
void FuchsiaCdm::LoadSession(CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<NewSessionCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
void FuchsiaCdm::UpdateSession(const std::string& session_id,
const std::vector<uint8_t>& response,
std::unique_ptr<SimpleCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
void FuchsiaCdm::CloseSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
void FuchsiaCdm::RemoveSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) {
NOTIMPLEMENTED();
promise->reject(CdmPromise::Exception::NOT_SUPPORTED_ERROR, 0,
"not implemented");
}
CdmContext* FuchsiaCdm::GetCdmContext() {
return this;
}
std::unique_ptr<CallbackRegistration> FuchsiaCdm::RegisterEventCB(
EventCB event_cb) {
NOTIMPLEMENTED();
return nullptr;
}
Decryptor* FuchsiaCdm::GetDecryptor() {
NOTIMPLEMENTED();
return nullptr;
}
int FuchsiaCdm::GetCdmId() const {
return kInvalidCdmId;
}
} // namespace media
// Copyright 2019 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 MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_H_
#define MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_H_
#include <fuchsia/media/drm/cpp/fidl.h>
#include "base/macros.h"
#include "media/base/cdm_context.h"
#include "media/base/content_decryption_module.h"
namespace media {
class FuchsiaCdm : public ContentDecryptionModule, public CdmContext {
public:
struct SessionCallbacks {
SessionCallbacks();
SessionCallbacks(SessionCallbacks&&);
~SessionCallbacks();
SessionCallbacks& operator=(SessionCallbacks&&);
SessionMessageCB message_cb;
SessionClosedCB closed_cb;
SessionKeysChangeCB keys_change_cb;
SessionExpirationUpdateCB expiration_update_cb;
DISALLOW_COPY_AND_ASSIGN(SessionCallbacks);
};
FuchsiaCdm(fuchsia::media::drm::ContentDecryptionModulePtr cdm,
SessionCallbacks callbacks);
// ContentDecryptionModule implementation:
void SetServerCertificate(const std::vector<uint8_t>& certificate,
std::unique_ptr<SimpleCdmPromise> promise) override;
void CreateSessionAndGenerateRequest(
CdmSessionType session_type,
EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data,
std::unique_ptr<NewSessionCdmPromise> promise) override;
void LoadSession(CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<NewSessionCdmPromise> promise) override;
void UpdateSession(const std::string& session_id,
const std::vector<uint8_t>& response,
std::unique_ptr<SimpleCdmPromise> promise) override;
void CloseSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) override;
void RemoveSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) override;
CdmContext* GetCdmContext() override;
// CdmContext implementation:
std::unique_ptr<CallbackRegistration> RegisterEventCB(
EventCB event_cb) override;
Decryptor* GetDecryptor() override;
int GetCdmId() const override;
private:
~FuchsiaCdm() override;
fuchsia::media::drm::ContentDecryptionModulePtr cdm_;
SessionCallbacks session_callbacks_;
DISALLOW_COPY_AND_ASSIGN(FuchsiaCdm);
};
} // namespace media
#endif // MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_H_
...@@ -2,16 +2,26 @@ ...@@ -2,16 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "media/cdm/fuchsia/fuchsia_cdm_factory.h" #include "media/fuchsia/cdm/fuchsia_cdm_factory.h"
#include <fuchsia/media/drm/cpp/fidl.h>
#include "base/bind.h"
#include "media/base/bind_to_current_loop.h" #include "media/base/bind_to_current_loop.h"
#include "media/base/cdm_config.h"
#include "media/base/key_systems.h" #include "media/base/key_systems.h"
#include "media/cdm/aes_decryptor.h" #include "media/cdm/aes_decryptor.h"
#include "media/fuchsia/cdm/fuchsia_cdm.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "url/origin.h" #include "url/origin.h"
namespace media { namespace media {
FuchsiaCdmFactory::FuchsiaCdmFactory() = default; FuchsiaCdmFactory::FuchsiaCdmFactory(
service_manager::InterfaceProvider* interface_provider)
: interface_provider_(interface_provider) {
DCHECK(interface_provider_);
}
FuchsiaCdmFactory::~FuchsiaCdmFactory() = default; FuchsiaCdmFactory::~FuchsiaCdmFactory() = default;
...@@ -35,12 +45,26 @@ void FuchsiaCdmFactory::Create( ...@@ -35,12 +45,26 @@ void FuchsiaCdmFactory::Create(
auto cdm = base::MakeRefCounted<AesDecryptor>( auto cdm = base::MakeRefCounted<AesDecryptor>(
session_message_cb, session_closed_cb, session_keys_change_cb, session_message_cb, session_closed_cb, session_keys_change_cb,
session_expiration_update_cb); session_expiration_update_cb);
std::move(bound_cdm_created_cb).Run(cdm, std::string()); std::move(bound_cdm_created_cb).Run(std::move(cdm), "");
return; return;
} }
// TODO(yucliu): Create CDM with platform support. if (!cdm_provider_)
std::move(bound_cdm_created_cb).Run(nullptr, "Unsupported key system."); interface_provider_->GetInterface(mojo::MakeRequest(&cdm_provider_));
fuchsia::media::drm::ContentDecryptionModulePtr cdm_ptr;
cdm_provider_->CreateCdmInterface(key_system, cdm_ptr.NewRequest());
FuchsiaCdm::SessionCallbacks callbacks;
callbacks.message_cb = session_message_cb;
callbacks.closed_cb = session_closed_cb;
callbacks.keys_change_cb = session_keys_change_cb;
callbacks.expiration_update_cb = session_expiration_update_cb;
auto cdm = base::MakeRefCounted<FuchsiaCdm>(std::move(cdm_ptr),
std::move(callbacks));
std::move(bound_cdm_created_cb).Run(std::move(cdm), "");
} }
} // namespace media } // namespace media
...@@ -2,18 +2,25 @@ ...@@ -2,18 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef MEDIA_CDM_FUCHSIA_FUCHSIA_CDM_FACTORY_H_ #ifndef MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_FACTORY_H_
#define MEDIA_CDM_FUCHSIA_FUCHSIA_CDM_FACTORY_H_ #define MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_FACTORY_H_
#include "base/macros.h" #include "base/macros.h"
#include "media/base/cdm_factory.h" #include "media/base/cdm_factory.h"
#include "media/base/media_export.h" #include "media/base/media_export.h"
#include "media/fuchsia/mojom/fuchsia_cdm_provider.mojom.h"
namespace service_manager {
class InterfaceProvider;
}
namespace media { namespace media {
class MEDIA_EXPORT FuchsiaCdmFactory : public CdmFactory { class MEDIA_EXPORT FuchsiaCdmFactory : public CdmFactory {
public: public:
FuchsiaCdmFactory(); // |interface_provider| must outlive this class.
explicit FuchsiaCdmFactory(
service_manager::InterfaceProvider* interface_provider);
~FuchsiaCdmFactory() final; ~FuchsiaCdmFactory() final;
// CdmFactory implementation. // CdmFactory implementation.
...@@ -27,9 +34,12 @@ class MEDIA_EXPORT FuchsiaCdmFactory : public CdmFactory { ...@@ -27,9 +34,12 @@ class MEDIA_EXPORT FuchsiaCdmFactory : public CdmFactory {
const CdmCreatedCB& cdm_created_cb) final; const CdmCreatedCB& cdm_created_cb) final;
private: private:
service_manager::InterfaceProvider* const interface_provider_;
media::mojom::FuchsiaCdmProviderPtr cdm_provider_;
DISALLOW_COPY_AND_ASSIGN(FuchsiaCdmFactory); DISALLOW_COPY_AND_ASSIGN(FuchsiaCdmFactory);
}; };
} // namespace media } // namespace media
#endif // MEDIA_CDM_FUCHSIA_FUCHSIA_CDM_FACTORY_H_ #endif // MEDIA_FUCHSIA_CDM_FUCHSIA_CDM_FACTORY_H_
# Copyright 2019 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.
assert(is_fuchsia)
source_set("service") {
sources = [
"fuchsia_cdm_manager.cc",
"fuchsia_cdm_manager.h",
]
deps = [
"//media",
"//media/fuchsia/mojom",
"//third_party/fuchsia-sdk/sdk:media_drm",
"//url",
]
}
// Copyright 2019 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 "media/fuchsia/cdm/service/fuchsia_cdm_manager.h"
#include "base/logging.h"
#include "url/origin.h"
namespace media {
FuchsiaCdmManager::FuchsiaCdmManager() = default;
FuchsiaCdmManager::~FuchsiaCdmManager() = default;
void FuchsiaCdmManager::CreateAndProvision(
const std::string& key_system,
const url::Origin& origin,
CreateFetcherCB create_fetcher_cb,
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request) {
NOTIMPLEMENTED();
}
} // namespace media
// Copyright 2019 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 MEDIA_FUCHSIA_CDM_SERVICE_FUCHSIA_CDM_MANAGER_H_
#define MEDIA_FUCHSIA_CDM_SERVICE_FUCHSIA_CDM_MANAGER_H_
#include <fuchsia/media/drm/cpp/fidl.h>
#include <string>
#include "media/base/provision_fetcher.h"
namespace url {
class Origin;
} // namespace url
namespace media {
// Create and connect to Fuchsia CDM service. It will provision the origin if
// needed. It will chain all the concurrent provision requests and make sure we
// only send one provision request to server.
class FuchsiaCdmManager {
public:
FuchsiaCdmManager();
~FuchsiaCdmManager();
void CreateAndProvision(
const std::string& key_system,
const url::Origin& origin,
CreateFetcherCB create_fetcher_cb,
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request);
};
} // namespace media
#endif // MEDIA_FUCHSIA_CDM_SERVICE_FUCHSIA_CDM_MANAGER_H_
# Copyright 2019 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.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [
"fuchsia_cdm_provider.mojom",
]
}
include_rules = [
"+fuchsia/mojom",
]
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
per-file *.typemap=file://ipc/SECURITY_OWNERS
# Copyright 2019 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.
mojom = "//media/fuchsia/mojom/fuchsia_cdm_provider.mojom"
os_whitelist = [ "fuchsia" ]
public_headers = [ "fuchsia/media/drm/cpp/fidl.h" ]
traits_headers = [ "//media/fuchsia/mojom/cdm_request_mojom_traits.h" ]
sources = [
"//media/fuchsia/mojom/cdm_request_mojom_traits.h",
]
public_deps = [
"//fuchsia/mojom:traits",
"//third_party/fuchsia-sdk/sdk:media_drm",
]
type_mappings = [ "media.mojom.CdmRequest=fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>[move_only]" ]
// Copyright 2019 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 MEDIA_FUCHSIA_MOJOM_CDM_REQUEST_MOJOM_TRAITS_H_
#define MEDIA_FUCHSIA_MOJOM_CDM_REQUEST_MOJOM_TRAITS_H_
#include <fuchsia/media/drm/cpp/fidl.h>
#include "fuchsia/mojom/fidl_interface_request_mojom_traits.h"
namespace mojo {
template <>
struct StructTraits<
media::mojom::CdmRequestDataView,
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>>
: public FidlInterfaceRequestStructTraits<
media::mojom::CdmRequestDataView,
fuchsia::media::drm::ContentDecryptionModule> {};
} // namespace mojo
#endif // MEDIA_FUCHSIA_MOJOM_CDM_REQUEST_MOJOM_TRAITS_H_
// Copyright 2019 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.
module media.mojom;
// Mojo struct for
// fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>.
struct CdmRequest {
handle request;
};
// Interface for asking privileged process to create connection to
// fuchsia CDM service.
interface FuchsiaCdmProvider {
// Create connection to fuchsia::media::drm::ContentDecryptionModule for
// |key_system|.
// Implementation should make sure the persistent storage are isolated
// for different web origins.
CreateCdmInterface(string key_system, CdmRequest cdm_request);
};
# Copyright 2019 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.
typemaps = [ "//media/fuchsia/mojom/cdm_request.typemap" ]
...@@ -26,6 +26,7 @@ _typemap_imports = [ ...@@ -26,6 +26,7 @@ _typemap_imports = [
"//gpu/ipc/common/typemaps.gni", "//gpu/ipc/common/typemaps.gni",
"//ipc/typemaps.gni", "//ipc/typemaps.gni",
"//media/capture/mojom/typemaps.gni", "//media/capture/mojom/typemaps.gni",
"//media/fuchsia/mojom/typemaps.gni",
"//media/learning/mojo/public/cpp/typemaps.gni", "//media/learning/mojo/public/cpp/typemaps.gni",
"//media/mojo/mojom/typemaps.gni", "//media/mojo/mojom/typemaps.gni",
"//mojo/public/cpp/base/typemaps.gni", "//mojo/public/cpp/base/typemaps.gni",
......
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