Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/crypto/key_systems_info.h" | 5 #include "content/renderer/media/crypto/key_systems_info.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/media/crypto/key_systems.h" | |
| 8 #include "third_party/WebKit/public/platform/WebString.h" | 9 #include "third_party/WebKit/public/platform/WebString.h" |
| 9 | 10 |
| 10 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 11 | 12 |
| 12 // The following must be after widevine_cdm_version.h. | 13 // The following must be after widevine_cdm_version.h. |
| 13 | 14 |
| 14 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | 15 #if defined(WIDEVINE_CDM_AVAILABLE) && \ |
| 15 defined(OS_LINUX) && !defined(OS_CHROMEOS) | 16 defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 16 #include <gnu/libc-version.h> | 17 #include <gnu/libc-version.h> |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/version.h" | 19 #include "base/version.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | 22 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
| 22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 23 #include "media/base/media_switches.h" | 24 #include "media/base/media_switches.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| 28 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 29 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 29 | 30 |
| 30 #if defined(ENABLE_PEPPER_CDMS) | 31 #if defined(ENABLE_PEPPER_CDMS) |
| 31 static const char kExternalClearKeyKeySystem[] = | 32 static const char kExternalClearKeyKeySystem[] = |
| 32 "org.chromium.externalclearkey"; | 33 "org.chromium.externalclearkey"; |
| 33 #endif // defined(ENABLE_PEPPER_CDMS) | 34 #endif // defined(ENABLE_PEPPER_CDMS) |
| 34 | 35 |
| 35 #if defined(WIDEVINE_CDM_AVAILABLE) | 36 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 36 // TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. | |
| 37 static const char kWidevineBaseKeySystem[] = "com.widevine"; | |
| 38 | 37 |
| 39 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 38 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 40 // The supported codecs depend on what the CDM provides. | 39 // The supported codecs depend on what the CDM provides. |
| 41 static const char kWidevineVideoMp4Codecs[] = | 40 static const char kWidevineVideoMp4Codecs[] = |
| 42 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ | 41 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ |
| 43 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 42 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| 44 "avc1,mp4a"; | 43 "avc1,mp4a"; |
| 45 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | 44 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
| 46 "avc1"; | 45 "avc1"; |
| 47 #else | 46 #else |
| 48 ""; // No codec strings are supported. | 47 ""; // No codec strings are supported. |
| 49 #endif | 48 #endif |
| 50 | 49 |
| 51 static const char kWidevineAudioMp4Codecs[] = | 50 static const char kWidevineAudioMp4Codecs[] = |
| 52 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 51 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| 53 "mp4a"; | 52 "mp4a"; |
| 54 #else | 53 #else |
| 55 ""; // No codec strings are supported. | 54 ""; // No codec strings are supported. |
| 56 #endif | 55 #endif |
| 57 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 56 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 58 | 57 |
| 59 static inline bool IsWidevine(const std::string& key_system) { | 58 static void RegisterWidevine() { |
| 60 return key_system == kWidevineKeySystem || | 59 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 61 key_system == kWidevineBaseKeySystem; | 60 Version glibc_version(gnu_get_libc_version()); |
| 61 DCHECK(glibc_version.IsValid()); | |
| 62 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) | |
| 63 return; | |
| 64 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 65 | |
| 66 AddConcreteSupportedKeySystem( | |
| 67 kWidevineKeySystem, | |
| 68 #if defined(ENABLE_PEPPER_CDMS) | |
| 69 kWidevineCdmPluginMimeType, | |
| 70 #elif defined(OS_ANDROID) | |
| 71 { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
| 72 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }, | |
| 73 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 74 false); | |
| 75 AddSupportedType(kWidevineKeySystem, "video/webm", "vorbis,vp8,vp8.0"); | |
| 76 AddSupportedType(kWidevineKeySystem, "audio/webm", "vorbis"); | |
| 77 #if defined(USE_PROPRIETARY_CODECS) && \ | |
| 78 defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 79 AddSupportedType(kWidevineKeySystem, "video/mp4", kWidevineVideoMp4Codecs); | |
| 80 AddSupportedType(kWidevineKeySystem, "audio/mp4", kWidevineAudioMp4Codecs); | |
| 81 #endif // defined(USE_PROPRIETARY_CODECS) && | |
| 82 // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 83 | |
| 84 AddParentKeySystem("com.widevine", kWidevineKeySystem); | |
| 62 } | 85 } |
| 63 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 86 #endif // WIDEVINE_CDM_AVAILABLE |
| 64 | 87 |
| 65 const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { | 88 |
| 89 void RegisterKeySystems() { | |
| 66 // Clear Key. | 90 // Clear Key. |
| 67 { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, | 91 AddConcreteSupportedKeySystem(kClearKeyKeySystem, |
| 68 { "audio/webm", "vorbis", kClearKeyKeySystem }, | 92 #if defined(ENABLE_PEPPER_CDMS) |
| 93 "", | |
| 94 #elif defined(OS_ANDROID) | |
| 95 { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | |
| 96 0x0, 0x0, 0x0, 0x0,0x0, 0x0, 0x0, 0x0, }, | |
|
xhwang
2013/08/27 20:58:05
space/align
ddorwin
2013/08/27 22:41:22
Done. (space)
| |
| 97 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 98 true); | |
| 99 AddSupportedType(kClearKeyKeySystem, "video/webm", "vorbis,vp8,vp8.0"); | |
| 100 AddSupportedType(kClearKeyKeySystem, "audio/webm", "vorbis"); | |
| 69 #if defined(USE_PROPRIETARY_CODECS) | 101 #if defined(USE_PROPRIETARY_CODECS) |
| 70 { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, | 102 AddSupportedType(kClearKeyKeySystem, "video/mp4", "avc1,mp4a"); |
| 71 { "audio/mp4", "mp4a", kClearKeyKeySystem }, | 103 AddSupportedType(kClearKeyKeySystem, "audio/mp4", "mp4a"); |
| 72 #endif // defined(USE_PROPRIETARY_CODECS) | 104 #endif // defined(USE_PROPRIETARY_CODECS) |
| 73 | 105 |
| 74 #if defined(ENABLE_PEPPER_CDMS) | 106 #if defined(ENABLE_PEPPER_CDMS) |
| 75 // External Clear Key (used for testing). | 107 // External Clear Key (used for testing). |
| 76 { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, | 108 AddConcreteSupportedKeySystem(kExternalClearKeyKeySystem, |
| 77 { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, | 109 "application/x-ppapi-clearkey-cdm", false); |
| 110 AddSupportedType(kExternalClearKeyKeySystem, | |
| 111 "video/webm", "vorbis,vp8,vp8.0"); | |
| 112 AddSupportedType(kExternalClearKeyKeySystem, "audio/webm", "vorbis"); | |
| 78 #if defined(USE_PROPRIETARY_CODECS) | 113 #if defined(USE_PROPRIETARY_CODECS) |
| 79 { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, | 114 AddSupportedType(kExternalClearKeyKeySystem, "video/mp4", "avc1,mp4a"); |
| 80 { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, | 115 AddSupportedType(kExternalClearKeyKeySystem, "audio/mp4", "mp4a"); |
| 81 #endif // defined(USE_PROPRIETARY_CODECS) | 116 #endif // defined(USE_PROPRIETARY_CODECS) |
| 82 #endif // defined(ENABLE_PEPPER_CDMS) | 117 #endif // defined(ENABLE_PEPPER_CDMS) |
| 83 | 118 |
| 84 #if defined(WIDEVINE_CDM_AVAILABLE) | 119 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 85 // Widevine. | 120 RegisterWidevine(); |
| 86 { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, | |
| 87 { "audio/webm", "vorbis", kWidevineKeySystem }, | |
| 88 #if defined(USE_PROPRIETARY_CODECS) | |
| 89 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 90 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem }, | |
| 91 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem }, | |
| 92 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | |
| 93 #endif // defined(USE_PROPRIETARY_CODECS) | |
| 94 #endif // WIDEVINE_CDM_AVAILABLE | 121 #endif // WIDEVINE_CDM_AVAILABLE |
| 95 }; | |
| 96 | |
| 97 const int kNumSupportedFormatKeySystemCombinations = | |
| 98 arraysize(kSupportedFormatKeySystemCombinations); | |
| 99 | |
| 100 #if defined(ENABLE_PEPPER_CDMS) | |
| 101 const KeySystemPepperTypePair kKeySystemToPepperTypeMapping[] = { | |
| 102 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm"}, | |
| 103 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 104 { kWidevineKeySystem, kWidevineCdmPluginMimeType} | |
| 105 #endif // WIDEVINE_CDM_AVAILABLE | |
| 106 }; | |
| 107 | |
| 108 const int kNumKeySystemToPepperTypeMapping = | |
| 109 arraysize(kKeySystemToPepperTypeMapping); | |
| 110 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 111 | |
| 112 #if defined(OS_ANDROID) | |
| 113 // TODO(qinmin): add UUIDs for other key systems. | |
| 114 const KeySystemUUIDPair kKeySystemToUUIDMapping[] = { | |
| 115 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 116 { kWidevineKeySystem, { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
| 117 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED } | |
| 118 } | |
| 119 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 120 }; | |
| 121 | |
| 122 // arraySize() does not work if the array is empty, so use ARRAYSIZE_UNSAFE(). | |
| 123 const int kNumKeySystemToUUIDMapping = | |
| 124 ARRAYSIZE_UNSAFE(kKeySystemToUUIDMapping); | |
| 125 #endif // defined(OS_ANDROID) | |
| 126 | |
| 127 bool IsOSIncompatible(const std::string& concrete_key_system) { | |
| 128 DCHECK(IsConcreteKeySystem(concrete_key_system)) | |
| 129 << concrete_key_system << " is not a concrete system"; | |
| 130 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | |
| 131 defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 132 if (IsWidevine(concrete_key_system)) { | |
| 133 Version glibc_version(gnu_get_libc_version()); | |
| 134 DCHECK(glibc_version.IsValid()); | |
| 135 return glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); | |
| 136 } | |
| 137 #endif | |
| 138 return false; | |
| 139 } | |
| 140 | |
| 141 std::string EnsureConcreteKeySystem(const std::string& key_system) { | |
| 142 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 143 if (key_system == kWidevineKeySystem || key_system == kWidevineBaseKeySystem) | |
| 144 return kWidevineKeySystem; | |
| 145 #endif // WIDEVINE_CDM_AVAILABLE | |
| 146 // No parent names for Clear Key. | |
| 147 if (key_system == kClearKeyKeySystem) | |
| 148 return kClearKeyKeySystem; | |
| 149 #if defined(ENABLE_PEPPER_CDMS) | |
| 150 // No parent names for External Clear Key. | |
| 151 if (key_system == kExternalClearKeyKeySystem) | |
| 152 return kExternalClearKeyKeySystem; | |
| 153 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 154 return ""; | |
| 155 } | 122 } |
| 156 | 123 |
| 157 bool IsCanPlayTypeSuppressed(const std::string& key_system) { | 124 bool IsCanPlayTypeSuppressed(const std::string& key_system) { |
| 158 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | 125 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
| 159 // See http://crbug.com/237627. | 126 // See http://crbug.com/237627. |
| 160 if (IsWidevine(key_system) && | 127 if (key_system == kWidevineKeySystem && |
| 161 !CommandLine::ForCurrentProcess()->HasSwitch( | 128 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 162 switches::kOverrideEncryptedMediaCanPlayType)) | 129 switches::kOverrideEncryptedMediaCanPlayType)) |
| 163 return true; | 130 return true; |
| 164 #endif | 131 #endif |
| 165 return false; | 132 return false; |
| 166 } | 133 } |
| 167 | 134 |
| 168 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) { | 135 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) { |
| 169 if (key_system == kClearKeyKeySystem) | 136 if (key_system == kClearKeyKeySystem) |
| 170 return "ClearKey"; | 137 return "ClearKey"; |
| 171 #if defined(WIDEVINE_CDM_AVAILABLE) | 138 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 172 if (key_system == kWidevineKeySystem) | 139 if (key_system == kWidevineKeySystem) |
| 173 return "Widevine"; | 140 return "Widevine"; |
| 174 #endif // WIDEVINE_CDM_AVAILABLE | 141 #endif // WIDEVINE_CDM_AVAILABLE |
| 175 return "Unknown"; | 142 return "Unknown"; |
| 176 } | 143 } |
| 177 | 144 |
| 178 bool CanUseAesDecryptorInternal(const std::string& key_system) { | |
| 179 return key_system == kClearKeyKeySystem; | |
| 180 } | |
| 181 | |
| 182 } // namespace content | 145 } // namespace content |
| OLD | NEW |