diff options
author | sandersd <sandersd@chromium.org> | 2015-05-05 18:50:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-06 01:52:17 +0000 |
commit | a6bf8b52a70dafe95e8e2d8827f5e1283ec1bf56 (patch) | |
tree | 24fd280efc30617bbdb4802a082dce2ea3a99d8e /components/cdm | |
parent | d5538fccee51a36e074196b5f5b846a787559600 (diff) | |
download | chromium_src-a6bf8b52a70dafe95e8e2d8827f5e1283ec1bf56.zip chromium_src-a6bf8b52a70dafe95e8e2d8827f5e1283ec1bf56.tar.gz chromium_src-a6bf8b52a70dafe95e8e2d8827f5e1283ec1bf56.tar.bz2 |
Support Android secure codecs in requestMediaKeySystemAccess().
This adds the bits necessary to determine if a configuration requires hardware-secure codecs. It does not add the logic to actually enable secure surfaces based on the requirement, that decision is still based on the renderer preference.
BUG=467779
Review URL: https://codereview.chromium.org/1106263004
Cr-Commit-Position: refs/heads/master@{#328464}
Diffstat (limited to 'components/cdm')
-rw-r--r-- | components/cdm/renderer/android_key_systems.cc | 83 | ||||
-rw-r--r-- | components/cdm/renderer/android_key_systems.h | 7 | ||||
-rw-r--r-- | components/cdm/renderer/widevine_key_systems.cc | 6 | ||||
-rw-r--r-- | components/cdm/renderer/widevine_key_systems.h | 3 |
4 files changed, 48 insertions, 51 deletions
diff --git a/components/cdm/renderer/android_key_systems.cc b/components/cdm/renderer/android_key_systems.cc index 28b45eb..b9521d3 100644 --- a/components/cdm/renderer/android_key_systems.cc +++ b/components/cdm/renderer/android_key_systems.cc @@ -17,7 +17,9 @@ #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. +using media::EmeFeatureSupport; using media::EmeRobustness; +using media::EmeSessionTypeSupport; using media::KeySystemInfo; using media::SupportedCodecs; @@ -39,60 +41,50 @@ static SupportedKeySystemResponse QueryKeySystemSupport( return response; } -void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems, - bool is_non_compositing_supported) { +void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { SupportedKeySystemResponse response = QueryKeySystemSupport( kWidevineKeySystem); - // When creating the WIDEVINE key system, BrowserCdmFactoryAndroid configures - // the CDM's security level based on a pref. Therefore the supported - // codec/robustenss combinations depend on that pref, represented by - // |bool is_non_compositing_supported|. - // TODO(sandersd): For unprefixed, set the security level based on the - // requested robustness instead of the flag. http://crbug.com/467779 - // We should also stop using the term "non_compositing." - SupportedCodecs codecs = response.compositing_codecs; - EmeRobustness max_audio_robustness = EmeRobustness::SW_SECURE_CRYPTO; - EmeRobustness max_video_robustness = EmeRobustness::SW_SECURE_CRYPTO; - if (is_non_compositing_supported) { - codecs = response.non_compositing_codecs; - max_audio_robustness = EmeRobustness::HW_SECURE_CRYPTO; - max_video_robustness = EmeRobustness::HW_SECURE_ALL; - } - - // We are using MediaDrm API on Android and we cannot guarantee that API - // doesn't use persistent storage on the device. Therefore always set - // persistent state to EmeFeatureSupport::ALWAYS_ENABLED to err on the - // safe side. + // Since we do not control the implementation of the MediaDrm API on Android, + // we assume that it can and will make use of persistence even though no + // persistence-based features are supported. - if (codecs != media::EME_CODEC_NONE) { + if (response.compositing_codecs != media::EME_CODEC_NONE) { AddWidevineWithCodecs( - WIDEVINE, codecs, max_audio_robustness, max_video_robustness, - media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. - media::EmeSessionTypeSupport:: - NOT_SUPPORTED, // persistent-release-message. - media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. - media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive - // identifier. + WIDEVINE, + response.compositing_codecs, // Regular codecs. + response.non_compositing_codecs, // Hardware-secure codecs. + EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. + EmeRobustness::HW_SECURE_ALL, // Max video robustness. + EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. + EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. + EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. + EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. concrete_key_systems); + } else { + // It doesn't make sense to support secure codecs but not regular codecs. + DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE); } // For compatibility with the prefixed API, register a separate L1 key system. - // When creating the WIDEVINE_HR_NON_COMPOSITING key system, - // BrowserCdmFactoryAndroid does not configure the CDM's security level (that - // is, leaves it as L1); therefore only secure codecs are supported. - // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 - if (response.non_compositing_codecs != media::EME_CODEC_NONE) { + // This key systems acts as though only hardware-secure codecs are available. + // We only register support for codecs with both regular and hardware-secure + // variants so that we can be sure they will work regardless of the renderer + // preference. + SupportedCodecs secure_codecs = + response.compositing_codecs & response.non_compositing_codecs; + if (secure_codecs != media::EME_CODEC_NONE) { + // Note: The prefixed API only consults the regular codecs field. AddWidevineWithCodecs( - WIDEVINE_HR_NON_COMPOSITING, response.non_compositing_codecs, - EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. - EmeRobustness::HW_SECURE_ALL, // Max video robustness. - media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. - media::EmeSessionTypeSupport:: - NOT_SUPPORTED, // persistent-release-message. - media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. - media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive - // identifier. + WIDEVINE_HR_NON_COMPOSITING, + secure_codecs, // Regular codecs. + media::EME_CODEC_NONE, // Hardware-secure codecs. + EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. + EmeRobustness::HW_SECURE_ALL, // Max video robustness. + EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. + EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. + EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. + EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. concrete_key_systems); } } @@ -121,7 +113,8 @@ void AddAndroidPlatformKeySystems( #endif // defined(USE_PROPRIETARY_CODECS) info.max_audio_robustness = EmeRobustness::EMPTY; info.max_video_robustness = EmeRobustness::EMPTY; - // Assume the worst case (from a user point of view). + // Assume that platform key systems support no features but can and will + // make use of persistence and identifiers. info.persistent_license_support = media::EmeSessionTypeSupport::NOT_SUPPORTED; info.persistent_release_message_support = diff --git a/components/cdm/renderer/android_key_systems.h b/components/cdm/renderer/android_key_systems.h index b27f57c..fb962b1 100644 --- a/components/cdm/renderer/android_key_systems.h +++ b/components/cdm/renderer/android_key_systems.h @@ -12,12 +12,7 @@ namespace cdm { void AddAndroidWidevine( - std::vector<media::KeySystemInfo>* concrete_key_systems, - // TODO(sandersd): Non-compositing support depends on the - // use_video_overlay_for_embedded_encrypted_video pref, which may differ per - // WebContents, meaning this cannot be a global setting for the renderer - // process. Handle this per WebContents instead. http://crbug.com/467779 - bool is_non_compositing_supported); + std::vector<media::KeySystemInfo>* concrete_key_systems); // Add platform-supported key systems which are not explicitly handled // by Chrome. diff --git a/components/cdm/renderer/widevine_key_systems.cc b/components/cdm/renderer/widevine_key_systems.cc index c1412c3..3998066 100644 --- a/components/cdm/renderer/widevine_key_systems.cc +++ b/components/cdm/renderer/widevine_key_systems.cc @@ -29,6 +29,9 @@ static std::string GetDirectParentName(std::string name) { void AddWidevineWithCodecs( WidevineCdmType widevine_cdm_type, SupportedCodecs supported_codecs, +#if defined(OS_ANDROID) + SupportedCodecs supported_secure_codecs, +#endif // defined(OS_ANDROID) media::EmeRobustness max_audio_robustness, media::EmeRobustness max_video_robustness, media::EmeSessionTypeSupport persistent_license_support, @@ -57,6 +60,9 @@ void AddWidevineWithCodecs( // there are no codecs supported in that container. Fix this when we support // initDataType. info.supported_codecs = supported_codecs; +#if defined(OS_ANDROID) + info.supported_secure_codecs = supported_secure_codecs; +#endif // defined(OS_ANDROID) // Here we assume that support for a container imples support for the // associated initialization data type. KeySystems handles validating diff --git a/components/cdm/renderer/widevine_key_systems.h b/components/cdm/renderer/widevine_key_systems.h index dc05bb8..125e297 100644 --- a/components/cdm/renderer/widevine_key_systems.h +++ b/components/cdm/renderer/widevine_key_systems.h @@ -22,6 +22,9 @@ enum WidevineCdmType { void AddWidevineWithCodecs( WidevineCdmType widevine_cdm_type, media::SupportedCodecs supported_codecs, +#if defined(OS_ANDROID) + media::SupportedCodecs supported_secure_codecs, +#endif // defined(OS_ANDROID) media::EmeRobustness max_audio_robustness, media::EmeRobustness max_video_robustness, media::EmeSessionTypeSupport persistent_license_support, |