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