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

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

Issue 246033002: Store SupportedCodecs in KeySystemInfo and KeySystems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: eme_codec.h Created 6 years, 8 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
« no previous file with comments | « chrome/common/encrypted_media_messages_android.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/renderer/media/chrome_key_systems.h" 5 #include "chrome/renderer/media/chrome_key_systems.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 10 matching lines...) Expand all
21 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 21 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
22 #include <gnu/libc-version.h> 22 #include <gnu/libc-version.h>
23 #include "base/version.h" 23 #include "base/version.h"
24 #endif 24 #endif
25 25
26 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
27 #include "chrome/common/encrypted_media_messages_android.h" 27 #include "chrome/common/encrypted_media_messages_android.h"
28 #endif 28 #endif
29 29
30 using content::KeySystemInfo; 30 using content::KeySystemInfo;
31 31 using content::SupportedCodecs;
32 const char kAudioWebM[] = "audio/webm";
33 const char kVideoWebM[] = "video/webm";
34 const char kVorbis[] = "vorbis";
35 const char kVP8[] = "vp8";
36 const char kVP80[] = "vp8.0";
37
38 #if defined(USE_PROPRIETARY_CODECS)
39 const char kAudioMp4[] = "audio/mp4";
40 const char kVideoMp4[] = "video/mp4";
41 const char kMp4a[] = "mp4a";
42 const char kAvc1[] = "avc1";
43 const char kAvc3[] = "avc3";
44 #endif // defined(USE_PROPRIETARY_CODECS)
45 32
46 #if defined(ENABLE_PEPPER_CDMS) 33 #if defined(ENABLE_PEPPER_CDMS)
47 static bool IsPepperCdmRegistered( 34 static bool IsPepperCdmRegistered(
48 const std::string& pepper_type, 35 const std::string& pepper_type,
49 std::vector<base::string16>* additional_param_names, 36 std::vector<base::string16>* additional_param_names,
50 std::vector<base::string16>* additional_param_values) { 37 std::vector<base::string16>* additional_param_values) {
51 bool is_registered = false; 38 bool is_registered = false;
52 content::RenderThread::Get()->Send( 39 content::RenderThread::Get()->Send(
53 new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType( 40 new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType(
54 pepper_type, 41 pepper_type,
(...skipping 23 matching lines...) Expand all
78 std::vector<base::string16> additional_param_names; 65 std::vector<base::string16> additional_param_names;
79 std::vector<base::string16> additional_param_values; 66 std::vector<base::string16> additional_param_values;
80 if (!IsPepperCdmRegistered(kExternalClearKeyPepperType, 67 if (!IsPepperCdmRegistered(kExternalClearKeyPepperType,
81 &additional_param_names, 68 &additional_param_names,
82 &additional_param_values)) { 69 &additional_param_values)) {
83 return; 70 return;
84 } 71 }
85 72
86 KeySystemInfo info(kExternalClearKeyKeySystem); 73 KeySystemInfo info(kExternalClearKeyKeySystem);
87 74
88 info.supported_types[kAudioWebM].insert(kVorbis); 75 info.supported_codecs = content::EME_CODEC_WEBM_ALL;
89 info.supported_types[kVideoWebM] = info.supported_types[kAudioWebM];
90 info.supported_types[kVideoWebM].insert(kVP8);
91 info.supported_types[kVideoWebM].insert(kVP80);
92 #if defined(USE_PROPRIETARY_CODECS) 76 #if defined(USE_PROPRIETARY_CODECS)
93 info.supported_types[kAudioMp4].insert(kMp4a); 77 info.supported_codecs |= content::EME_CODEC_MP4_ALL;
94 info.supported_types[kVideoMp4] = info.supported_types[kAudioMp4];
95 info.supported_types[kVideoMp4].insert(kAvc1);
96 info.supported_types[kVideoMp4].insert(kAvc3);
97 #endif // defined(USE_PROPRIETARY_CODECS) 78 #endif // defined(USE_PROPRIETARY_CODECS)
98 79
99 info.pepper_type = kExternalClearKeyPepperType; 80 info.pepper_type = kExternalClearKeyPepperType;
100 81
101 concrete_key_systems->push_back(info); 82 concrete_key_systems->push_back(info);
102 83
103 // Add support of decrypt-only mode in ClearKeyCdm. 84 // Add support of decrypt-only mode in ClearKeyCdm.
104 info.key_system = kExternalClearKeyDecryptOnlyKeySystem; 85 info.key_system = kExternalClearKeyDecryptOnlyKeySystem;
105 concrete_key_systems->push_back(info); 86 concrete_key_systems->push_back(info);
106 87
(...skipping 16 matching lines...) Expand all
123 104
124 #if defined(WIDEVINE_CDM_AVAILABLE) 105 #if defined(WIDEVINE_CDM_AVAILABLE)
125 enum WidevineCdmType { 106 enum WidevineCdmType {
126 WIDEVINE, 107 WIDEVINE,
127 WIDEVINE_HR, 108 WIDEVINE_HR,
128 #if defined(OS_ANDROID) 109 #if defined(OS_ANDROID)
129 WIDEVINE_HR_NON_COMPOSITING, 110 WIDEVINE_HR_NON_COMPOSITING,
130 #endif 111 #endif
131 }; 112 };
132 113
133 // Defines bitmask values used to specify supported codecs. 114 #if !defined(OS_ANDROID)
134 // Each value represents a codec within a specific container.
135 // The mask values are stored in a SupportedCodecs.
136 typedef uint32 SupportedCodecs;
137 enum SupportedCodecMasks {
138 NO_CODECS = 0,
139 WEBM_VORBIS = 1 << 0,
140 WEBM_VP8 = 1 << 1,
141 WEBM_CODECS = (WEBM_VORBIS | WEBM_VP8),
142 #if defined(USE_PROPRIETARY_CODECS)
143 MP4_AAC = 1 << 2,
144 MP4_AVC1 = 1 << 3,
145 MP4_CODECS = (MP4_AAC | MP4_AVC1),
146 ALL_CODECS = (WEBM_CODECS | MP4_CODECS),
147 #else
148 ALL_CODECS = WEBM_CODECS,
149 #endif // defined(USE_PROPRIETARY_CODECS)
150 INVALID_CODECS = ~ALL_CODECS
151 };
152
153 #if defined(OS_ANDROID)
154 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
155 COMPILE_ASSERT(static_cast<int>(name) == \
156 static_cast<int>(android::name), \
157 mismatching_enums)
158 COMPILE_ASSERT_MATCHING_ENUM(NO_CODECS);
159 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VORBIS);
160 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8);
161 COMPILE_ASSERT_MATCHING_ENUM(WEBM_CODECS);
162 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC);
163 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1);
164 COMPILE_ASSERT_MATCHING_ENUM(MP4_CODECS);
165 COMPILE_ASSERT_MATCHING_ENUM(ALL_CODECS);
166 COMPILE_ASSERT_MATCHING_ENUM(INVALID_CODECS);
167 #undef COMPILE_ASSERT_MATCHING_ENUM
168 #else
169 static bool IsWidevineHrSupported() { 115 static bool IsWidevineHrSupported() {
170 // TODO(jrummell): Need to call CheckPlatformState() but it is 116 // TODO(jrummell): Need to call CheckPlatformState() but it is
171 // asynchronous, and needs to be done in the browser. 117 // asynchronous, and needs to be done in the browser.
172 return false; 118 return false;
173 } 119 }
174 #endif 120 #endif
175 121
176 // Return |name|'s parent key system. 122 // Return |name|'s parent key system.
177 static std::string GetDirectParentName(std::string name) { 123 static std::string GetDirectParentName(std::string name) {
178 int last_period = name.find_last_of('.'); 124 int last_period = name.find_last_of('.');
(...skipping 20 matching lines...) Expand all
199 info.key_system.append(".hrnoncompositing"); 145 info.key_system.append(".hrnoncompositing");
200 break; 146 break;
201 #endif 147 #endif
202 default: 148 default:
203 NOTREACHED(); 149 NOTREACHED();
204 } 150 }
205 151
206 // TODO(xhwang): A container or an initDataType may be supported even though 152 // TODO(xhwang): A container or an initDataType may be supported even though
207 // there are no codecs supported in that container. Fix this when we support 153 // there are no codecs supported in that container. Fix this when we support
208 // initDataType. 154 // initDataType.
209 if (supported_codecs & WEBM_CODECS) { 155 info.supported_codecs = supported_codecs;
210 if (supported_codecs & WEBM_VORBIS)
211 info.supported_types[kAudioWebM].insert(kVorbis);
212
213 if (supported_codecs & WEBM_VP8) {
214 info.supported_types[kVideoWebM] = info.supported_types[kAudioWebM];
215 info.supported_types[kVideoWebM].insert(kVP8);
216 info.supported_types[kVideoWebM].insert(kVP80);
217 }
218 }
219
220 #if defined(USE_PROPRIETARY_CODECS)
221 if (supported_codecs & MP4_CODECS) {
222 if (supported_codecs & MP4_AAC)
223 info.supported_types[kAudioMp4].insert(kMp4a);
224
225 if (supported_codecs & MP4_AVC1) {
226 info.supported_types[kVideoMp4] = info.supported_types[kAudioMp4];
227 info.supported_types[kVideoMp4].insert(kAvc1);
228 info.supported_types[kVideoMp4].insert(kAvc3);
229 }
230 }
231 #endif // defined(USE_PROPRIETARY_CODECS)
232 156
233 #if defined(ENABLE_PEPPER_CDMS) 157 #if defined(ENABLE_PEPPER_CDMS)
234 info.pepper_type = kWidevineCdmPluginMimeType; 158 info.pepper_type = kWidevineCdmPluginMimeType;
235 #endif // defined(ENABLE_PEPPER_CDMS) 159 #endif // defined(ENABLE_PEPPER_CDMS)
236 160
237 concrete_key_systems->push_back(info); 161 concrete_key_systems->push_back(info);
238 } 162 }
239 163
240 #if defined(ENABLE_PEPPER_CDMS) 164 #if defined(ENABLE_PEPPER_CDMS)
241 // When the adapter is registered, a name-value pair is inserted in 165 // When the adapter is registered, a name-value pair is inserted in
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType, 207 if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType,
284 &additional_param_names, 208 &additional_param_names,
285 &additional_param_values)) { 209 &additional_param_values)) {
286 DVLOG(1) << "Widevine CDM is not currently available."; 210 DVLOG(1) << "Widevine CDM is not currently available.";
287 return; 211 return;
288 } 212 }
289 213
290 std::vector<std::string> codecs; 214 std::vector<std::string> codecs;
291 GetSupportedCodecs(additional_param_names, additional_param_values, &codecs); 215 GetSupportedCodecs(additional_param_names, additional_param_values, &codecs);
292 216
293 SupportedCodecs supported_codecs = NO_CODECS; 217 SupportedCodecs supported_codecs = content::EME_CODEC_NONE;
294 for (size_t i = 0; i < codecs.size(); ++i) { 218 for (size_t i = 0; i < codecs.size(); ++i) {
295 if (codecs[i] == kCdmSupportedCodecVorbis) 219 if (codecs[i] == kCdmSupportedCodecVorbis)
296 supported_codecs |= WEBM_VORBIS; 220 supported_codecs |= content::EME_CODEC_WEBM_VORBIS;
297 if (codecs[i] == kCdmSupportedCodecVp8) 221 if (codecs[i] == kCdmSupportedCodecVp8)
298 supported_codecs |= WEBM_VP8; 222 supported_codecs |= content::EME_CODEC_WEBM_VP8;
299 #if defined(USE_PROPRIETARY_CODECS) 223 #if defined(USE_PROPRIETARY_CODECS)
300 if (codecs[i] == kCdmSupportedCodecAac) 224 if (codecs[i] == kCdmSupportedCodecAac)
301 supported_codecs |= MP4_AAC; 225 supported_codecs |= content::EME_CODEC_MP4_AAC;
302 if (codecs[i] == kCdmSupportedCodecAvc1) 226 if (codecs[i] == kCdmSupportedCodecAvc1)
303 supported_codecs |= MP4_AVC1; 227 supported_codecs |= content::EME_CODEC_MP4_AVC1;
304 #endif // defined(USE_PROPRIETARY_CODECS) 228 #endif // defined(USE_PROPRIETARY_CODECS)
305 } 229 }
306 230
307 AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems); 231 AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems);
308 232
309 if (IsWidevineHrSupported()) 233 if (IsWidevineHrSupported())
310 AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems); 234 AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems);
311 } 235 }
312 #elif defined(OS_ANDROID) 236 #elif defined(OS_ANDROID)
313 static void AddAndroidWidevine( 237 static void AddAndroidWidevine(
314 std::vector<KeySystemInfo>* concrete_key_systems) { 238 std::vector<KeySystemInfo>* concrete_key_systems) {
315 SupportedKeySystemRequest request; 239 SupportedKeySystemRequest request;
316 SupportedKeySystemResponse response; 240 SupportedKeySystemResponse response;
317 241
318 request.key_system = kWidevineKeySystem; 242 request.key_system = kWidevineKeySystem;
319 request.codecs = static_cast<android::SupportedCodecs>(android::WEBM_CODECS | 243 request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL;
320 android::MP4_CODECS);
321 content::RenderThread::Get()->Send( 244 content::RenderThread::Get()->Send(
322 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); 245 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
323 DCHECK_EQ(response.compositing_codecs & android::INVALID_CODECS, 246 DCHECK(response.compositing_codecs & content::EME_CODEC_ALL)
324 android::NO_CODECS)
325 << "unrecognized codec"; 247 << "unrecognized codec";
326 DCHECK_EQ(response.non_compositing_codecs & android::INVALID_CODECS, 248 DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL)
327 android::NO_CODECS)
328 << "unrecognized codec"; 249 << "unrecognized codec";
329 if (response.compositing_codecs != android::NO_CODECS) { 250 if (response.compositing_codecs != content::EME_CODEC_NONE) {
330 AddWidevineWithCodecs( 251 AddWidevineWithCodecs(
331 WIDEVINE, 252 WIDEVINE,
332 static_cast<SupportedCodecs>(response.compositing_codecs), 253 static_cast<SupportedCodecs>(response.compositing_codecs),
333 concrete_key_systems); 254 concrete_key_systems);
334 } 255 }
335 256
336 if (response.non_compositing_codecs != android::NO_CODECS) { 257 if (response.non_compositing_codecs != content::EME_CODEC_NONE) {
337 AddWidevineWithCodecs( 258 AddWidevineWithCodecs(
338 WIDEVINE_HR_NON_COMPOSITING, 259 WIDEVINE_HR_NON_COMPOSITING,
339 static_cast<SupportedCodecs>(response.non_compositing_codecs), 260 static_cast<SupportedCodecs>(response.non_compositing_codecs),
340 concrete_key_systems); 261 concrete_key_systems);
341 } 262 }
342 } 263 }
343 #endif // defined(ENABLE_PEPPER_CDMS) 264 #endif // defined(ENABLE_PEPPER_CDMS)
344 #endif // defined(WIDEVINE_CDM_AVAILABLE) 265 #endif // defined(WIDEVINE_CDM_AVAILABLE)
345 266
346 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { 267 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
347 #if defined(ENABLE_PEPPER_CDMS) 268 #if defined(ENABLE_PEPPER_CDMS)
348 AddExternalClearKey(key_systems_info); 269 AddExternalClearKey(key_systems_info);
349 #endif 270 #endif
350 271
351 #if defined(WIDEVINE_CDM_AVAILABLE) 272 #if defined(WIDEVINE_CDM_AVAILABLE)
352 #if defined(ENABLE_PEPPER_CDMS) 273 #if defined(ENABLE_PEPPER_CDMS)
353 AddPepperBasedWidevine(key_systems_info); 274 AddPepperBasedWidevine(key_systems_info);
354 #elif defined(OS_ANDROID) 275 #elif defined(OS_ANDROID)
355 AddAndroidWidevine(key_systems_info); 276 AddAndroidWidevine(key_systems_info);
356 #endif 277 #endif
357 #endif 278 #endif
358 } 279 }
OLDNEW
« no previous file with comments | « chrome/common/encrypted_media_messages_android.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698