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 "chrome/renderer/media/chrome_key_systems.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/platform/WebString.h" | |
9 | 8 |
10 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 9 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
11 | 10 |
12 // The following must be after widevine_cdm_version.h. | 11 // The following must be after widevine_cdm_version.h. |
13 | 12 |
14 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) | 13 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
15 #include <gnu/libc-version.h> | 14 #include <gnu/libc-version.h> |
16 #include "base/version.h" | 15 #include "base/version.h" |
17 #endif | 16 #endif |
18 | 17 |
19 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | 18 using content::KeySystemInfo; |
20 #include "base/command_line.h" | |
21 #include "media/base/media_switches.h" | |
22 #endif | |
23 | |
24 namespace content { | |
25 | 19 |
26 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 20 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
27 | 21 |
28 static const char kAudioWebM[] = "audio/webm"; | 22 static const char kAudioWebM[] = "audio/webm"; |
29 static const char kVideoWebM[] = "video/webm"; | 23 static const char kVideoWebM[] = "video/webm"; |
30 static const char kVorbis[] = "vorbis"; | 24 static const char kVorbis[] = "vorbis"; |
31 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; | 25 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; |
32 | 26 |
33 static const char kAudioMp4[] = "audio/mp4"; | 27 static const char kAudioMp4[] = "audio/mp4"; |
34 static const char kVideoMp4[] = "video/mp4"; | 28 static const char kVideoMp4[] = "video/mp4"; |
35 static const char kMp4a[] = "mp4a"; | 29 static const char kMp4a[] = "mp4a"; |
36 static const char kAvc1[] = "avc1"; | 30 static const char kAvc1[] = "avc1"; |
37 static const char kMp4aAvc1[] = "mp4a,avc1"; | 31 static const char kMp4aAvc1[] = "mp4a,avc1"; |
38 | 32 |
39 #if defined(WIDEVINE_CDM_AVAILABLE) | 33 #if defined(WIDEVINE_CDM_AVAILABLE) |
34 // Defines bitmask values used to specify supported codecs. | |
35 // Each value represents a codec within a specific container. | |
40 enum SupportedCodecs { | 36 enum SupportedCodecs { |
41 WEBM_VP8_AND_VORBIS = 1 << 0, | 37 WEBM_VP8_AND_VORBIS = 1 << 0, |
42 #if defined(USE_PROPRIETARY_CODECS) | 38 #if defined(USE_PROPRIETARY_CODECS) |
43 MP4_AAC = 1 << 1, | 39 MP4_AAC = 1 << 1, |
44 MP4_AVC1 = 1 << 2, | 40 MP4_AVC1 = 1 << 2, |
45 #endif // defined(USE_PROPRIETARY_CODECS) | 41 #endif // defined(USE_PROPRIETARY_CODECS) |
46 }; | 42 }; |
47 | 43 |
48 static void AddWidevineForTypes( | 44 static void AddWidevineForCodecs( |
xhwang
2013/09/11 20:38:55
nit: will AddWidevineWithCodecs be better?
ddorwin
2013/09/12 22:35:40
Done.
| |
49 SupportedCodecs supported_codecs, | 45 SupportedCodecs supported_codecs, |
50 std::vector<KeySystemInfo>* concrete_key_systems) { | 46 std::vector<KeySystemInfo>* concrete_key_systems) { |
51 static const char kWidevineParentKeySystem[] = "com.widevine"; | 47 static const char kWidevineParentKeySystem[] = "com.widevine"; |
52 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
53 static const uint8 kWidevineUuid[16] = { | 49 static const uint8 kWidevineUuid[16] = { |
54 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | 50 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
55 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | 51 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
56 #endif | 52 #endif |
57 | 53 |
58 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) | 54 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 | 94 |
99 #if defined(USE_PROPRIETARY_CODECS) | 95 #if defined(USE_PROPRIETARY_CODECS) |
100 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) | 96 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) |
101 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC); | 97 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC); |
102 #endif | 98 #endif |
103 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) | 99 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) |
104 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); | 100 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); |
105 #endif | 101 #endif |
106 #endif // defined(USE_PROPRIETARY_CODECS) | 102 #endif // defined(USE_PROPRIETARY_CODECS) |
107 | 103 |
108 AddWidevineForTypes(supported_codecs, concrete_key_systems); | 104 AddWidevineForCodecs(supported_codecs, concrete_key_systems); |
109 } | 105 } |
110 #elif defined(OS_ANDROID) | 106 #elif defined(OS_ANDROID) |
111 static void AddAndroidWidevine( | 107 static void AddAndroidWidevine( |
112 std::vector<KeySystemInfo>* concrete_key_systems) { | 108 std::vector<KeySystemInfo>* concrete_key_systems) { |
113 SupportedCodecs supported_codecs = MP4_AAC | MP4_AVC1; | 109 SupportedCodecs supported_codecs = MP4_AAC | MP4_AVC1; |
114 AddWidevineForTypes(supported_codecs, concrete_key_systems); | 110 AddWidevineForCodecs(supported_codecs, concrete_key_systems); |
115 } | 111 } |
116 #endif // defined(ENABLE_PEPPER_CDMS) | 112 #endif // defined(ENABLE_PEPPER_CDMS) |
117 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 113 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
118 | 114 |
119 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { | 115 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { |
120 KeySystemInfo info(kClearKeyKeySystem); | 116 KeySystemInfo info(kClearKeyKeySystem); |
121 | 117 |
122 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); | 118 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); |
123 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); | 119 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); |
124 #if defined(USE_PROPRIETARY_CODECS) | 120 #if defined(USE_PROPRIETARY_CODECS) |
(...skipping 23 matching lines...) Expand all Loading... | |
148 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); | 144 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); |
149 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); | 145 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); |
150 #endif // defined(USE_PROPRIETARY_CODECS) | 146 #endif // defined(USE_PROPRIETARY_CODECS) |
151 | 147 |
152 info.pepper_type = kExternalClearKeyPepperType; | 148 info.pepper_type = kExternalClearKeyPepperType; |
153 | 149 |
154 concrete_key_systems->push_back(info); | 150 concrete_key_systems->push_back(info); |
155 } | 151 } |
156 #endif // defined(ENABLE_PEPPER_CDMS) | 152 #endif // defined(ENABLE_PEPPER_CDMS) |
157 | 153 |
158 void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info) { | 154 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { |
159 AddClearKey(key_systems_info); | 155 AddClearKey(key_systems_info); |
160 | 156 |
161 #if defined(ENABLE_PEPPER_CDMS) | 157 #if defined(ENABLE_PEPPER_CDMS) |
162 AddExternalClearKey(key_systems_info); | 158 AddExternalClearKey(key_systems_info); |
163 #endif | 159 #endif |
164 | 160 |
165 #if defined(WIDEVINE_CDM_AVAILABLE) | 161 #if defined(WIDEVINE_CDM_AVAILABLE) |
166 #if defined(ENABLE_PEPPER_CDMS) | 162 #if defined(ENABLE_PEPPER_CDMS) |
167 AddPepperBasedWidevine(key_systems_info); | 163 AddPepperBasedWidevine(key_systems_info); |
168 #elif defined(OS_ANDROID) | 164 #elif defined(OS_ANDROID) |
169 AddAndroidWidevine(key_systems_info); | 165 AddAndroidWidevine(key_systems_info); |
170 #endif | 166 #endif |
171 #endif | 167 #endif |
172 } | 168 } |
173 | |
174 bool IsCanPlayTypeSuppressed(const std::string& key_system) { | |
175 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) | |
176 // See http://crbug.com/237627. | |
177 if (key_system == kWidevineKeySystem && | |
178 !CommandLine::ForCurrentProcess()->HasSwitch( | |
179 switches::kOverrideEncryptedMediaCanPlayType)) | |
180 return true; | |
181 #endif | |
182 return false; | |
183 } | |
184 | |
185 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) { | |
186 if (key_system == kClearKeyKeySystem) | |
187 return "ClearKey"; | |
188 #if defined(WIDEVINE_CDM_AVAILABLE) | |
189 if (key_system == kWidevineKeySystem) | |
190 return "Widevine"; | |
191 #endif // WIDEVINE_CDM_AVAILABLE | |
192 return "Unknown"; | |
193 } | |
194 | |
195 } // namespace content | |
OLD | NEW |