Chromium Code Reviews| Index: content/renderer/media/crypto/key_systems_info.cc |
| diff --git a/content/renderer/media/crypto/key_systems_info.cc b/content/renderer/media/crypto/key_systems_info.cc |
| index 495fe05e965ab22f269727f3f85431c5e9e60220..e3d28d30e48ed0371fbe10f9a2f8b7c103c16d5e 100644 |
| --- a/content/renderer/media/crypto/key_systems_info.cc |
| +++ b/content/renderer/media/crypto/key_systems_info.cc |
| @@ -5,7 +5,6 @@ |
| #include "content/renderer/media/crypto/key_systems_info.h" |
| #include "base/logging.h" |
| -#include "content/renderer/media/crypto/key_systems.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| @@ -26,41 +25,33 @@ namespace content { |
| static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| -#if defined(ENABLE_PEPPER_CDMS) |
| -static const char kExternalClearKeyKeySystem[] = |
| - "org.chromium.externalclearkey"; |
| -#elif defined(OS_ANDROID) |
| -static const uint8 kEmptyUuid[16] = |
| - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; |
| -static const uint8 kWidevineUuid[16] = |
| - { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
| - 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| -#endif |
| +static const char kAudioWebM[] = "audio/webm"; |
| +static const char kVideoWebM[] = "video/webm"; |
| +static const char kVorbis[] = "vorbis"; |
| +static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; |
| -#if defined(WIDEVINE_CDM_AVAILABLE) |
| +static const char kAudioMp4[] = "audio/mp4"; |
| +static const char kVideoMp4[] = "video/mp4"; |
| +static const char kMp4a[] = "mp4a"; |
| +static const char kAvc1[] = "avc1"; |
| +static const char kMp4aAvc1[] = "mp4a,avc1"; |
| -#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| -// The supported codecs depend on what the CDM provides. |
| -static const char kWidevineVideoMp4Codecs[] = |
| -#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ |
| - defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| - "avc1,mp4a"; |
| -#elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
| - "avc1"; |
| -#else |
| - ""; // No codec strings are supported. |
| -#endif |
| - |
| -static const char kWidevineAudioMp4Codecs[] = |
| -#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| - "mp4a"; |
| -#else |
| - ""; // No codec strings are supported. |
| +#if defined(WIDEVINE_CDM_AVAILABLE) |
| +static void AddWidevineForTypes( |
| + bool is_webm_vp8_and_vorbis_supported, |
| +#if defined(USE_PROPRIETARY_CODECS) |
| + bool is_mp4_supported, |
| + bool is_aac_supported, |
| + bool is_avc1_supported, |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + static const char kWidevineParentKeySystem[] = "com.widevine"; |
| +#if defined(OS_ANDROID) |
| + static const uint8 kWidevineUuid[16] = |
| + { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
|
xhwang
2013/09/04 21:48:40
Move "{" to the previous line?
ddorwin
2013/09/06 18:30:00
Done.
|
| + 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| #endif |
| -#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| -static void RegisterWidevine() { |
| #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
| Version glibc_version(gnu_get_libc_version()); |
| DCHECK(glibc_version.IsValid()); |
| @@ -68,71 +59,116 @@ static void RegisterWidevine() { |
| return; |
| #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
| - AddConcreteSupportedKeySystem( |
| - kWidevineKeySystem, |
| - false, |
| + KeySystemInfo info(kWidevineKeySystem); |
| + |
| + if (is_webm_vp8_and_vorbis_supported) { |
| + info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
| + info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
| + } |
| + |
| +#if defined(USE_PROPRIETARY_CODECS) |
| + DCHECK(!is_mp4_supported || (!is_aac_supported && !is_aac_supported)); |
| + if (is_mp4_supported) { |
| + const char* video_codecs = is_avc1_supported ? |
| + (is_aac_supported ? kMp4aAvc1 : kAvc1) : |
| + ""; |
| + const char* audio_codecs = is_aac_supported ? kMp4a : ""; |
| + |
| + info.supported_types.push_back(std::make_pair(kAudioMp4, audio_codecs)); |
| + info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs)); |
| + } |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| + |
| + info.parent_key_system = kWidevineParentKeySystem; |
| + |
| #if defined(ENABLE_PEPPER_CDMS) |
| - kWidevineCdmPluginMimeType, |
| + info.pepper_type = kWidevineCdmPluginMimeType; |
| #elif defined(OS_ANDROID) |
| - kWidevineUuid, |
| + info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); |
| #endif // defined(ENABLE_PEPPER_CDMS) |
| - "com.widevine"); |
| - AddSupportedType(kWidevineKeySystem, "video/webm", "vorbis,vp8,vp8.0"); |
| - AddSupportedType(kWidevineKeySystem, "audio/webm", "vorbis"); |
| -#if defined(USE_PROPRIETARY_CODECS) && \ |
| - defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| - AddSupportedType(kWidevineKeySystem, "video/mp4", kWidevineVideoMp4Codecs); |
| - AddSupportedType(kWidevineKeySystem, "audio/mp4", kWidevineAudioMp4Codecs); |
| -#endif // defined(USE_PROPRIETARY_CODECS) && |
| - // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| -} |
| -#endif // WIDEVINE_CDM_AVAILABLE |
| + concrete_key_systems->push_back(info); |
| +} |
| -static void RegisterClearKey() { |
| - // Clear Key. |
| - AddConcreteSupportedKeySystem( |
| - kClearKeyKeySystem, |
| - true, |
| #if defined(ENABLE_PEPPER_CDMS) |
| - std::string(), |
| -#elif defined(OS_ANDROID) |
| - kEmptyUuid, |
| +// Supported types are determined at compile time. |
| +static void AddPepperBasedWidevine( |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + AddWidevineForTypes(true, // WebM, VP8 & Vorbis. |
| +#if defined(USE_PROPRIETARY_CODECS) |
| +#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| + true, // MP4. |
| +#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| + true, // AAC. |
| +#else |
| + false, // No AAC. |
| +#endif |
| +#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
| + true, // AVC1. |
|
xhwang
2013/09/04 21:48:40
Shall we define bit flags for these? e.g.
CDM_SUPP
ddorwin
2013/09/06 18:30:00
Done.
|
| +#else |
| + false, // No AVC1. |
| +#endif |
| +#else |
| + false, false, false, // No MP4 codecs. |
| +#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| + concrete_key_systems); |
| +} |
| #endif // defined(ENABLE_PEPPER_CDMS) |
| - std::string()); |
| - AddSupportedType(kClearKeyKeySystem, "video/webm", "vorbis,vp8,vp8.0"); |
| - AddSupportedType(kClearKeyKeySystem, "audio/webm", "vorbis"); |
| +#endif // defined(WIDEVINE_CDM_AVAILABLE) |
| + |
| +static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { |
| + KeySystemInfo info(kClearKeyKeySystem); |
| + |
| + info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
| + info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
| #if defined(USE_PROPRIETARY_CODECS) |
| - AddSupportedType(kClearKeyKeySystem, "video/mp4", "avc1,mp4a"); |
| - AddSupportedType(kClearKeyKeySystem, "audio/mp4", "mp4a"); |
| + info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
| + info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); |
| #endif // defined(USE_PROPRIETARY_CODECS) |
| + |
| + info.use_aes_decryptor = true; |
| + |
| + concrete_key_systems->push_back(info); |
| } |
| #if defined(ENABLE_PEPPER_CDMS) |
| -static void RegisterExternalClearKey() { |
| - // External Clear Key (used for testing). |
| - AddConcreteSupportedKeySystem(kExternalClearKeyKeySystem, false, |
| - "application/x-ppapi-clearkey-cdm", |
| - std::string()); |
| - AddSupportedType(kExternalClearKeyKeySystem, |
| - "video/webm", "vorbis,vp8,vp8.0"); |
| - AddSupportedType(kExternalClearKeyKeySystem, "audio/webm", "vorbis"); |
| +// External Clear Key (used for testing). |
| +static void AddExternalClearKey( |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + static const char kExternalClearKeyKeySystem[] = |
| + "org.chromium.externalclearkey"; |
| + static const char kExternalClearKeyPepperType[] = |
| + "application/x-ppapi-clearkey-cdm"; |
| + |
| + KeySystemInfo info(kExternalClearKeyKeySystem); |
| + |
| + info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
| + info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
| #if defined(USE_PROPRIETARY_CODECS) |
| - AddSupportedType(kExternalClearKeyKeySystem, "video/mp4", "avc1,mp4a"); |
| - AddSupportedType(kExternalClearKeyKeySystem, "audio/mp4", "mp4a"); |
| + info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
| + info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); |
| #endif // defined(USE_PROPRIETARY_CODECS) |
| + |
| + info.pepper_type = kExternalClearKeyPepperType; |
| + |
| + concrete_key_systems->push_back(info); |
| } |
| #endif // defined(ENABLE_PEPPER_CDMS) |
| -void RegisterKeySystems() { |
| - RegisterClearKey(); |
| +void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info) { |
| + AddClearKey(key_systems_info); |
| #if defined(ENABLE_PEPPER_CDMS) |
| - RegisterExternalClearKey(); |
| + AddExternalClearKey(key_systems_info); |
| #endif |
| #if defined(WIDEVINE_CDM_AVAILABLE) |
| - RegisterWidevine(); |
| +#if defined(ENABLE_PEPPER_CDMS) |
| + AddPepperBasedWidevine(key_systems_info); |
| +#else |
| +#error TODO(ddorwin): Need to check the platform |
| +#endif |
| #endif |
| } |