| 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 "webkit/renderer/media/crypto/key_systems_info.h" | 5 #include "webkit/renderer/media/crypto/key_systems_info.h" |
| 6 | 6 |
| 7 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 7 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 8 | 8 |
| 9 // The following must be after widevine_cdm_version.h. | |
| 10 | |
| 11 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | 9 #if defined(WIDEVINE_CDM_AVAILABLE) && \ |
| 12 defined(OS_LINUX) && !defined(OS_CHROMEOS) | 10 defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 13 #include <gnu/libc-version.h> | 11 #include <gnu/libc-version.h> |
| 14 #include "base/logging.h" | 12 #include "base/logging.h" |
| 15 #include "base/version.h" | 13 #include "base/version.h" |
| 16 #endif | 14 #endif |
| 17 | 15 |
| 18 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
| 19 #include "base/command_line.h" | |
| 20 #include "media/base/media_switches.h" | |
| 21 #endif | |
| 22 | |
| 23 namespace webkit_media { | 16 namespace webkit_media { |
| 24 | 17 |
| 25 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 18 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 26 | 19 |
| 27 static const char kExternalClearKeyKeySystem[] = | 20 static const char kExternalClearKeyKeySystem[] = |
| 28 "org.chromium.externalclearkey"; | 21 "org.chromium.externalclearkey"; |
| 29 | 22 |
| 30 #if defined(WIDEVINE_CDM_AVAILABLE) | 23 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 31 // TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. | 24 // TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. |
| 32 static const char kWidevineBaseKeySystem[] = "com.widevine"; | 25 static const char kWidevineBaseKeySystem[] = "com.widevine"; |
| 26 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 33 | 27 |
| 34 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 28 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 35 // The supported codecs depend on what the CDM provides. | 29 // The supported codecs depend on what the CDM provides. |
| 36 static const char kWidevineVideoMp4Codecs[] = | 30 static const char kWidevineVideoMp4Codecs[] = |
| 37 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ | 31 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ |
| 38 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 32 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| 39 "avc1,mp4a"; | 33 "avc1,mp4a"; |
| 40 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | 34 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
| 41 "avc1"; | 35 "avc1"; |
| 42 #else | 36 #else |
| 43 ""; // No codec strings are supported. | 37 ""; // No codec strings are supported. |
| 44 #endif | 38 #endif |
| 45 | 39 |
| 46 static const char kWidevineAudioMp4Codecs[] = | 40 static const char kWidevineAudioMp4Codecs[] = |
| 47 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 41 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
| 48 "mp4a"; | 42 "mp4a"; |
| 49 #else | 43 #else |
| 50 ""; // No codec strings are supported. | 44 ""; // No codec strings are supported. |
| 51 #endif | 45 #endif |
| 52 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 46 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 53 | 47 |
| 54 static inline bool IsWidevine(const std::string& key_system) { | |
| 55 return key_system == kWidevineKeySystem || | |
| 56 key_system == kWidevineBaseKeySystem; | |
| 57 } | |
| 58 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 59 | |
| 60 const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { | 48 const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { |
| 61 // Clear Key. | 49 // Clear Key. |
| 62 { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, | 50 { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, |
| 63 { "audio/webm", "vorbis", kClearKeyKeySystem }, | 51 { "audio/webm", "vorbis", kClearKeyKeySystem }, |
| 64 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 52 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| 65 { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, | 53 { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, |
| 66 { "audio/mp4", "mp4a", kClearKeyKeySystem }, | 54 { "audio/mp4", "mp4a", kClearKeyKeySystem }, |
| 67 #endif | 55 #endif |
| 68 | 56 |
| 69 // External Clear Key (used for testing). | 57 // External Clear Key (used for testing). |
| 70 { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, | 58 { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, |
| 71 { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, | 59 { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, |
| 72 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 60 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| 73 { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, | 61 { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, |
| 74 { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, | 62 { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, |
| 75 #endif | 63 #endif |
| 76 | 64 |
| 77 #if defined(WIDEVINE_CDM_AVAILABLE) | 65 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 78 // Widevine. | 66 // Widevine. |
| 67 // See http://crbug.com/237627. |
| 68 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
| 69 { "", "", kWidevineKeySystem }, |
| 70 #else |
| 79 { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, | 71 { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, |
| 80 { "audio/webm", "vorbis", kWidevineKeySystem }, | 72 { "audio/webm", "vorbis", kWidevineKeySystem }, |
| 81 { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem }, | 73 { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem }, |
| 82 { "audio/webm", "vorbis", kWidevineBaseKeySystem }, | 74 { "audio/webm", "vorbis", kWidevineBaseKeySystem }, |
| 83 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 75 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| 84 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 76 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 85 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem }, | 77 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem }, |
| 86 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineBaseKeySystem }, | 78 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineBaseKeySystem }, |
| 87 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem }, | 79 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem }, |
| 88 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem }, | 80 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem }, |
| 89 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) | 81 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) |
| 90 #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 82 #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| 83 #endif // defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) |
| 91 #endif // WIDEVINE_CDM_AVAILABLE | 84 #endif // WIDEVINE_CDM_AVAILABLE |
| 92 }; | 85 }; |
| 93 | 86 |
| 94 const int kNumSupportedFormatKeySystemCombinations = | 87 const int kNumSupportedFormatKeySystemCombinations = |
| 95 arraysize(kSupportedFormatKeySystemCombinations); | 88 arraysize(kSupportedFormatKeySystemCombinations); |
| 96 | 89 |
| 97 #if defined(ENABLE_PEPPER_CDMS) | 90 #if defined(ENABLE_PEPPER_CDMS) |
| 98 const KeySystemPepperTypePair kKeySystemToPepperTypeMapping[] = { | 91 const KeySystemPepperTypePair kKeySystemToPepperTypeMapping[] = { |
| 99 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm"}, | 92 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm"}, |
| 100 #if defined(WIDEVINE_CDM_AVAILABLE) | 93 #if defined(WIDEVINE_CDM_AVAILABLE) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 117 }; | 110 }; |
| 118 | 111 |
| 119 // arraySize() does not work if the array is empty, so use ARRAYSIZE_UNSAFE(). | 112 // arraySize() does not work if the array is empty, so use ARRAYSIZE_UNSAFE(). |
| 120 const int kNumKeySystemToUUIDMapping = | 113 const int kNumKeySystemToUUIDMapping = |
| 121 ARRAYSIZE_UNSAFE(kKeySystemToUUIDMapping); | 114 ARRAYSIZE_UNSAFE(kKeySystemToUUIDMapping); |
| 122 #endif // defined(OS_ANDROID) | 115 #endif // defined(OS_ANDROID) |
| 123 | 116 |
| 124 bool IsSystemCompatible(const std::string& key_system) { | 117 bool IsSystemCompatible(const std::string& key_system) { |
| 125 #if defined(WIDEVINE_CDM_AVAILABLE) && \ | 118 #if defined(WIDEVINE_CDM_AVAILABLE) && \ |
| 126 defined(OS_LINUX) && !defined(OS_CHROMEOS) | 119 defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 127 if (IsWidevine(key_system)) { | 120 if (key_system == kWidevineKeySystem || |
| 121 key_system == kWidevineBaseKeySystem) { |
| 128 Version glibc_version(gnu_get_libc_version()); | 122 Version glibc_version(gnu_get_libc_version()); |
| 129 DCHECK(glibc_version.IsValid()); | 123 DCHECK(glibc_version.IsValid()); |
| 130 return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); | 124 return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); |
| 131 } | 125 } |
| 132 #endif | 126 #endif |
| 133 return true; | 127 return true; |
| 134 } | 128 } |
| 135 | 129 |
| 136 bool IsCanPlayTypeSuppressed(const std::string& key_system) { | |
| 137 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
| 138 // See http://crbug.com/237627. | |
| 139 if (IsWidevine(key_system) && | |
| 140 !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 141 switches::kEncryptedMediaCanPlayTypeOverride)) | |
| 142 return true; | |
| 143 #endif | |
| 144 return false; | |
| 145 } | |
| 146 | |
| 147 std::string KeySystemNameForUMAGeneric(const std::string& key_system) { | 130 std::string KeySystemNameForUMAGeneric(const std::string& key_system) { |
| 148 if (key_system == kClearKeyKeySystem) | 131 if (key_system == kClearKeyKeySystem) |
| 149 return "ClearKey"; | 132 return "ClearKey"; |
| 150 #if defined(WIDEVINE_CDM_AVAILABLE) | 133 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 151 if (key_system == kWidevineKeySystem) | 134 if (key_system == kWidevineKeySystem) |
| 152 return "Widevine"; | 135 return "Widevine"; |
| 153 #endif // WIDEVINE_CDM_AVAILABLE | 136 #endif // WIDEVINE_CDM_AVAILABLE |
| 154 return "Unknown"; | 137 return "Unknown"; |
| 155 } | 138 } |
| 156 | 139 |
| 157 bool CanUseBuiltInAesDecryptor(const std::string& key_system) { | 140 bool CanUseBuiltInAesDecryptor(const std::string& key_system) { |
| 158 return key_system == kClearKeyKeySystem; | 141 return key_system == kClearKeyKeySystem; |
| 159 } | 142 } |
| 160 | 143 |
| 161 } // namespace webkit_media | 144 } // namespace webkit_media |
| OLD | NEW |