Skip to content

Commit

Permalink
[Fuchsia][EME] Origin provision
Browse files Browse the repository at this point in the history
Origin provision is handled by FuchsiaCdmManager. It makes sure we only
send one provision request to provisioning server for the required
origin. All the other requests will be cached to wait for the current
provision to be finished.

Bug: 966191
Test: Shaka Player WV audio only test (with other CLs).
Change-Id: I95aa9e15783c3efb4842a0b1a7e808b24b023a0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737069
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685018}
  • Loading branch information
Yuchen Liu authored and Commit Bot committed Aug 7, 2019
1 parent e7bae99 commit 52b96fc
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 10 deletions.
1 change: 1 addition & 0 deletions fuchsia/engine/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ component("web_engine_core") {
"//skia/public/mojom",
"//third_party/blink/public/common",
"//third_party/fuchsia-sdk/sdk:web",
"//third_party/widevine/cdm:headers",
"//ui/aura",
"//ui/base/ime",
"//ui/display",
Expand Down
1 change: 1 addition & 0 deletions fuchsia/engine/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include_rules = [
"+third_party/blink/public/common/logging",
"+third_party/blink/public/common/messaging",
"+third_party/blink/public/mojom/messaging",
"+third_party/widevine/cdm",
"+ui/aura",
"+ui/base/ime",
"+ui/display",
Expand Down
40 changes: 38 additions & 2 deletions fuchsia/engine/browser/web_engine_cdm_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
#include <string>

#include "base/bind.h"
#include "base/fuchsia/service_directory_client.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/cdm/service/fuchsia_cdm_manager.h"
#include "media/fuchsia/mojom/fuchsia_cdm_provider.mojom.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"

namespace {
class FuchsiaCdmProviderImpl
Expand Down Expand Up @@ -76,15 +79,48 @@ void BindFuchsiaCdmProvider(media::FuchsiaCdmManager* cdm_manager,
std::move(loader_factory)),
frame_host, std::move(request));
}

class WidevineHandler : public media::FuchsiaCdmManager::KeySystemHandler {
public:
WidevineHandler() = default;
~WidevineHandler() override = default;

void CreateCdm(
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request) override {
auto widevine = base::fuchsia::ServiceDirectoryClient::ForCurrentProcess()
->ConnectToService<fuchsia::media::drm::Widevine>();
widevine->CreateContentDecryptionModule(std::move(request));
}

fuchsia::media::drm::ProvisionerPtr CreateProvisioner() override {
fuchsia::media::drm::ProvisionerPtr provisioner;

auto widevine = base::fuchsia::ServiceDirectoryClient::ForCurrentProcess()
->ConnectToService<fuchsia::media::drm::Widevine>();
widevine->CreateProvisioner(provisioner.NewRequest());

return provisioner;
}
};

// Supported key systems:
std::unique_ptr<media::FuchsiaCdmManager> CreateCdmManager() {
media::FuchsiaCdmManager::KeySystemHandlerMap handlers;
handlers.emplace(kWidevineKeySystem, std::make_unique<WidevineHandler>());

return std::make_unique<media::FuchsiaCdmManager>(std::move(handlers));
}
} // namespace

WebEngineCdmService::WebEngineCdmService(
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>*
registry)
: registry_(registry) {
: cdm_manager_(CreateCdmManager()), registry_(registry) {
DCHECK(cdm_manager_);
DCHECK(registry_);
registry_->AddInterface(
base::BindRepeating(&BindFuchsiaCdmProvider, &cdm_manager_));
base::BindRepeating(&BindFuchsiaCdmProvider, cdm_manager_.get()));
}

WebEngineCdmService::~WebEngineCdmService() {
Expand Down
9 changes: 7 additions & 2 deletions fuchsia/engine/browser/web_engine_cdm_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
#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 <memory>

#include "services/service_manager/public/cpp/binder_registry.h"

namespace content {
class RenderFrameHost;
}

namespace media {
class FuchsiaCdmManager;
}

class WebEngineCdmService {
public:
explicit WebEngineCdmService(
Expand All @@ -20,7 +25,7 @@ class WebEngineCdmService {
~WebEngineCdmService();

private:
media::FuchsiaCdmManager cdm_manager_;
std::unique_ptr<media::FuchsiaCdmManager> cdm_manager_;

// Not owned pointer. |registry_| must outlive |this|.
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>* const
Expand Down
1 change: 1 addition & 0 deletions media/fuchsia/cdm/DEPS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include_rules = [
"+fuchsia/base",
"+services/service_manager/public",
]
6 changes: 5 additions & 1 deletion media/fuchsia/cdm/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ source_set("service") {
"fuchsia_cdm_manager.h",
]

public_deps = [
"//third_party/fuchsia-sdk/sdk:media_drm",
]

deps = [
"//fuchsia/base",
"//media",
"//media/fuchsia/mojom",
"//third_party/fuchsia-sdk/sdk:media_drm",
"//url",
]
}

0 comments on commit 52b96fc

Please sign in to comment.