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

Side by Side Diff: content/renderer/media/crypto/key_systems_info.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 "content/renderer/media/crypto/key_systems_info.h"
6 6
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebString.h" 7 #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)
15 #include <gnu/libc-version.h>
16 #include "base/version.h"
17 #endif
18
19 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) 13 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
20 #include "base/command_line.h" 14 #include "base/command_line.h"
21 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
22 #endif 16 #endif
23 17
24 namespace content { 18 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";
29 static const char kVideoWebM[] = "video/webm";
30 static const char kVorbis[] = "vorbis";
31 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0";
32
33 static const char kAudioMp4[] = "audio/mp4";
34 static const char kVideoMp4[] = "video/mp4";
35 static const char kMp4a[] = "mp4a";
36 static const char kAvc1[] = "avc1";
37 static const char kMp4aAvc1[] = "mp4a,avc1";
38
39 #if defined(WIDEVINE_CDM_AVAILABLE)
40 enum SupportedCodecs {
41 WEBM_VP8_AND_VORBIS = 1 << 0,
42 #if defined(USE_PROPRIETARY_CODECS)
43 MP4_AAC = 1 << 1,
44 MP4_AVC1 = 1 << 2,
45 #endif // defined(USE_PROPRIETARY_CODECS)
46 };
47
48 static void AddWidevineForTypes(
49 SupportedCodecs supported_codecs,
50 std::vector<KeySystemInfo>* concrete_key_systems) {
51 static const char kWidevineParentKeySystem[] = "com.widevine";
52 #if defined(OS_ANDROID)
53 static const uint8 kWidevineUuid[16] = {
54 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
55 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
56 #endif
57
58 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
59 Version glibc_version(gnu_get_libc_version());
60 DCHECK(glibc_version.IsValid());
61 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION))
62 return;
63 #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
64
65 KeySystemInfo info(kWidevineKeySystem);
66
67 if (supported_codecs & WEBM_VP8_AND_VORBIS) {
68 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
69 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
70 }
71
72 #if defined(USE_PROPRIETARY_CODECS)
73 if (supported_codecs & MP4_AAC)
74 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
75
76 if (supported_codecs & MP4_AVC1) {
77 const char* video_codecs = (supported_codecs & MP4_AAC) ? kMp4aAvc1 : kAvc1;
78 info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs));
79 }
80 #endif // defined(USE_PROPRIETARY_CODECS)
81
82 info.parent_key_system = kWidevineParentKeySystem;
83
84 #if defined(ENABLE_PEPPER_CDMS)
85 info.pepper_type = kWidevineCdmPluginMimeType;
86 #elif defined(OS_ANDROID)
87 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid));
88 #endif // defined(ENABLE_PEPPER_CDMS)
89
90 concrete_key_systems->push_back(info);
91 }
92
93 #if defined(ENABLE_PEPPER_CDMS)
94 // Supported types are determined at compile time.
95 static void AddPepperBasedWidevine(
96 std::vector<KeySystemInfo>* concrete_key_systems) {
97 SupportedCodecs supported_codecs = WEBM_VP8_AND_VORBIS;
98
99 #if defined(USE_PROPRIETARY_CODECS)
100 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
101 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC);
102 #endif
103 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
104 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
105 #endif
106 #endif // defined(USE_PROPRIETARY_CODECS)
107
108 AddWidevineForTypes(supported_codecs, concrete_key_systems);
109 }
110 #elif defined(OS_ANDROID)
111 static void AddAndroidWidevine(
112 std::vector<KeySystemInfo>* concrete_key_systems) {
113 #if defined(USE_PROPRIETARY_CODECS)
114 SupportedCodecs supported_codecs =
115 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1);
116 AddWidevineForTypes(supported_codecs, concrete_key_systems);
117 #endif // defined(USE_PROPRIETARY_CODECS)
118 }
119 #endif // defined(ENABLE_PEPPER_CDMS)
120 #endif // defined(WIDEVINE_CDM_AVAILABLE)
121
122 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
123 KeySystemInfo info(kClearKeyKeySystem);
124
125 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
126 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
127 #if defined(USE_PROPRIETARY_CODECS)
128 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
129 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1));
130 #endif // defined(USE_PROPRIETARY_CODECS)
131
132 info.use_aes_decryptor = true;
133
134 concrete_key_systems->push_back(info);
135 }
136
137 #if defined(ENABLE_PEPPER_CDMS)
138 // External Clear Key (used for testing).
139 static void AddExternalClearKey(
140 std::vector<KeySystemInfo>* concrete_key_systems) {
141 static const char kExternalClearKeyKeySystem[] =
142 "org.chromium.externalclearkey";
143 static const char kExternalClearKeyPepperType[] =
144 "application/x-ppapi-clearkey-cdm";
145
146 KeySystemInfo info(kExternalClearKeyKeySystem);
147
148 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
149 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
150 #if defined(USE_PROPRIETARY_CODECS)
151 info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
152 info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1));
153 #endif // defined(USE_PROPRIETARY_CODECS)
154
155 info.pepper_type = kExternalClearKeyPepperType;
156
157 concrete_key_systems->push_back(info);
158 }
159 #endif // defined(ENABLE_PEPPER_CDMS)
160
161 void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
162 AddClearKey(key_systems_info);
163
164 #if defined(ENABLE_PEPPER_CDMS)
165 AddExternalClearKey(key_systems_info);
166 #endif
167
168 #if defined(WIDEVINE_CDM_AVAILABLE)
169 #if defined(ENABLE_PEPPER_CDMS)
170 AddPepperBasedWidevine(key_systems_info);
171 #elif defined(OS_ANDROID)
172 AddAndroidWidevine(key_systems_info);
173 #endif
174 #endif
175 }
176
177 bool IsCanPlayTypeSuppressed(const std::string& key_system) { 22 bool IsCanPlayTypeSuppressed(const std::string& key_system) {
178 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) 23 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
179 // See http://crbug.com/237627. 24 // See http://crbug.com/237627.
180 if (key_system == kWidevineKeySystem && 25 if (key_system == kWidevineKeySystem &&
181 !CommandLine::ForCurrentProcess()->HasSwitch( 26 !CommandLine::ForCurrentProcess()->HasSwitch(
182 switches::kOverrideEncryptedMediaCanPlayType)) 27 switches::kOverrideEncryptedMediaCanPlayType))
183 return true; 28 return true;
184 #endif 29 #endif
185 return false; 30 return false;
186 } 31 }
187 32
188 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) { 33 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) {
189 if (key_system == kClearKeyKeySystem) 34 if (key_system == kClearKeyKeySystem)
190 return "ClearKey"; 35 return "ClearKey";
191 #if defined(WIDEVINE_CDM_AVAILABLE) 36 #if defined(WIDEVINE_CDM_AVAILABLE)
192 if (key_system == kWidevineKeySystem) 37 if (key_system == kWidevineKeySystem)
193 return "Widevine"; 38 return "Widevine";
194 #endif // WIDEVINE_CDM_AVAILABLE 39 #endif // WIDEVINE_CDM_AVAILABLE
195 return "Unknown"; 40 return "Unknown";
196 } 41 }
197 42
198 } // namespace content 43 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/crypto/key_systems_info.h ('k') | content/renderer/media/crypto/key_systems_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698