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

Side by Side Diff: media/base/key_systems.cc

Issue 1023863002: Create an interface for KeySystems, migrate WebEncryptedMediaClientImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@robustness
Patch Set: Rebase. Created 5 years, 9 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
« no previous file with comments | « media/base/key_systems.h ('k') | media/blink/webencryptedmediaclient_impl.h » ('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 "media/base/key_systems.h" 5 #include "media/base/key_systems.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // True is always returned for a |key_system| that begins with "x-". 153 // True is always returned for a |key_system| that begins with "x-".
154 // 154 //
155 // As with other web platform features, advertising support for a key system 155 // As with other web platform features, advertising support for a key system
156 // implies that it adheres to a defined and interoperable specification. 156 // implies that it adheres to a defined and interoperable specification.
157 // 157 //
158 // To ensure interoperability, implementations of a specific |key_system| string 158 // To ensure interoperability, implementations of a specific |key_system| string
159 // must conform to a specification for that identifier that defines 159 // must conform to a specification for that identifier that defines
160 // key system-specific behaviors not fully defined by the EME specification. 160 // key system-specific behaviors not fully defined by the EME specification.
161 // That specification should be provided by the owner of the domain that is the 161 // That specification should be provided by the owner of the domain that is the
162 // reverse of the |key_system| string. 162 // reverse of the |key_system| string.
163 // This involves more than calling a library, SDK, or platform API. KeySystems 163 // This involves more than calling a library, SDK, or platform API.
164 // must be populated appropriately, and there will likely be glue code to adapt 164 // KeySystemsImpl must be populated appropriately, and there will likely be glue
165 // to the API of the library, SDK, or platform API. 165 // code to adapt to the API of the library, SDK, or platform API.
166 // 166 //
167 // Chromium mainline contains this data and glue code for specific key systems, 167 // Chromium mainline contains this data and glue code for specific key systems,
168 // which should help ensure interoperability with other implementations using 168 // which should help ensure interoperability with other implementations using
169 // these key systems. 169 // these key systems.
170 // 170 //
171 // If you need to add support for other key systems, ensure that you have 171 // If you need to add support for other key systems, ensure that you have
172 // obtained the specification for how to integrate it with EME, implemented the 172 // obtained the specification for how to integrate it with EME, implemented the
173 // appropriate glue/adapter code, and added all the appropriate data to 173 // appropriate glue/adapter code, and added all the appropriate data to
174 // KeySystems. Only then should you change this function. 174 // KeySystemsImpl. Only then should you change this function.
175 static bool IsPotentiallySupportedKeySystem(const std::string& key_system) { 175 static bool IsPotentiallySupportedKeySystem(const std::string& key_system) {
176 // Known and supported key systems. 176 // Known and supported key systems.
177 if (key_system == kWidevineKeySystem) 177 if (key_system == kWidevineKeySystem)
178 return true; 178 return true;
179 if (key_system == kClearKey) 179 if (key_system == kClearKey)
180 return true; 180 return true;
181 181
182 // External Clear Key is known and supports suffixes for testing. 182 // External Clear Key is known and supports suffixes for testing.
183 if (IsExternalClearKey(key_system)) 183 if (IsExternalClearKey(key_system))
184 return true; 184 return true;
185 185
186 // Chromecast defines behaviors for Cast clients within its reverse domain. 186 // Chromecast defines behaviors for Cast clients within its reverse domain.
187 const char kChromecastRoot[] = "com.chromecast"; 187 const char kChromecastRoot[] = "com.chromecast";
188 if (IsParentKeySystemOf(kChromecastRoot, key_system)) 188 if (IsParentKeySystemOf(kChromecastRoot, key_system))
189 return true; 189 return true;
190 190
191 // Implementations that do not have a specification or appropriate glue code 191 // Implementations that do not have a specification or appropriate glue code
192 // can use the "x-" prefix to avoid conflicting with and advertising support 192 // can use the "x-" prefix to avoid conflicting with and advertising support
193 // for real key system names. Use is discouraged. 193 // for real key system names. Use is discouraged.
194 const char kExcludedPrefix[] = "x-"; 194 const char kExcludedPrefix[] = "x-";
195 if (key_system.find(kExcludedPrefix, 0, arraysize(kExcludedPrefix) - 1) == 0) 195 if (key_system.find(kExcludedPrefix, 0, arraysize(kExcludedPrefix) - 1) == 0)
196 return true; 196 return true;
197 197
198 return false; 198 return false;
199 } 199 }
200 200
201 class KeySystems { 201 class KeySystemsImpl : public KeySystems {
202 public: 202 public:
203 static KeySystems& GetInstance(); 203 static KeySystemsImpl& GetInstance();
204 204
205 void UpdateIfNeeded(); 205 void UpdateIfNeeded();
206 206
207 bool IsConcreteSupportedKeySystem(const std::string& key_system); 207 bool IsConcreteSupportedKeySystem(const std::string& key_system) const;
208
209 bool IsSupportedKeySystem(const std::string& key_system);
210 208
211 bool IsSupportedKeySystemWithInitDataType( 209 bool IsSupportedKeySystemWithInitDataType(
212 const std::string& key_system, 210 const std::string& key_system,
213 const std::string& init_data_type); 211 const std::string& init_data_type) const;
212
213 bool PrefixedIsSupportedKeySystemWithMediaMimeType(
214 const std::string& mime_type,
215 const std::vector<std::string>& codecs,
216 const std::string& key_system);
214 217
215 bool IsSupportedKeySystemWithMediaMimeType( 218 bool IsSupportedKeySystemWithMediaMimeType(
216 const std::string& mime_type, 219 const std::string& mime_type,
217 const std::vector<std::string>& codecs, 220 const std::vector<std::string>& codecs,
218 const std::string& key_system, 221 const std::string& key_system) const;
219 bool is_prefixed);
220 222
221 std::string GetKeySystemNameForUMA(const std::string& key_system) const; 223 std::string GetKeySystemNameForUMA(const std::string& key_system) const;
222 224
223 bool UseAesDecryptor(const std::string& concrete_key_system); 225 bool UseAesDecryptor(const std::string& concrete_key_system) const;
224 226
225 #if defined(ENABLE_PEPPER_CDMS) 227 #if defined(ENABLE_PEPPER_CDMS)
226 std::string GetPepperType(const std::string& concrete_key_system); 228 std::string GetPepperType(const std::string& concrete_key_system) const;
227 #endif 229 #endif
228 230
231 void AddContainerMask(const std::string& container, uint32 mask);
232 void AddCodecMask(const std::string& codec, uint32 mask);
233
234 // Implementation of KeySystems interface.
235 bool IsSupportedKeySystem(const std::string& key_system) const override;
236
237 bool IsSupportedCodecCombination(
238 const std::string& key_system,
239 EmeMediaType media_type,
240 const std::string& container_mime_type,
241 const std::vector<std::string>& codecs) const override;
242
229 EmeConfigRule GetRobustnessConfigRule( 243 EmeConfigRule GetRobustnessConfigRule(
230 const std::string& key_system, 244 const std::string& key_system,
231 EmeMediaType media_type, 245 EmeMediaType media_type,
232 const std::string& requested_robustness); 246 const std::string& requested_robustness) const override;
233 247
234 EmeConfigRule GetPersistentLicenseSessionConfigRule( 248 EmeConfigRule GetPersistentLicenseSessionConfigRule(
235 const std::string& key_system); 249 const std::string& key_system) const override;
236 250
237 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( 251 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule(
238 const std::string& key_system); 252 const std::string& key_system) const override;
239 253
240 EmeConfigRule GetPersistentStateConfigRule( 254 EmeConfigRule GetPersistentStateConfigRule(
241 const std::string& key_system, 255 const std::string& key_system,
242 EmeFeatureRequirement requirement); 256 EmeFeatureRequirement requirement) const override;
243 257
244 EmeConfigRule GetDistinctiveIdentifierConfigRule( 258 EmeConfigRule GetDistinctiveIdentifierConfigRule(
245 const std::string& key_system, 259 const std::string& key_system,
246 EmeFeatureRequirement requirement); 260 EmeFeatureRequirement requirement) const override;
247
248 void AddContainerMask(const std::string& container, uint32 mask);
249 void AddCodecMask(const std::string& codec, uint32 mask);
250 261
251 private: 262 private:
252 void InitializeUMAInfo(); 263 void InitializeUMAInfo();
253 264
254 void UpdateSupportedKeySystems(); 265 void UpdateSupportedKeySystems();
255 266
256 void AddConcreteSupportedKeySystems( 267 void AddConcreteSupportedKeySystems(
257 const std::vector<KeySystemInfo>& concrete_key_systems); 268 const std::vector<KeySystemInfo>& concrete_key_systems);
258 269
259 friend struct base::DefaultLazyInstanceTraits<KeySystems>; 270 friend struct base::DefaultLazyInstanceTraits<KeySystemsImpl>;
260 271
261 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; 272 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap;
262 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; 273 typedef base::hash_map<std::string, std::string> ParentKeySystemMap;
263 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; 274 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap;
264 typedef base::hash_map<std::string, EmeCodec> CodecsMap; 275 typedef base::hash_map<std::string, EmeCodec> CodecsMap;
265 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; 276 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap;
266 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; 277 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap;
267 278
268 KeySystems(); 279 KeySystemsImpl();
269 ~KeySystems() {} 280 ~KeySystemsImpl() {}
270 281
271 EmeInitDataType GetInitDataTypeForName( 282 EmeInitDataType GetInitDataTypeForName(
272 const std::string& init_data_type) const; 283 const std::string& init_data_type) const;
273 // TODO(sandersd): Separate container enum from codec mask value. 284 // TODO(sandersd): Separate container enum from codec mask value.
274 // http://crbug.com/417440 285 // http://crbug.com/417440
275 SupportedCodecs GetCodecMaskForContainer( 286 SupportedCodecs GetCodecMaskForContainer(
276 const std::string& container) const; 287 const std::string& container) const;
277 EmeCodec GetCodecForString(const std::string& codec) const; 288 EmeCodec GetCodecForString(const std::string& codec) const;
278 289
279 const std::string& PrefixedGetConcreteKeySystemNameFor( 290 const std::string& PrefixedGetConcreteKeySystemNameFor(
(...skipping 22 matching lines...) Expand all
302 KeySystemsSupportUMA key_systems_support_uma_; 313 KeySystemsSupportUMA key_systems_support_uma_;
303 314
304 InitDataTypesMap init_data_type_name_map_; 315 InitDataTypesMap init_data_type_name_map_;
305 ContainerCodecsMap container_to_codec_mask_map_; 316 ContainerCodecsMap container_to_codec_mask_map_;
306 CodecsMap codec_string_map_; 317 CodecsMap codec_string_map_;
307 KeySystemNameForUMAMap key_system_name_for_uma_map_; 318 KeySystemNameForUMAMap key_system_name_for_uma_map_;
308 319
309 // Makes sure all methods are called from the same thread. 320 // Makes sure all methods are called from the same thread.
310 base::ThreadChecker thread_checker_; 321 base::ThreadChecker thread_checker_;
311 322
312 DISALLOW_COPY_AND_ASSIGN(KeySystems); 323 DISALLOW_COPY_AND_ASSIGN(KeySystemsImpl);
313 }; 324 };
314 325
315 static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; 326 static base::LazyInstance<KeySystemsImpl> g_key_systems =
327 LAZY_INSTANCE_INITIALIZER;
316 328
317 KeySystems& KeySystems::GetInstance() { 329 KeySystemsImpl& KeySystemsImpl::GetInstance() {
318 KeySystems& key_systems = g_key_systems.Get(); 330 KeySystemsImpl& key_systems = g_key_systems.Get();
319 key_systems.UpdateIfNeeded(); 331 key_systems.UpdateIfNeeded();
320 return key_systems; 332 return key_systems;
321 } 333 }
322 334
323 // Because we use a LazyInstance, the key systems info must be populated when 335 // Because we use a LazyInstance, the key systems info must be populated when
324 // the instance is lazily initiated. 336 // the instance is lazily initiated.
325 KeySystems::KeySystems() { 337 KeySystemsImpl::KeySystemsImpl() {
326 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { 338 for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) {
327 const std::string& name = kInitDataTypeNames[i].name; 339 const std::string& name = kInitDataTypeNames[i].name;
328 DCHECK(!init_data_type_name_map_.count(name)); 340 DCHECK(!init_data_type_name_map_.count(name));
329 init_data_type_name_map_[name] = kInitDataTypeNames[i].type; 341 init_data_type_name_map_[name] = kInitDataTypeNames[i].type;
330 } 342 }
331 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { 343 for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) {
332 const std::string& name = kContainerToCodecMasks[i].name; 344 const std::string& name = kContainerToCodecMasks[i].name;
333 DCHECK(!container_to_codec_mask_map_.count(name)); 345 DCHECK(!container_to_codec_mask_map_.count(name));
334 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type; 346 container_to_codec_mask_map_[name] = kContainerToCodecMasks[i].type;
335 } 347 }
336 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) { 348 for (size_t i = 0; i < arraysize(kCodecStrings); ++i) {
337 const std::string& name = kCodecStrings[i].name; 349 const std::string& name = kCodecStrings[i].name;
338 DCHECK(!codec_string_map_.count(name)); 350 DCHECK(!codec_string_map_.count(name));
339 codec_string_map_[name] = kCodecStrings[i].type; 351 codec_string_map_[name] = kCodecStrings[i].type;
340 } 352 }
341 353
342 InitializeUMAInfo(); 354 InitializeUMAInfo();
343 355
344 // Always update supported key systems during construction. 356 // Always update supported key systems during construction.
345 UpdateSupportedKeySystems(); 357 UpdateSupportedKeySystems();
346 } 358 }
347 359
348 EmeInitDataType KeySystems::GetInitDataTypeForName( 360 EmeInitDataType KeySystemsImpl::GetInitDataTypeForName(
349 const std::string& init_data_type) const { 361 const std::string& init_data_type) const {
350 InitDataTypesMap::const_iterator iter = 362 InitDataTypesMap::const_iterator iter =
351 init_data_type_name_map_.find(init_data_type); 363 init_data_type_name_map_.find(init_data_type);
352 if (iter != init_data_type_name_map_.end()) 364 if (iter != init_data_type_name_map_.end())
353 return iter->second; 365 return iter->second;
354 return EME_INIT_DATA_TYPE_NONE; 366 return EME_INIT_DATA_TYPE_NONE;
355 } 367 }
356 368
357 SupportedCodecs KeySystems::GetCodecMaskForContainer( 369 SupportedCodecs KeySystemsImpl::GetCodecMaskForContainer(
358 const std::string& container) const { 370 const std::string& container) const {
359 ContainerCodecsMap::const_iterator iter = 371 ContainerCodecsMap::const_iterator iter =
360 container_to_codec_mask_map_.find(container); 372 container_to_codec_mask_map_.find(container);
361 if (iter != container_to_codec_mask_map_.end()) 373 if (iter != container_to_codec_mask_map_.end())
362 return iter->second; 374 return iter->second;
363 return EME_CODEC_NONE; 375 return EME_CODEC_NONE;
364 } 376 }
365 377
366 EmeCodec KeySystems::GetCodecForString(const std::string& codec) const { 378 EmeCodec KeySystemsImpl::GetCodecForString(const std::string& codec) const {
367 CodecsMap::const_iterator iter = codec_string_map_.find(codec); 379 CodecsMap::const_iterator iter = codec_string_map_.find(codec);
368 if (iter != codec_string_map_.end()) 380 if (iter != codec_string_map_.end())
369 return iter->second; 381 return iter->second;
370 return EME_CODEC_NONE; 382 return EME_CODEC_NONE;
371 } 383 }
372 384
373 const std::string& KeySystems::PrefixedGetConcreteKeySystemNameFor( 385 const std::string& KeySystemsImpl::PrefixedGetConcreteKeySystemNameFor(
374 const std::string& key_system) const { 386 const std::string& key_system) const {
375 ParentKeySystemMap::const_iterator iter = 387 ParentKeySystemMap::const_iterator iter =
376 parent_key_system_map_.find(key_system); 388 parent_key_system_map_.find(key_system);
377 if (iter != parent_key_system_map_.end()) 389 if (iter != parent_key_system_map_.end())
378 return iter->second; 390 return iter->second;
379 return key_system; 391 return key_system;
380 } 392 }
381 393
382 void KeySystems::InitializeUMAInfo() { 394 void KeySystemsImpl::InitializeUMAInfo() {
383 DCHECK(thread_checker_.CalledOnValidThread()); 395 DCHECK(thread_checker_.CalledOnValidThread());
384 DCHECK(key_system_name_for_uma_map_.empty()); 396 DCHECK(key_system_name_for_uma_map_.empty());
385 397
386 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma; 398 std::vector<KeySystemInfoForUMA> key_systems_info_for_uma;
387 if (GetMediaClient()) 399 if (GetMediaClient())
388 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma); 400 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma);
389 401
390 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) { 402 for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) {
391 key_system_name_for_uma_map_[info.key_system] = 403 key_system_name_for_uma_map_[info.key_system] =
392 info.key_system_name_for_uma; 404 info.key_system_name_for_uma;
393 if (info.reports_key_system_support_to_uma) 405 if (info.reports_key_system_support_to_uma)
394 key_systems_support_uma_.AddKeySystemToReport(info.key_system); 406 key_systems_support_uma_.AddKeySystemToReport(info.key_system);
395 } 407 }
396 408
397 // Clear Key is always supported. 409 // Clear Key is always supported.
398 key_system_name_for_uma_map_[kClearKeyKeySystem] = 410 key_system_name_for_uma_map_[kClearKeyKeySystem] =
399 kClearKeyKeySystemNameForUMA; 411 kClearKeyKeySystemNameForUMA;
400 } 412 }
401 413
402 void KeySystems::UpdateIfNeeded() { 414 void KeySystemsImpl::UpdateIfNeeded() {
403 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded()) 415 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded())
404 UpdateSupportedKeySystems(); 416 UpdateSupportedKeySystems();
405 } 417 }
406 418
407 void KeySystems::UpdateSupportedKeySystems() { 419 void KeySystemsImpl::UpdateSupportedKeySystems() {
408 DCHECK(thread_checker_.CalledOnValidThread()); 420 DCHECK(thread_checker_.CalledOnValidThread());
409 concrete_key_system_map_.clear(); 421 concrete_key_system_map_.clear();
410 parent_key_system_map_.clear(); 422 parent_key_system_map_.clear();
411 423
412 // Build KeySystemInfo. 424 // Build KeySystemInfo.
413 std::vector<KeySystemInfo> key_systems_info; 425 std::vector<KeySystemInfo> key_systems_info;
414 426
415 // Add key systems supported by the MediaClient implementation. 427 // Add key systems supported by the MediaClient implementation.
416 if (GetMediaClient()) 428 if (GetMediaClient())
417 GetMediaClient()->AddSupportedKeySystems(&key_systems_info); 429 GetMediaClient()->AddSupportedKeySystems(&key_systems_info);
418 430
419 // Clear Key is always supported. 431 // Clear Key is always supported.
420 AddClearKey(&key_systems_info); 432 AddClearKey(&key_systems_info);
421 433
422 AddConcreteSupportedKeySystems(key_systems_info); 434 AddConcreteSupportedKeySystems(key_systems_info);
423 } 435 }
424 436
425 void KeySystems::AddConcreteSupportedKeySystems( 437 void KeySystemsImpl::AddConcreteSupportedKeySystems(
426 const std::vector<KeySystemInfo>& concrete_key_systems) { 438 const std::vector<KeySystemInfo>& concrete_key_systems) {
427 DCHECK(thread_checker_.CalledOnValidThread()); 439 DCHECK(thread_checker_.CalledOnValidThread());
428 DCHECK(concrete_key_system_map_.empty()); 440 DCHECK(concrete_key_system_map_.empty());
429 DCHECK(parent_key_system_map_.empty()); 441 DCHECK(parent_key_system_map_.empty());
430 442
431 for (const KeySystemInfo& info : concrete_key_systems) { 443 for (const KeySystemInfo& info : concrete_key_systems) {
432 DCHECK(!info.key_system.empty()); 444 DCHECK(!info.key_system.empty());
433 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); 445 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID);
434 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); 446 DCHECK(info.max_video_robustness != EmeRobustness::INVALID);
435 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID); 447 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) 511 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system))
500 << "Parent '" << info.parent_key_system << "' " 512 << "Parent '" << info.parent_key_system << "' "
501 << "already registered concrete"; 513 << "already registered concrete";
502 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) 514 DCHECK(!parent_key_system_map_.count(info.parent_key_system))
503 << "Parent '" << info.parent_key_system << "' already registered"; 515 << "Parent '" << info.parent_key_system << "' already registered";
504 parent_key_system_map_[info.parent_key_system] = info.key_system; 516 parent_key_system_map_[info.parent_key_system] = info.key_system;
505 } 517 }
506 } 518 }
507 } 519 }
508 520
509 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { 521 bool KeySystemsImpl::IsConcreteSupportedKeySystem(
522 const std::string& key_system) const {
510 DCHECK(thread_checker_.CalledOnValidThread()); 523 DCHECK(thread_checker_.CalledOnValidThread());
511 return concrete_key_system_map_.count(key_system) != 0; 524 return concrete_key_system_map_.count(key_system) != 0;
512 } 525 }
513 526
514 bool KeySystems::IsSupportedContainer( 527 bool KeySystemsImpl::IsSupportedContainer(
515 const std::string& container, 528 const std::string& container,
516 SupportedCodecs key_system_supported_codecs) const { 529 SupportedCodecs key_system_supported_codecs) const {
517 DCHECK(thread_checker_.CalledOnValidThread()); 530 DCHECK(thread_checker_.CalledOnValidThread());
518 DCHECK(!container.empty()); 531 DCHECK(!container.empty());
519 532
520 // When checking container support for EME, "audio/foo" should be treated the 533 // When checking container support for EME, "audio/foo" should be treated the
521 // same as "video/foo". Convert the |container| to achieve this. 534 // same as "video/foo". Convert the |container| to achieve this.
522 // TODO(xhwang): Replace this with real checks against supported initDataTypes 535 // TODO(xhwang): Replace this with real checks against supported initDataTypes
523 // combined with supported demuxers. 536 // combined with supported demuxers.
524 std::string canonical_container = container; 537 std::string canonical_container = container;
525 if (container.find("audio/") == 0) 538 if (container.find("audio/") == 0)
526 canonical_container.replace(0, 6, "video/"); 539 canonical_container.replace(0, 6, "video/");
527 540
528 // A container is supported iif at least one codec in that container is 541 // A container is supported iif at least one codec in that container is
529 // supported. 542 // supported.
530 SupportedCodecs supported_codecs = 543 SupportedCodecs supported_codecs =
531 GetCodecMaskForContainer(canonical_container); 544 GetCodecMaskForContainer(canonical_container);
532 return (supported_codecs & key_system_supported_codecs) != 0; 545 return (supported_codecs & key_system_supported_codecs) != 0;
533 } 546 }
534 547
535 bool KeySystems::IsSupportedContainerAndCodecs( 548 bool KeySystemsImpl::IsSupportedContainerAndCodecs(
536 const std::string& container, 549 const std::string& container,
537 const std::vector<std::string>& codecs, 550 const std::vector<std::string>& codecs,
538 SupportedCodecs key_system_supported_codecs) const { 551 SupportedCodecs key_system_supported_codecs) const {
539 DCHECK(thread_checker_.CalledOnValidThread()); 552 DCHECK(thread_checker_.CalledOnValidThread());
540 DCHECK(!container.empty()); 553 DCHECK(!container.empty());
541 DCHECK(!codecs.empty()); 554 DCHECK(!codecs.empty());
542 DCHECK(IsSupportedContainer(container, key_system_supported_codecs)); 555 DCHECK(IsSupportedContainer(container, key_system_supported_codecs));
543 556
544 SupportedCodecs container_supported_codecs = 557 SupportedCodecs container_supported_codecs =
545 GetCodecMaskForContainer(container); 558 GetCodecMaskForContainer(container);
(...skipping 11 matching lines...) Expand all
557 return false; 570 return false;
558 571
559 // Unsupported codec/container combination, e.g. "video/webm" and "avc1". 572 // Unsupported codec/container combination, e.g. "video/webm" and "avc1".
560 if (!(codec & container_supported_codecs)) 573 if (!(codec & container_supported_codecs))
561 return false; 574 return false;
562 } 575 }
563 576
564 return true; 577 return true;
565 } 578 }
566 579
567 bool KeySystems::IsSupportedKeySystem(const std::string& key_system) { 580 bool KeySystemsImpl::IsSupportedKeySystemWithInitDataType(
568 DCHECK(thread_checker_.CalledOnValidThread());
569 // Unprefixed EME only supports concrete key systems.
570 return concrete_key_system_map_.count(key_system) != 0;
571 }
572
573 bool KeySystems::IsSupportedKeySystemWithInitDataType(
574 const std::string& key_system, 581 const std::string& key_system,
575 const std::string& init_data_type) { 582 const std::string& init_data_type) const {
576 DCHECK(thread_checker_.CalledOnValidThread()); 583 DCHECK(thread_checker_.CalledOnValidThread());
577 584
578 // Locate |key_system|. Only concrete key systems are supported in unprefixed. 585 // Locate |key_system|. Only concrete key systems are supported in unprefixed.
579 KeySystemInfoMap::const_iterator key_system_iter = 586 KeySystemInfoMap::const_iterator key_system_iter =
580 concrete_key_system_map_.find(key_system); 587 concrete_key_system_map_.find(key_system);
581 if (key_system_iter == concrete_key_system_map_.end()) 588 if (key_system_iter == concrete_key_system_map_.end())
582 return false; 589 return false;
583 590
584 // Check |init_data_type| and |key_system| x |init_data_type|. 591 // Check |init_data_type| and |key_system| x |init_data_type|.
585 const KeySystemInfo& info = key_system_iter->second; 592 const KeySystemInfo& info = key_system_iter->second;
586 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); 593 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type);
587 return (info.supported_init_data_types & eme_init_data_type) != 0; 594 return (info.supported_init_data_types & eme_init_data_type) != 0;
588 } 595 }
589 596
590 // TODO(sandersd): Reorganize to be more similar to 597 bool KeySystemsImpl::PrefixedIsSupportedKeySystemWithMediaMimeType(
591 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be
592 // required; http://crbug.com/417461.
593 bool KeySystems::IsSupportedKeySystemWithMediaMimeType(
594 const std::string& mime_type, 598 const std::string& mime_type,
595 const std::vector<std::string>& codecs, 599 const std::vector<std::string>& codecs,
596 const std::string& key_system, 600 const std::string& key_system) {
597 bool is_prefixed) {
598 DCHECK(thread_checker_.CalledOnValidThread()); 601 DCHECK(thread_checker_.CalledOnValidThread());
599 const bool report_to_uma = is_prefixed;
600 602
601 // If |is_prefixed| and |key_system| is a parent key system, use its concrete 603 const std::string& concrete_key_system =
602 // child. 604 PrefixedGetConcreteKeySystemNameFor(key_system);
603 const std::string& concrete_key_system = is_prefixed ?
604 PrefixedGetConcreteKeySystemNameFor(key_system) :
605 key_system;
606 605
607 bool has_type = !mime_type.empty(); 606 bool has_type = !mime_type.empty();
608 607
609 if (report_to_uma) 608 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type);
610 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type);
611 609
612 // Check key system support. 610 // Check key system support.
613 KeySystemInfoMap::const_iterator key_system_iter = 611 KeySystemInfoMap::const_iterator key_system_iter =
614 concrete_key_system_map_.find(concrete_key_system); 612 concrete_key_system_map_.find(concrete_key_system);
615 if (key_system_iter == concrete_key_system_map_.end()) 613 if (key_system_iter == concrete_key_system_map_.end())
616 return false; 614 return false;
617 615
618 if (report_to_uma) 616 key_systems_support_uma_.ReportKeySystemSupport(key_system, false);
619 key_systems_support_uma_.ReportKeySystemSupport(key_system, false);
620 617
621 if (!has_type) { 618 if (!has_type) {
622 DCHECK(codecs.empty()); 619 DCHECK(codecs.empty());
623 return true; 620 return true;
624 } 621 }
625 622
626 SupportedCodecs key_system_supported_codecs = 623 SupportedCodecs key_system_supported_codecs =
627 key_system_iter->second.supported_codecs; 624 key_system_iter->second.supported_codecs;
628 625
629 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) 626 if (!IsSupportedContainer(mime_type, key_system_supported_codecs))
630 return false; 627 return false;
631 628
632 if (!codecs.empty() && 629 if (!codecs.empty() &&
633 !IsSupportedContainerAndCodecs( 630 !IsSupportedContainerAndCodecs(
634 mime_type, codecs, key_system_supported_codecs)) { 631 mime_type, codecs, key_system_supported_codecs)) {
635 return false; 632 return false;
636 } 633 }
637 634
638 if (report_to_uma) 635 key_systems_support_uma_.ReportKeySystemSupport(key_system, true);
639 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); 636
640 return true; 637 return true;
641 } 638 }
642 639
643 std::string KeySystems::GetKeySystemNameForUMA( 640 bool KeySystemsImpl::IsSupportedKeySystemWithMediaMimeType(
641 const std::string& mime_type,
642 const std::vector<std::string>& codecs,
644 const std::string& key_system) const { 643 const std::string& key_system) const {
645 DCHECK(thread_checker_.CalledOnValidThread()); 644 DCHECK(thread_checker_.CalledOnValidThread());
646 645
646 KeySystemInfoMap::const_iterator key_system_iter =
647 concrete_key_system_map_.find(key_system);
648 if (key_system_iter == concrete_key_system_map_.end())
649 return false;
650
651 if (mime_type.empty()) {
652 DCHECK(codecs.empty());
653 return true;
654 }
655
656 SupportedCodecs key_system_supported_codecs =
657 key_system_iter->second.supported_codecs;
658
659 if (!IsSupportedContainer(mime_type, key_system_supported_codecs))
660 return false;
661
662 if (!codecs.empty() &&
663 !IsSupportedContainerAndCodecs(
664 mime_type, codecs, key_system_supported_codecs)) {
665 return false;
666 }
667
668 return true;
669 }
670
671 std::string KeySystemsImpl::GetKeySystemNameForUMA(
672 const std::string& key_system) const {
673 DCHECK(thread_checker_.CalledOnValidThread());
674
647 KeySystemNameForUMAMap::const_iterator iter = 675 KeySystemNameForUMAMap::const_iterator iter =
648 key_system_name_for_uma_map_.find(key_system); 676 key_system_name_for_uma_map_.find(key_system);
649 if (iter == key_system_name_for_uma_map_.end()) 677 if (iter == key_system_name_for_uma_map_.end())
650 return kUnknownKeySystemNameForUMA; 678 return kUnknownKeySystemNameForUMA;
651 679
652 return iter->second; 680 return iter->second;
653 } 681 }
654 682
655 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { 683 bool KeySystemsImpl::UseAesDecryptor(
684 const std::string& concrete_key_system) const {
656 DCHECK(thread_checker_.CalledOnValidThread()); 685 DCHECK(thread_checker_.CalledOnValidThread());
657 686
658 KeySystemInfoMap::const_iterator key_system_iter = 687 KeySystemInfoMap::const_iterator key_system_iter =
659 concrete_key_system_map_.find(concrete_key_system); 688 concrete_key_system_map_.find(concrete_key_system);
660 if (key_system_iter == concrete_key_system_map_.end()) { 689 if (key_system_iter == concrete_key_system_map_.end()) {
661 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 690 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
662 return false; 691 return false;
663 } 692 }
664 693
665 return key_system_iter->second.use_aes_decryptor; 694 return key_system_iter->second.use_aes_decryptor;
666 } 695 }
667 696
668 #if defined(ENABLE_PEPPER_CDMS) 697 #if defined(ENABLE_PEPPER_CDMS)
669 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { 698 std::string KeySystemsImpl::GetPepperType(
699 const std::string& concrete_key_system) const {
670 DCHECK(thread_checker_.CalledOnValidThread()); 700 DCHECK(thread_checker_.CalledOnValidThread());
671 701
672 KeySystemInfoMap::const_iterator key_system_iter = 702 KeySystemInfoMap::const_iterator key_system_iter =
673 concrete_key_system_map_.find(concrete_key_system); 703 concrete_key_system_map_.find(concrete_key_system);
674 if (key_system_iter == concrete_key_system_map_.end()) { 704 if (key_system_iter == concrete_key_system_map_.end()) {
675 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 705 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
676 return std::string(); 706 return std::string();
677 } 707 }
678 708
679 const std::string& type = key_system_iter->second.pepper_type; 709 const std::string& type = key_system_iter->second.pepper_type;
680 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; 710 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based";
681 return type; 711 return type;
682 } 712 }
683 #endif 713 #endif
684 714
685 EmeConfigRule KeySystems::GetRobustnessConfigRule( 715 void KeySystemsImpl::AddContainerMask(const std::string& container,
716 uint32 mask) {
717 DCHECK(thread_checker_.CalledOnValidThread());
718 DCHECK(!container_to_codec_mask_map_.count(container));
719 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask);
720 }
721
722 void KeySystemsImpl::AddCodecMask(const std::string& codec, uint32 mask) {
723 DCHECK(thread_checker_.CalledOnValidThread());
724 DCHECK(!codec_string_map_.count(codec));
725 codec_string_map_[codec] = static_cast<EmeCodec>(mask);
726 }
727
728 bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) const {
729 DCHECK(thread_checker_.CalledOnValidThread());
730 return concrete_key_system_map_.count(key_system) != 0;
731 }
732
733 // TODO(sandersd): Make sure that the codecs also match the |media_type|.
734 // http://crbug.com/457386
735 bool KeySystemsImpl::IsSupportedCodecCombination(
686 const std::string& key_system, 736 const std::string& key_system,
687 EmeMediaType media_type, 737 EmeMediaType media_type,
688 const std::string& requested_robustness) { 738 const std::string& container_mime_type,
739 const std::vector<std::string>& codecs) const {
740 // Make sure the container matches |media_type|.
741 switch (media_type) {
742 case EmeMediaType::AUDIO:
743 if (!StartsWithASCII(container_mime_type, "audio/", true))
744 return false;
745 break;
746 case EmeMediaType::VIDEO:
747 if (!StartsWithASCII(container_mime_type, "video/", true))
748 return false;
749 break;
750 }
751 return IsSupportedKeySystemWithMediaMimeType(
752 container_mime_type, codecs, key_system);
753 }
754
755 EmeConfigRule KeySystemsImpl::GetRobustnessConfigRule(
756 const std::string& key_system,
757 EmeMediaType media_type,
758 const std::string& requested_robustness) const {
689 DCHECK(thread_checker_.CalledOnValidThread()); 759 DCHECK(thread_checker_.CalledOnValidThread());
690 760
691 EmeRobustness robustness = ConvertRobustness(requested_robustness); 761 EmeRobustness robustness = ConvertRobustness(requested_robustness);
692 if (robustness == EmeRobustness::INVALID) 762 if (robustness == EmeRobustness::INVALID)
693 return EmeConfigRule::NOT_SUPPORTED; 763 return EmeConfigRule::NOT_SUPPORTED;
694 if (robustness == EmeRobustness::EMPTY) 764 if (robustness == EmeRobustness::EMPTY)
695 return EmeConfigRule::SUPPORTED; 765 return EmeConfigRule::SUPPORTED;
696 766
697 KeySystemInfoMap::const_iterator key_system_iter = 767 KeySystemInfoMap::const_iterator key_system_iter =
698 concrete_key_system_map_.find(key_system); 768 concrete_key_system_map_.find(key_system);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (media_type == EmeMediaType::VIDEO && 805 if (media_type == EmeMediaType::VIDEO &&
736 max_robustness == EmeRobustness::HW_SECURE_ALL) { 806 max_robustness == EmeRobustness::HW_SECURE_ALL) {
737 return EmeConfigRule::IDENTIFIER_RECOMMENDED; 807 return EmeConfigRule::IDENTIFIER_RECOMMENDED;
738 } 808 }
739 } 809 }
740 #endif // defined(OS_CHROMEOS) 810 #endif // defined(OS_CHROMEOS)
741 811
742 return EmeConfigRule::SUPPORTED; 812 return EmeConfigRule::SUPPORTED;
743 } 813 }
744 814
745 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( 815 EmeConfigRule KeySystemsImpl::GetPersistentLicenseSessionConfigRule(
746 const std::string& key_system) { 816 const std::string& key_system) const {
747 DCHECK(thread_checker_.CalledOnValidThread()); 817 DCHECK(thread_checker_.CalledOnValidThread());
748 818
749 KeySystemInfoMap::const_iterator key_system_iter = 819 KeySystemInfoMap::const_iterator key_system_iter =
750 concrete_key_system_map_.find(key_system); 820 concrete_key_system_map_.find(key_system);
751 if (key_system_iter == concrete_key_system_map_.end()) { 821 if (key_system_iter == concrete_key_system_map_.end()) {
752 NOTREACHED(); 822 NOTREACHED();
753 return EmeConfigRule::NOT_SUPPORTED; 823 return EmeConfigRule::NOT_SUPPORTED;
754 } 824 }
755 return ConvertSessionTypeSupport( 825 return ConvertSessionTypeSupport(
756 key_system_iter->second.persistent_license_support); 826 key_system_iter->second.persistent_license_support);
757 } 827 }
758 828
759 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( 829 EmeConfigRule KeySystemsImpl::GetPersistentReleaseMessageSessionConfigRule(
760 const std::string& key_system) { 830 const std::string& key_system) const {
761 DCHECK(thread_checker_.CalledOnValidThread()); 831 DCHECK(thread_checker_.CalledOnValidThread());
762 832
763 KeySystemInfoMap::const_iterator key_system_iter = 833 KeySystemInfoMap::const_iterator key_system_iter =
764 concrete_key_system_map_.find(key_system); 834 concrete_key_system_map_.find(key_system);
765 if (key_system_iter == concrete_key_system_map_.end()) { 835 if (key_system_iter == concrete_key_system_map_.end()) {
766 NOTREACHED(); 836 NOTREACHED();
767 return EmeConfigRule::NOT_SUPPORTED; 837 return EmeConfigRule::NOT_SUPPORTED;
768 } 838 }
769 return ConvertSessionTypeSupport( 839 return ConvertSessionTypeSupport(
770 key_system_iter->second.persistent_release_message_support); 840 key_system_iter->second.persistent_release_message_support);
771 } 841 }
772 842
773 EmeConfigRule KeySystems::GetPersistentStateConfigRule( 843 EmeConfigRule KeySystemsImpl::GetPersistentStateConfigRule(
774 const std::string& key_system, 844 const std::string& key_system,
775 EmeFeatureRequirement requirement) { 845 EmeFeatureRequirement requirement) const {
776 DCHECK(thread_checker_.CalledOnValidThread()); 846 DCHECK(thread_checker_.CalledOnValidThread());
777 847
778 KeySystemInfoMap::const_iterator key_system_iter = 848 KeySystemInfoMap::const_iterator key_system_iter =
779 concrete_key_system_map_.find(key_system); 849 concrete_key_system_map_.find(key_system);
780 if (key_system_iter == concrete_key_system_map_.end()) { 850 if (key_system_iter == concrete_key_system_map_.end()) {
781 NOTREACHED(); 851 NOTREACHED();
782 return EmeConfigRule::NOT_SUPPORTED; 852 return EmeConfigRule::NOT_SUPPORTED;
783 } 853 }
784 854
785 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we 855 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we
(...skipping 19 matching lines...) Expand all
805 requirement == EME_FEATURE_NOT_ALLOWED) { 875 requirement == EME_FEATURE_NOT_ALLOWED) {
806 return EmeConfigRule::NOT_SUPPORTED; 876 return EmeConfigRule::NOT_SUPPORTED;
807 } 877 }
808 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && 878 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER &&
809 requirement == EME_FEATURE_REQUIRED) { 879 requirement == EME_FEATURE_REQUIRED) {
810 return EmeConfigRule::IDENTIFIER_REQUIRED; 880 return EmeConfigRule::IDENTIFIER_REQUIRED;
811 } 881 }
812 return EmeConfigRule::SUPPORTED; 882 return EmeConfigRule::SUPPORTED;
813 } 883 }
814 884
815 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( 885 EmeConfigRule KeySystemsImpl::GetDistinctiveIdentifierConfigRule(
816 const std::string& key_system, 886 const std::string& key_system,
817 EmeFeatureRequirement requirement) { 887 EmeFeatureRequirement requirement) const {
818 DCHECK(thread_checker_.CalledOnValidThread()); 888 DCHECK(thread_checker_.CalledOnValidThread());
819 889
820 KeySystemInfoMap::const_iterator key_system_iter = 890 KeySystemInfoMap::const_iterator key_system_iter =
821 concrete_key_system_map_.find(key_system); 891 concrete_key_system_map_.find(key_system);
822 if (key_system_iter == concrete_key_system_map_.end()) { 892 if (key_system_iter == concrete_key_system_map_.end()) {
823 NOTREACHED(); 893 NOTREACHED();
824 return EmeConfigRule::NOT_SUPPORTED; 894 return EmeConfigRule::NOT_SUPPORTED;
825 } 895 }
826 896
827 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, 897 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL,
(...skipping 15 matching lines...) Expand all
843 requirement == EME_FEATURE_NOT_ALLOWED) { 913 requirement == EME_FEATURE_NOT_ALLOWED) {
844 return EmeConfigRule::NOT_SUPPORTED; 914 return EmeConfigRule::NOT_SUPPORTED;
845 } 915 }
846 if (support == EME_FEATURE_ALWAYS_ENABLED || 916 if (support == EME_FEATURE_ALWAYS_ENABLED ||
847 requirement == EME_FEATURE_REQUIRED) { 917 requirement == EME_FEATURE_REQUIRED) {
848 return EmeConfigRule::IDENTIFIER_REQUIRED; 918 return EmeConfigRule::IDENTIFIER_REQUIRED;
849 } 919 }
850 return EmeConfigRule::SUPPORTED; 920 return EmeConfigRule::SUPPORTED;
851 } 921 }
852 922
853 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { 923 KeySystems& KeySystems::GetInstance() {
854 DCHECK(thread_checker_.CalledOnValidThread()); 924 return KeySystemsImpl::GetInstance();
855 DCHECK(!container_to_codec_mask_map_.count(container));
856 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask);
857 }
858
859 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) {
860 DCHECK(thread_checker_.CalledOnValidThread());
861 DCHECK(!codec_string_map_.count(codec));
862 codec_string_map_[codec] = static_cast<EmeCodec>(mask);
863 } 925 }
864 926
865 //------------------------------------------------------------------------------ 927 //------------------------------------------------------------------------------
866 928
867 std::string GetUnprefixedKeySystemName(const std::string& key_system) { 929 std::string GetUnprefixedKeySystemName(const std::string& key_system) {
868 if (key_system == kClearKeyKeySystem) 930 if (key_system == kClearKeyKeySystem)
869 return kUnsupportedClearKeyKeySystem; 931 return kUnsupportedClearKeyKeySystem;
870 932
871 if (key_system == kPrefixedClearKeyKeySystem) 933 if (key_system == kPrefixedClearKeyKeySystem)
872 return kClearKeyKeySystem; 934 return kClearKeyKeySystem;
(...skipping 16 matching lines...) Expand all
889 if (init_data_type == "cenc") { 951 if (init_data_type == "cenc") {
890 return container == "audio/mp4" || container == "video/mp4"; 952 return container == "audio/mp4" || container == "video/mp4";
891 } else if (init_data_type == "webm") { 953 } else if (init_data_type == "webm") {
892 return container == "audio/webm" || container == "video/webm"; 954 return container == "audio/webm" || container == "video/webm";
893 } else { 955 } else {
894 return true; 956 return true;
895 } 957 }
896 } 958 }
897 959
898 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) { 960 bool PrefixedIsSupportedConcreteKeySystem(const std::string& key_system) {
899 return KeySystems::GetInstance().IsConcreteSupportedKeySystem(key_system); 961 return KeySystemsImpl::GetInstance().IsConcreteSupportedKeySystem(key_system);
900 } 962 }
901 963
902 bool IsSupportedKeySystem(const std::string& key_system) { 964 bool IsSupportedKeySystem(const std::string& key_system) {
903 if (!KeySystems::GetInstance().IsSupportedKeySystem(key_system)) 965 if (!KeySystemsImpl::GetInstance().IsSupportedKeySystem(key_system))
904 return false; 966 return false;
905 967
906 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is 968 // TODO(ddorwin): Move this to where we add key systems when prefixed EME is
907 // removed (crbug.com/249976). 969 // removed (crbug.com/249976).
908 if (!IsPotentiallySupportedKeySystem(key_system)) { 970 if (!IsPotentiallySupportedKeySystem(key_system)) {
909 // If you encounter this path, see the comments for the above function. 971 // If you encounter this path, see the comments for the above function.
910 NOTREACHED() << "Unrecognized key system " << key_system 972 NOTREACHED() << "Unrecognized key system " << key_system
911 << ". See code comments."; 973 << ". See code comments.";
912 return false; 974 return false;
913 } 975 }
914 976
915 return true; 977 return true;
916 } 978 }
917 979
918 bool IsSupportedKeySystemWithInitDataType( 980 bool IsSupportedKeySystemWithInitDataType(
919 const std::string& key_system, 981 const std::string& key_system,
920 const std::string& init_data_type) { 982 const std::string& init_data_type) {
921 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType( 983 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithInitDataType(
922 key_system, init_data_type); 984 key_system, init_data_type);
923 } 985 }
924 986
925 bool IsSupportedKeySystemWithMediaMimeType( 987 bool IsSupportedKeySystemWithMediaMimeType(
926 const std::string& mime_type, 988 const std::string& mime_type,
927 const std::vector<std::string>& codecs, 989 const std::vector<std::string>& codecs,
928 const std::string& key_system) { 990 const std::string& key_system) {
929 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( 991 return KeySystemsImpl::GetInstance().IsSupportedKeySystemWithMediaMimeType(
930 mime_type, codecs, key_system, false); 992 mime_type, codecs, key_system);
931 } 993 }
932 994
933 bool PrefixedIsSupportedKeySystemWithMediaMimeType( 995 bool PrefixedIsSupportedKeySystemWithMediaMimeType(
934 const std::string& mime_type, 996 const std::string& mime_type,
935 const std::vector<std::string>& codecs, 997 const std::vector<std::string>& codecs,
936 const std::string& key_system) { 998 const std::string& key_system) {
937 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( 999 return KeySystemsImpl::GetInstance()
938 mime_type, codecs, key_system, true); 1000 .PrefixedIsSupportedKeySystemWithMediaMimeType(mime_type, codecs,
1001 key_system);
939 } 1002 }
940 1003
941 std::string GetKeySystemNameForUMA(const std::string& key_system) { 1004 std::string GetKeySystemNameForUMA(const std::string& key_system) {
942 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system); 1005 return KeySystemsImpl::GetInstance().GetKeySystemNameForUMA(key_system);
943 } 1006 }
944 1007
945 bool CanUseAesDecryptor(const std::string& concrete_key_system) { 1008 bool CanUseAesDecryptor(const std::string& concrete_key_system) {
946 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); 1009 return KeySystemsImpl::GetInstance().UseAesDecryptor(concrete_key_system);
947 } 1010 }
948 1011
949 #if defined(ENABLE_PEPPER_CDMS) 1012 #if defined(ENABLE_PEPPER_CDMS)
950 std::string GetPepperType(const std::string& concrete_key_system) { 1013 std::string GetPepperType(const std::string& concrete_key_system) {
951 return KeySystems::GetInstance().GetPepperType(concrete_key_system); 1014 return KeySystemsImpl::GetInstance().GetPepperType(concrete_key_system);
952 } 1015 }
953 #endif 1016 #endif
954 1017
955 EmeConfigRule GetRobustnessConfigRule(
956 const std::string& key_system,
957 EmeMediaType media_type,
958 const std::string& robustness) {
959 return KeySystems::GetInstance().GetRobustnessConfigRule(
960 key_system, media_type, robustness);
961 }
962
963 EmeConfigRule GetPersistentLicenseSessionConfigRule(
964 const std::string& key_system) {
965 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule(
966 key_system);
967 }
968
969 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule(
970 const std::string& key_system) {
971 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule(
972 key_system);
973 }
974
975 EmeConfigRule GetPersistentStateConfigRule(
976 const std::string& key_system,
977 EmeFeatureRequirement requirement) {
978 return KeySystems::GetInstance().GetPersistentStateConfigRule(
979 key_system, requirement);
980 }
981
982 EmeConfigRule GetDistinctiveIdentifierConfigRule(
983 const std::string& key_system,
984 EmeFeatureRequirement requirement) {
985 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule(
986 key_system, requirement);
987 }
988
989 // These two functions are for testing purpose only. The declaration in the 1018 // These two functions are for testing purpose only. The declaration in the
990 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used 1019 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used
991 // by tests but not non-test code. However, this .cc file is compiled as part of 1020 // by tests but not non-test code. However, this .cc file is compiled as part of
992 // "media" where "UNIT_TEST" is not defined. So we need to specify 1021 // "media" where "UNIT_TEST" is not defined. So we need to specify
993 // "MEDIA_EXPORT" here again so that they are visible to tests. 1022 // "MEDIA_EXPORT" here again so that they are visible to tests.
994 1023
995 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { 1024 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) {
996 KeySystems::GetInstance().AddContainerMask(container, mask); 1025 KeySystemsImpl::GetInstance().AddContainerMask(container, mask);
997 } 1026 }
998 1027
999 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { 1028 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) {
1000 KeySystems::GetInstance().AddCodecMask(codec, mask); 1029 KeySystemsImpl::GetInstance().AddCodecMask(codec, mask);
1001 } 1030 }
1002 1031
1003 } // namespace media 1032 } // namespace media
OLDNEW
« no previous file with comments | « media/base/key_systems.h ('k') | media/blink/webencryptedmediaclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698