Chromium Code Reviews| Index: components/cdm/renderer/android_key_systems.cc |
| diff --git a/components/cdm/renderer/android_key_systems.cc b/components/cdm/renderer/android_key_systems.cc |
| index 56d2aec617265331d7181e11a3a9b903e5409374..8284d37f0428e66ea36b2500edb8ffbb09c3c62e 100644 |
| --- a/components/cdm/renderer/android_key_systems.cc |
| +++ b/components/cdm/renderer/android_key_systems.cc |
| @@ -10,21 +10,81 @@ |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "components/cdm/common/cdm_messages_android.h" |
| -#include "components/cdm/renderer/widevine_key_systems.h" |
| +#include "components/cdm/renderer/widevine_key_system_properties.h" |
| #include "content/public/renderer/render_thread.h" |
| #include "media/base/eme_constants.h" |
| #include "media/base/media_switches.h" |
| #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| +using media::EmeConfigRule; |
| using media::EmeFeatureSupport; |
| +using media::EmeInitDataType; |
| using media::EmeRobustness; |
| using media::EmeSessionTypeSupport; |
| -using media::KeySystemInfo; |
| +using media::KeySystemProperties; |
| using media::SupportedCodecs; |
| namespace cdm { |
| +namespace { |
| + |
| +// Implementation of KeySystemProperties for platform-supported key systems. |
| +// Assumes that platform key systems support no features but can and will |
| +// make use of persistence and identifiers. |
| +class AndroidPlatformKeySystemProperties : public KeySystemProperties { |
| + public: |
| + AndroidPlatformKeySystemProperties(const std::string& name, |
| + SupportedCodecs supported_codecs) |
| + : name_(name), supported_codecs_(supported_codecs) {} |
|
ddorwin
2016/04/27 22:41:54
In the future, we'll need some value other than th
halliwell
2016/04/27 23:50:45
Acknowledged.
|
| + |
| + std::string GetKeySystemName() const override { return name_; } |
| + |
| + bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override { |
| + // Here we assume that support for a container implies support for the |
| + // associated initialization data type. KeySystems handles validating |
| + // |init_data_type| x |container| pairings. |
|
ddorwin
2016/04/27 22:41:54
What does this mean?
halliwell
2016/04/27 23:50:45
This is a copy-paste from key_systems.cc. Do you
|
| + if (init_data_type == EmeInitDataType::WEBM) |
|
ddorwin
2016/04/27 22:41:54
Can we force the caller to make this assumption in
halliwell
2016/04/27 23:50:45
Ack, follow up on those bugs separately?
|
| + return (supported_codecs_ & media::EME_CODEC_WEBM_ALL) != 0; |
| +#if defined(USE_PROPRIETARY_CODECS) |
| + if (init_data_type == EmeInitDataType::CENC) |
|
ddorwin
2016/04/27 22:41:54
Use a switch statement instead?
Then explicitly li
halliwell
2016/04/27 23:50:45
Done.
|
| + return (supported_codecs_ & media::EME_CODEC_MP4_ALL) != 0; |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| + return false; |
| + } |
| + |
| + SupportedCodecs GetSupportedCodecs() const override { |
| + return supported_codecs_; |
| + } |
| + |
| + EmeConfigRule GetRobustnessConfigRule( |
| + media::EmeMediaType media_type, |
| + const std::string& requested_robustness) const override { |
| + return requested_robustness.empty() ? EmeConfigRule::SUPPORTED |
| + : EmeConfigRule::NOT_SUPPORTED; |
| + } |
| + |
| + EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override { |
| + return EmeSessionTypeSupport::NOT_SUPPORTED; |
| + } |
| + EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport() |
| + const override { |
| + return EmeSessionTypeSupport::NOT_SUPPORTED; |
| + } |
| + EmeFeatureSupport GetPersistentStateSupport() const override { |
| + return EmeFeatureSupport::ALWAYS_ENABLED; |
| + } |
| + EmeFeatureSupport GetDistinctiveIdentifierSupport() const override { |
| + return EmeFeatureSupport::ALWAYS_ENABLED; |
| + } |
| + |
| + private: |
| + std::string name_; |
|
ddorwin
2016/04/27 22:41:54
nit: can be consts
halliwell
2016/04/27 23:50:45
Done.
|
| + SupportedCodecs supported_codecs_; |
| +}; |
| + |
| +} // namespace |
| + |
| static SupportedKeySystemResponse QueryKeySystemSupport( |
| const std::string& key_system) { |
| SupportedKeySystemRequest request; |
| @@ -41,7 +101,8 @@ static SupportedKeySystemResponse QueryKeySystemSupport( |
| return response; |
| } |
| -void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
| +void AddAndroidWidevine( |
| + std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) { |
| SupportedKeySystemResponse response = QueryKeySystemSupport( |
| kWidevineKeySystem); |
| @@ -50,7 +111,7 @@ void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
| // persistence-based features are supported. |
| if (response.compositing_codecs != media::EME_CODEC_NONE) { |
| - AddWidevineWithCodecs( |
| + concrete_key_systems->emplace_back(new WidevineKeySystemProperties( |
| response.compositing_codecs, // Regular codecs. |
| response.non_compositing_codecs, // Hardware-secure codecs. |
| EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
| @@ -58,8 +119,7 @@ void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
| EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. |
| EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. |
| EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. |
| - EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive identifier. |
| - concrete_key_systems); |
| + EmeFeatureSupport::ALWAYS_ENABLED)); // Distinctive identifier. |
| } else { |
| // It doesn't make sense to support secure codecs but not regular codecs. |
| DCHECK(response.non_compositing_codecs == media::EME_CODEC_NONE); |
| @@ -67,7 +127,7 @@ void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
| } |
| void AddAndroidPlatformKeySystems( |
| - std::vector<KeySystemInfo>* concrete_key_systems) { |
| + std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) { |
| std::vector<std::string> key_system_names; |
| content::RenderThread::Get()->Send( |
| new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); |
| @@ -76,30 +136,8 @@ void AddAndroidPlatformKeySystems( |
| it != key_system_names.end(); ++it) { |
| SupportedKeySystemResponse response = QueryKeySystemSupport(*it); |
| if (response.compositing_codecs != media::EME_CODEC_NONE) { |
| - KeySystemInfo info; |
| - info.key_system = *it; |
| - info.supported_codecs = response.compositing_codecs; |
| - // Here we assume that support for a container implies support for the |
| - // associated initialization data type. KeySystems handles validating |
| - // |init_data_type| x |container| pairings. |
| - if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) |
| - info.supported_init_data_types |= media::kInitDataTypeMaskWebM; |
| -#if defined(USE_PROPRIETARY_CODECS) |
| - if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) |
| - info.supported_init_data_types |= media::kInitDataTypeMaskCenc; |
| -#endif // defined(USE_PROPRIETARY_CODECS) |
| - info.max_audio_robustness = EmeRobustness::EMPTY; |
| - info.max_video_robustness = EmeRobustness::EMPTY; |
| - // 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 = |
| - media::EmeSessionTypeSupport::NOT_SUPPORTED; |
| - info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; |
| - info.distinctive_identifier_support = |
| - media::EmeFeatureSupport::ALWAYS_ENABLED; |
| - concrete_key_systems->push_back(info); |
| + concrete_key_systems->emplace_back(new AndroidPlatformKeySystemProperties( |
| + *it, response.compositing_codecs)); |
| } |
| } |
| } |