Commit 33651419 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Enable PlayReady cdm in web_engine and cast_runner

Now web-engine respects playready_key_system flag in CreateContextParams
and cast_runner sets this flag when creating web.Context.

Bug: 1009755
Change-Id: I718cc105068a06a6c99b2f51180fd3e88b1a1fc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848415
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705318}
parent f6d88501
...@@ -112,6 +112,26 @@ class WidevineHandler : public media::FuchsiaCdmManager::KeySystemHandler { ...@@ -112,6 +112,26 @@ class WidevineHandler : public media::FuchsiaCdmManager::KeySystemHandler {
} }
}; };
class PlayreadyHandler : public media::FuchsiaCdmManager::KeySystemHandler {
public:
PlayreadyHandler() = default;
~PlayreadyHandler() override = default;
void CreateCdm(
fidl::InterfaceRequest<fuchsia::media::drm::ContentDecryptionModule>
request) override {
auto playready = base::fuchsia::ComponentContextForCurrentProcess()
->svc()
->Connect<fuchsia::media::drm::PlayReady>();
playready->CreateContentDecryptionModule(std::move(request));
}
fuchsia::media::drm::ProvisionerPtr CreateProvisioner() override {
// Provisioning is not required for PlayReady.
return fuchsia::media::drm::ProvisionerPtr();
}
};
// Supported key systems: // Supported key systems:
std::unique_ptr<media::FuchsiaCdmManager> CreateCdmManager() { std::unique_ptr<media::FuchsiaCdmManager> CreateCdmManager() {
media::FuchsiaCdmManager::KeySystemHandlerMap handlers; media::FuchsiaCdmManager::KeySystemHandlerMap handlers;
...@@ -121,6 +141,14 @@ std::unique_ptr<media::FuchsiaCdmManager> CreateCdmManager() { ...@@ -121,6 +141,14 @@ std::unique_ptr<media::FuchsiaCdmManager> CreateCdmManager() {
handlers.emplace(kWidevineKeySystem, std::make_unique<WidevineHandler>()); handlers.emplace(kWidevineKeySystem, std::make_unique<WidevineHandler>());
} }
std::string playready_key_system =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kPlayreadyKeySystem);
if (!playready_key_system.empty()) {
handlers.emplace(playready_key_system,
std::make_unique<PlayreadyHandler>());
}
return std::make_unique<media::FuchsiaCdmManager>(std::move(handlers)); return std::make_unique<media::FuchsiaCdmManager>(std::move(handlers));
} }
......
...@@ -33,6 +33,76 @@ bool IsSupportedHardwareVideoCodec(const media::VideoType& type) { ...@@ -33,6 +33,76 @@ bool IsSupportedHardwareVideoCodec(const media::VideoType& type) {
return false; return false;
} }
class PlayreadyKeySystemProperties : public ::media::KeySystemProperties {
public:
PlayreadyKeySystemProperties(const std::string& key_system_name,
media::SupportedCodecs supported_codecs,
bool persistent_license_support)
: key_system_name_(key_system_name),
supported_codecs_(supported_codecs),
persistent_license_support_(persistent_license_support) {}
std::string GetKeySystemName() const override { return key_system_name_; }
bool IsSupportedInitDataType(
media::EmeInitDataType init_data_type) const override {
return init_data_type == media::EmeInitDataType::CENC;
}
media::SupportedCodecs GetSupportedCodecs() const override {
return supported_codecs_;
}
media::SupportedCodecs GetSupportedHwSecureCodecs() const override {
return supported_codecs_;
}
media::EmeConfigRule GetRobustnessConfigRule(
media::EmeMediaType media_type,
const std::string& requested_robustness) const override {
// Only empty robustness string is currently supported.
if (requested_robustness.empty()) {
return media::EmeConfigRule::HW_SECURE_CODECS_REQUIRED;
}
return media::EmeConfigRule::NOT_SUPPORTED;
}
media::EmeSessionTypeSupport GetPersistentLicenseSessionSupport()
const override {
return persistent_license_support_
? media::EmeSessionTypeSupport::SUPPORTED
: media::EmeSessionTypeSupport::NOT_SUPPORTED;
}
media::EmeSessionTypeSupport GetPersistentUsageRecordSessionSupport()
const override {
return media::EmeSessionTypeSupport::NOT_SUPPORTED;
}
media::EmeFeatureSupport GetPersistentStateSupport() const override {
return media::EmeFeatureSupport::ALWAYS_ENABLED;
}
media::EmeFeatureSupport GetDistinctiveIdentifierSupport() const override {
return media::EmeFeatureSupport::ALWAYS_ENABLED;
}
media::EmeConfigRule GetEncryptionSchemeConfigRule(
media::EncryptionMode encryption_mode) const override {
if (encryption_mode == ::media::EncryptionMode::kCenc) {
return media::EmeConfigRule::SUPPORTED;
}
return media::EmeConfigRule::NOT_SUPPORTED;
}
private:
const std::string key_system_name_;
const media::SupportedCodecs supported_codecs_;
const bool persistent_license_support_;
};
} // namespace } // namespace
WebEngineContentRendererClient::WebEngineContentRendererClient() = default; WebEngineContentRendererClient::WebEngineContentRendererClient() = default;
...@@ -82,33 +152,33 @@ WebEngineContentRendererClient::CreateURLLoaderThrottleProvider( ...@@ -82,33 +152,33 @@ WebEngineContentRendererClient::CreateURLLoaderThrottleProvider(
void WebEngineContentRendererClient::AddSupportedKeySystems( void WebEngineContentRendererClient::AddSupportedKeySystems(
std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) { std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( media::SupportedCodecs supported_video_codecs = 0;
switches::kEnableWidevine)) { constexpr uint8_t kUnknownCodecLevel = 0;
media::SupportedCodecs supported_video_codecs = 0; if (IsSupportedHardwareVideoCodec(media::VideoType{
constexpr uint8_t kUnknownCodecLevel = 0; media::kCodecVP9, media::VP9PROFILE_PROFILE0, kUnknownCodecLevel,
if (IsSupportedHardwareVideoCodec(media::VideoType{ media::VideoColorSpace::REC709()})) {
media::kCodecVP9, media::VP9PROFILE_PROFILE0, kUnknownCodecLevel, supported_video_codecs |= media::EME_CODEC_VP9_PROFILE0;
media::VideoColorSpace::REC709()})) { }
supported_video_codecs |= media::EME_CODEC_VP9_PROFILE0;
}
if (IsSupportedHardwareVideoCodec(media::VideoType{ if (IsSupportedHardwareVideoCodec(media::VideoType{
media::kCodecVP9, media::VP9PROFILE_PROFILE2, kUnknownCodecLevel, media::kCodecVP9, media::VP9PROFILE_PROFILE2, kUnknownCodecLevel,
media::VideoColorSpace::REC709()})) { media::VideoColorSpace::REC709()})) {
supported_video_codecs |= media::EME_CODEC_VP9_PROFILE2; supported_video_codecs |= media::EME_CODEC_VP9_PROFILE2;
} }
if (IsSupportedHardwareVideoCodec(media::VideoType{ if (IsSupportedHardwareVideoCodec(media::VideoType{
media::kCodecH264, media::H264PROFILE_MAIN, kUnknownCodecLevel, media::kCodecH264, media::H264PROFILE_MAIN, kUnknownCodecLevel,
media::VideoColorSpace::REC709()})) { media::VideoColorSpace::REC709()})) {
supported_video_codecs |= media::EME_CODEC_AVC1; supported_video_codecs |= media::EME_CODEC_AVC1;
} }
media::SupportedCodecs supported_audio_codecs = media::EME_CODEC_AUDIO_ALL; media::SupportedCodecs supported_audio_codecs = media::EME_CODEC_AUDIO_ALL;
media::SupportedCodecs supported_codecs = media::SupportedCodecs supported_codecs =
supported_video_codecs | supported_audio_codecs; supported_video_codecs | supported_audio_codecs;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableWidevine)) {
base::flat_set<media::EncryptionMode> encryption_schemes{ base::flat_set<media::EncryptionMode> encryption_schemes{
media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}; media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs};
...@@ -129,6 +199,15 @@ void WebEngineContentRendererClient::AddSupportedKeySystems( ...@@ -129,6 +199,15 @@ void WebEngineContentRendererClient::AddSupportedKeySystems(
media::EmeFeatureSupport::ALWAYS_ENABLED, // persistent state media::EmeFeatureSupport::ALWAYS_ENABLED, // persistent state
media::EmeFeatureSupport::ALWAYS_ENABLED)); // distinctive identifier media::EmeFeatureSupport::ALWAYS_ENABLED)); // distinctive identifier
} }
std::string playready_key_system =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kPlayreadyKeySystem);
if (!playready_key_system.empty()) {
key_systems->emplace_back(
new PlayreadyKeySystemProperties(playready_key_system, supported_codecs,
/*persistent_license_support=*/false));
}
} }
bool WebEngineContentRendererClient::IsSupportedVideoType( bool WebEngineContentRendererClient::IsSupportedVideoType(
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"fuchsia.fonts.Provider", "fuchsia.fonts.Provider",
"fuchsia.logger.LogSink", "fuchsia.logger.LogSink",
"fuchsia.media.Audio", "fuchsia.media.Audio",
"fuchsia.media.drm.PlayReady",
"fuchsia.media.drm.Widevine", "fuchsia.media.drm.Widevine",
"fuchsia.mediacodec.CodecFactory", "fuchsia.mediacodec.CodecFactory",
"fuchsia.net.NameLookup", "fuchsia.net.NameLookup",
......
...@@ -39,6 +39,9 @@ int main(int argc, char** argv) { ...@@ -39,6 +39,9 @@ int main(int argc, char** argv) {
WebContentRunner::BuildCreateContextParams( WebContentRunner::BuildCreateContextParams(
fidl::InterfaceHandle<fuchsia::io::Directory>(), features); fidl::InterfaceHandle<fuchsia::io::Directory>(), features);
const char kCastPlayreadyKeySystem[] = "com.chromecast.playready";
create_context_params.set_playready_key_system(kCastPlayreadyKeySystem);
// TODO(b/141956135): Use CrKey version provided by the Agent. // TODO(b/141956135): Use CrKey version provided by the Agent.
create_context_params.set_user_agent_product("CrKey"); create_context_params.set_user_agent_product("CrKey");
create_context_params.set_user_agent_version("0"); create_context_params.set_user_agent_version("0");
......
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