Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: chrome/renderer/media/chrome_key_systems.cc

Issue 23452025: Move EME key system knowledge from content/ to chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test on Android Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 AddWidevineWithCodecs(
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
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 AddWidevineWithCodecs(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 #if defined(USE_PROPRIETARY_CODECS) 109 #if defined(USE_PROPRIETARY_CODECS)
114 SupportedCodecs supported_codecs = 110 SupportedCodecs supported_codecs =
115 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1); 111 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1);
116 AddWidevineForTypes(supported_codecs, concrete_key_systems); 112 AddWidevineForTypes(supported_codecs, concrete_key_systems);
117 #endif // defined(USE_PROPRIETARY_CODECS) 113 #endif // defined(USE_PROPRIETARY_CODECS)
118 } 114 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); 147 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
152 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); 148 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1));
153 #endif // defined(USE_PROPRIETARY_CODECS) 149 #endif // defined(USE_PROPRIETARY_CODECS)
154 150
155 info.pepper_type = kExternalClearKeyPepperType; 151 info.pepper_type = kExternalClearKeyPepperType;
156 152
157 concrete_key_systems->push_back(info); 153 concrete_key_systems->push_back(info);
158 } 154 }
159 #endif // defined(ENABLE_PEPPER_CDMS) 155 #endif // defined(ENABLE_PEPPER_CDMS)
160 156
161 void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info) { 157 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
162 AddClearKey(key_systems_info); 158 AddClearKey(key_systems_info);
163 159
164 #if defined(ENABLE_PEPPER_CDMS) 160 #if defined(ENABLE_PEPPER_CDMS)
165 AddExternalClearKey(key_systems_info); 161 AddExternalClearKey(key_systems_info);
166 #endif 162 #endif
167 163
168 #if defined(WIDEVINE_CDM_AVAILABLE) 164 #if defined(WIDEVINE_CDM_AVAILABLE)
169 #if defined(ENABLE_PEPPER_CDMS) 165 #if defined(ENABLE_PEPPER_CDMS)
170 AddPepperBasedWidevine(key_systems_info); 166 AddPepperBasedWidevine(key_systems_info);
171 #elif defined(OS_ANDROID) 167 #elif defined(OS_ANDROID)
172 AddAndroidWidevine(key_systems_info); 168 AddAndroidWidevine(key_systems_info);
173 #endif 169 #endif
174 #endif 170 #endif
175 } 171 }
176
177 bool IsCanPlayTypeSuppressed(const std::string& key_system) {
178 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
179 // See http://crbug.com/237627.
180 if (key_system == kWidevineKeySystem &&
181 !CommandLine::ForCurrentProcess()->HasSwitch(
182 switches::kOverrideEncryptedMediaCanPlayType))
183 return true;
184 #endif
185 return false;
186 }
187
188 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) {
189 if (key_system == kClearKeyKeySystem)
190 return "ClearKey";
191 #if defined(WIDEVINE_CDM_AVAILABLE)
192 if (key_system == kWidevineKeySystem)
193 return "Widevine";
194 #endif // WIDEVINE_CDM_AVAILABLE
195 return "Unknown";
196 }
197
198 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/media/chrome_key_systems.h ('k') | content/browser/media/encrypted_media_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698