Chromium Code Reviews| 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 "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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // Opus is not supported on Android yet. http://crbug.com/318436. | 91 // Opus is not supported on Android yet. http://crbug.com/318436. |
| 92 // TODO(sandersd): Check for platform support to set this bit. | 92 // TODO(sandersd): Check for platform support to set this bit. |
| 93 info.supported_codecs &= ~EME_CODEC_WEBM_OPUS; | 93 info.supported_codecs &= ~EME_CODEC_WEBM_OPUS; |
| 94 #endif // defined(OS_ANDROID) | 94 #endif // defined(OS_ANDROID) |
| 95 | 95 |
| 96 #if defined(USE_PROPRIETARY_CODECS) | 96 #if defined(USE_PROPRIETARY_CODECS) |
| 97 info.supported_init_data_types |= EME_INIT_DATA_TYPE_CENC; | 97 info.supported_init_data_types |= EME_INIT_DATA_TYPE_CENC; |
| 98 info.supported_codecs |= EME_CODEC_MP4_ALL; | 98 info.supported_codecs |= EME_CODEC_MP4_ALL; |
| 99 #endif // defined(USE_PROPRIETARY_CODECS) | 99 #endif // defined(USE_PROPRIETARY_CODECS) |
| 100 | 100 |
| 101 info.persistent_state_requirement = EME_REQUIREMENT_NOT_ALLOWED; | |
| 102 info.distinctive_identifier_requirement = EME_REQUIREMENT_NOT_ALLOWED; | |
| 103 info.supported_session_types = EME_SESSION_TYPE_TEMPORARY; | |
| 104 | |
| 101 info.use_aes_decryptor = true; | 105 info.use_aes_decryptor = true; |
| 102 | 106 |
| 103 concrete_key_systems->push_back(info); | 107 concrete_key_systems->push_back(info); |
| 104 } | 108 } |
| 105 | 109 |
| 106 class KeySystems { | 110 class KeySystems { |
| 107 public: | 111 public: |
| 108 static KeySystems& GetInstance(); | 112 static KeySystems& GetInstance(); |
| 109 | 113 |
| 110 void UpdateIfNeeded(); | 114 void UpdateIfNeeded(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 124 bool reportToUma); | 128 bool reportToUma); |
| 125 | 129 |
| 126 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 130 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
| 127 | 131 |
| 128 bool UseAesDecryptor(const std::string& concrete_key_system); | 132 bool UseAesDecryptor(const std::string& concrete_key_system); |
| 129 | 133 |
| 130 #if defined(ENABLE_PEPPER_CDMS) | 134 #if defined(ENABLE_PEPPER_CDMS) |
| 131 std::string GetPepperType(const std::string& concrete_key_system); | 135 std::string GetPepperType(const std::string& concrete_key_system); |
| 132 #endif | 136 #endif |
| 133 | 137 |
| 138 bool IsSupportedDistinctiveIdentifierRequirement( | |
| 139 const std::string& key_system, | |
| 140 EmeRequirement requirement); | |
| 141 | |
| 142 bool IsSupportedPersistentStateRequirement( | |
| 143 const std::string& key_system, | |
| 144 EmeRequirement requirement); | |
| 145 | |
| 146 bool IsSupportedSessionType( | |
| 147 const std::string& key_system, | |
| 148 EmeSessionType session_Type); | |
| 149 | |
| 134 void AddContainerMask(const std::string& container, uint32 mask); | 150 void AddContainerMask(const std::string& container, uint32 mask); |
| 135 void AddCodecMask(const std::string& codec, uint32 mask); | 151 void AddCodecMask(const std::string& codec, uint32 mask); |
| 136 | 152 |
| 137 private: | 153 private: |
| 138 void InitializeUMAInfo(); | 154 void InitializeUMAInfo(); |
| 139 | 155 |
| 140 void UpdateSupportedKeySystems(); | 156 void UpdateSupportedKeySystems(); |
| 141 | 157 |
| 142 void AddConcreteSupportedKeySystems( | 158 void AddConcreteSupportedKeySystems( |
| 143 const std::vector<KeySystemInfo>& concrete_key_systems); | 159 const std::vector<KeySystemInfo>& concrete_key_systems); |
| 144 | 160 |
| 145 void AddConcreteSupportedKeySystem( | |
| 146 const std::string& key_system, | |
| 147 bool use_aes_decryptor, | |
| 148 #if defined(ENABLE_PEPPER_CDMS) | |
| 149 const std::string& pepper_type, | |
| 150 #endif | |
| 151 SupportedInitDataTypes supported_init_data_types, | |
| 152 SupportedCodecs supported_codecs, | |
| 153 const std::string& parent_key_system); | |
| 154 | |
| 155 friend struct base::DefaultLazyInstanceTraits<KeySystems>; | 161 friend struct base::DefaultLazyInstanceTraits<KeySystems>; |
| 156 | 162 |
| 157 struct KeySystemProperties { | 163 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; |
| 158 KeySystemProperties() | |
| 159 : use_aes_decryptor(false), supported_codecs(EME_CODEC_NONE) {} | |
| 160 | |
| 161 bool use_aes_decryptor; | |
| 162 #if defined(ENABLE_PEPPER_CDMS) | |
| 163 std::string pepper_type; | |
| 164 #endif | |
| 165 SupportedInitDataTypes supported_init_data_types; | |
| 166 SupportedCodecs supported_codecs; | |
| 167 }; | |
| 168 | |
| 169 typedef base::hash_map<std::string, KeySystemProperties> | |
| 170 KeySystemPropertiesMap; | |
| 171 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; | 164 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; |
| 172 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; | 165 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; |
| 173 typedef base::hash_map<std::string, EmeCodec> CodecsMap; | 166 typedef base::hash_map<std::string, EmeCodec> CodecsMap; |
| 174 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; | 167 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; |
| 175 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; | 168 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; |
| 176 | 169 |
| 177 KeySystems(); | 170 KeySystems(); |
| 178 ~KeySystems() {} | 171 ~KeySystems() {} |
| 179 | 172 |
| 180 EmeInitDataType GetInitDataTypeForName( | 173 EmeInitDataType GetInitDataTypeForName( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 195 SupportedCodecs key_system_supported_codecs) const; | 188 SupportedCodecs key_system_supported_codecs) const; |
| 196 | 189 |
| 197 // Returns true if all |codecs| are supported in |container| by checking | 190 // Returns true if all |codecs| are supported in |container| by checking |
| 198 // |key_system_supported_codecs|. | 191 // |key_system_supported_codecs|. |
| 199 bool IsSupportedContainerAndCodecs( | 192 bool IsSupportedContainerAndCodecs( |
| 200 const std::string& container, | 193 const std::string& container, |
| 201 const std::vector<std::string>& codecs, | 194 const std::vector<std::string>& codecs, |
| 202 SupportedCodecs key_system_supported_codecs) const; | 195 SupportedCodecs key_system_supported_codecs) const; |
| 203 | 196 |
| 204 // Map from key system string to capabilities. | 197 // Map from key system string to capabilities. |
| 205 KeySystemPropertiesMap concrete_key_system_map_; | 198 KeySystemInfoMap concrete_key_system_map_; |
| 206 | 199 |
| 207 // Map from parent key system to the concrete key system that should be used | 200 // Map from parent key system to the concrete key system that should be used |
| 208 // to represent its capabilities. | 201 // to represent its capabilities. |
| 209 ParentKeySystemMap parent_key_system_map_; | 202 ParentKeySystemMap parent_key_system_map_; |
| 210 | 203 |
| 211 KeySystemsSupportUMA key_systems_support_uma_; | 204 KeySystemsSupportUMA key_systems_support_uma_; |
| 212 | 205 |
| 213 InitDataTypesMap init_data_type_name_map_; | 206 InitDataTypesMap init_data_type_name_map_; |
| 214 ContainerCodecsMap container_to_codec_mask_map_; | 207 ContainerCodecsMap container_to_codec_mask_map_; |
| 215 CodecsMap codec_string_map_; | 208 CodecsMap codec_string_map_; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 | 323 |
| 331 AddConcreteSupportedKeySystems(key_systems_info); | 324 AddConcreteSupportedKeySystems(key_systems_info); |
| 332 } | 325 } |
| 333 | 326 |
| 334 void KeySystems::AddConcreteSupportedKeySystems( | 327 void KeySystems::AddConcreteSupportedKeySystems( |
| 335 const std::vector<KeySystemInfo>& concrete_key_systems) { | 328 const std::vector<KeySystemInfo>& concrete_key_systems) { |
| 336 DCHECK(thread_checker_.CalledOnValidThread()); | 329 DCHECK(thread_checker_.CalledOnValidThread()); |
| 337 DCHECK(concrete_key_system_map_.empty()); | 330 DCHECK(concrete_key_system_map_.empty()); |
| 338 DCHECK(parent_key_system_map_.empty()); | 331 DCHECK(parent_key_system_map_.empty()); |
| 339 | 332 |
| 340 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { | 333 for (const KeySystemInfo& info : concrete_key_systems) { |
| 341 const KeySystemInfo& key_system_info = concrete_key_systems[i]; | 334 DCHECK(!info.key_system.empty()) << "Missing key system name"; |
|
ddorwin
2015/02/17 22:34:58
nit: The << part is probably unnecessary for this
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
| |
| 342 AddConcreteSupportedKeySystem(key_system_info.key_system, | 335 DCHECK(!IsConcreteSupportedKeySystem(info.key_system)) |
|
ddorwin
2015/02/17 22:34:58
I believe this needs to change after https://coder
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
| |
| 343 key_system_info.use_aes_decryptor, | 336 << "Key system '" << info.key_system << "' already registered"; |
| 337 DCHECK(!parent_key_system_map_.count(info.key_system)) | |
| 338 << "'" << info.key_system << "' is already registered as a parent"; | |
| 344 #if defined(ENABLE_PEPPER_CDMS) | 339 #if defined(ENABLE_PEPPER_CDMS) |
| 345 key_system_info.pepper_type, | 340 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); |
| 346 #endif | 341 #endif |
| 347 key_system_info.supported_init_data_types, | 342 |
| 348 key_system_info.supported_codecs, | 343 if (info.supported_session_types == EME_SESSION_TYPE_NONE) { |
| 349 key_system_info.parent_key_system); | 344 NOTREACHED() << "Key system '" << info.key_system << "' does not support" |
|
ddorwin
2015/02/17 22:34:58
nit: The issue is really that no session types wer
sandersd (OOO until July 31)
2015/02/18 23:41:18
Done.
| |
| 345 << "any session types"; | |
| 346 continue; | |
| 347 } | |
| 348 | |
|
ddorwin
2015/02/17 22:34:58
We can DCHECK that the persistent session types ar
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
| |
| 349 concrete_key_system_map_[info.key_system] = info; | |
| 350 | |
| 351 if (!info.parent_key_system.empty()) { | |
| 352 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) | |
| 353 << "Parent '" << info.parent_key_system << "' " | |
| 354 << "already registered concrete"; | |
| 355 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) | |
| 356 << "Parent '" << info.parent_key_system << "' already registered"; | |
| 357 parent_key_system_map_[info.parent_key_system] = info.key_system; | |
| 358 } | |
| 350 } | 359 } |
| 351 } | 360 } |
| 352 | 361 |
| 353 void KeySystems::AddConcreteSupportedKeySystem( | |
| 354 const std::string& concrete_key_system, | |
| 355 bool use_aes_decryptor, | |
| 356 #if defined(ENABLE_PEPPER_CDMS) | |
| 357 const std::string& pepper_type, | |
| 358 #endif | |
| 359 SupportedInitDataTypes supported_init_data_types, | |
| 360 SupportedCodecs supported_codecs, | |
| 361 const std::string& parent_key_system) { | |
| 362 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 363 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) | |
| 364 << "Key system '" << concrete_key_system << "' already registered"; | |
| 365 DCHECK(!parent_key_system_map_.count(concrete_key_system)) | |
| 366 << "'" << concrete_key_system << " is already registered as a parent"; | |
| 367 | |
| 368 KeySystemProperties properties; | |
| 369 properties.use_aes_decryptor = use_aes_decryptor; | |
| 370 #if defined(ENABLE_PEPPER_CDMS) | |
| 371 DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); | |
| 372 properties.pepper_type = pepper_type; | |
| 373 #endif | |
| 374 | |
| 375 properties.supported_init_data_types = supported_init_data_types; | |
| 376 properties.supported_codecs = supported_codecs; | |
| 377 | |
| 378 concrete_key_system_map_[concrete_key_system] = properties; | |
| 379 | |
| 380 if (!parent_key_system.empty()) { | |
| 381 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system)) | |
| 382 << "Parent '" << parent_key_system << "' already registered concrete"; | |
| 383 DCHECK(!parent_key_system_map_.count(parent_key_system)) | |
| 384 << "Parent '" << parent_key_system << "' already registered"; | |
| 385 parent_key_system_map_[parent_key_system] = concrete_key_system; | |
| 386 } | |
| 387 } | |
| 388 | |
| 389 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { | 362 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { |
| 390 DCHECK(thread_checker_.CalledOnValidThread()); | 363 DCHECK(thread_checker_.CalledOnValidThread()); |
| 391 return concrete_key_system_map_.count(key_system) != 0; | 364 return concrete_key_system_map_.count(key_system) != 0; |
| 392 } | 365 } |
| 393 | 366 |
| 394 bool KeySystems::IsSupportedContainer( | 367 bool KeySystems::IsSupportedContainer( |
| 395 const std::string& container, | 368 const std::string& container, |
| 396 SupportedCodecs key_system_supported_codecs) const { | 369 SupportedCodecs key_system_supported_codecs) const { |
| 397 DCHECK(thread_checker_.CalledOnValidThread()); | 370 DCHECK(thread_checker_.CalledOnValidThread()); |
| 398 DCHECK(!container.empty()); | 371 DCHECK(!container.empty()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 | 425 |
| 453 bool KeySystems::IsSupportedKeySystemWithInitDataType( | 426 bool KeySystems::IsSupportedKeySystemWithInitDataType( |
| 454 const std::string& key_system, | 427 const std::string& key_system, |
| 455 const std::string& init_data_type) { | 428 const std::string& init_data_type) { |
| 456 DCHECK(thread_checker_.CalledOnValidThread()); | 429 DCHECK(thread_checker_.CalledOnValidThread()); |
| 457 | 430 |
| 458 // If |key_system| is a parent key system, use its concrete child. | 431 // If |key_system| is a parent key system, use its concrete child. |
| 459 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); | 432 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); |
| 460 | 433 |
| 461 // Locate |concrete_key_system|. | 434 // Locate |concrete_key_system|. |
| 462 KeySystemPropertiesMap::const_iterator key_system_iter = | 435 KeySystemInfoMap::const_iterator key_system_iter = |
| 463 concrete_key_system_map_.find(concrete_key_system); | 436 concrete_key_system_map_.find(concrete_key_system); |
| 464 if (key_system_iter == concrete_key_system_map_.end()) | 437 if (key_system_iter == concrete_key_system_map_.end()) |
| 465 return false; | 438 return false; |
| 466 | 439 |
| 467 // Check |init_data_type| and |key_system| x |init_data_type|. | 440 // Check |init_data_type| and |key_system| x |init_data_type|. |
| 468 const KeySystemProperties& properties = key_system_iter->second; | 441 const KeySystemInfo& info = key_system_iter->second; |
| 469 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); | 442 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
| 470 return (properties.supported_init_data_types & eme_init_data_type) != 0; | 443 return (info.supported_init_data_types & eme_init_data_type) != 0; |
| 471 } | 444 } |
| 472 | 445 |
| 473 // TODO(sandersd): Reorganize to be more similar to | 446 // TODO(sandersd): Reorganize to be more similar to |
| 474 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be | 447 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be |
| 475 // required; http://crbug.com/417461. | 448 // required; http://crbug.com/417461. |
| 476 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 449 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
| 477 const std::string& mime_type, | 450 const std::string& mime_type, |
| 478 const std::vector<std::string>& codecs, | 451 const std::vector<std::string>& codecs, |
| 479 const std::string& key_system, | 452 const std::string& key_system, |
| 480 bool reportToUma) { | 453 bool reportToUma) { |
| 481 DCHECK(thread_checker_.CalledOnValidThread()); | 454 DCHECK(thread_checker_.CalledOnValidThread()); |
| 482 | 455 |
| 483 // If |key_system| is a parent key system, use its concrete child. | 456 // If |key_system| is a parent key system, use its concrete child. |
| 484 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); | 457 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); |
| 485 | 458 |
| 486 bool has_type = !mime_type.empty(); | 459 bool has_type = !mime_type.empty(); |
| 487 | 460 |
| 488 if (reportToUma) | 461 if (reportToUma) |
| 489 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | 462 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
| 490 | 463 |
| 491 // Check key system support. | 464 // Check key system support. |
| 492 KeySystemPropertiesMap::const_iterator key_system_iter = | 465 KeySystemInfoMap::const_iterator key_system_iter = |
| 493 concrete_key_system_map_.find(concrete_key_system); | 466 concrete_key_system_map_.find(concrete_key_system); |
| 494 if (key_system_iter == concrete_key_system_map_.end()) | 467 if (key_system_iter == concrete_key_system_map_.end()) |
| 495 return false; | 468 return false; |
| 496 | 469 |
| 497 if (reportToUma) | 470 if (reportToUma) |
| 498 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | 471 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
| 499 | 472 |
| 500 if (!has_type) { | 473 if (!has_type) { |
| 501 DCHECK(codecs.empty()); | 474 DCHECK(codecs.empty()); |
| 502 return true; | 475 return true; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 527 key_system_name_for_uma_map_.find(key_system); | 500 key_system_name_for_uma_map_.find(key_system); |
| 528 if (iter == key_system_name_for_uma_map_.end()) | 501 if (iter == key_system_name_for_uma_map_.end()) |
| 529 return kUnknownKeySystemNameForUMA; | 502 return kUnknownKeySystemNameForUMA; |
| 530 | 503 |
| 531 return iter->second; | 504 return iter->second; |
| 532 } | 505 } |
| 533 | 506 |
| 534 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { | 507 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { |
| 535 DCHECK(thread_checker_.CalledOnValidThread()); | 508 DCHECK(thread_checker_.CalledOnValidThread()); |
| 536 | 509 |
| 537 KeySystemPropertiesMap::const_iterator key_system_iter = | 510 KeySystemInfoMap::const_iterator key_system_iter = |
| 538 concrete_key_system_map_.find(concrete_key_system); | 511 concrete_key_system_map_.find(concrete_key_system); |
| 539 if (key_system_iter == concrete_key_system_map_.end()) { | 512 if (key_system_iter == concrete_key_system_map_.end()) { |
| 540 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 513 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 541 return false; | 514 return false; |
| 542 } | 515 } |
| 543 | 516 |
| 544 return key_system_iter->second.use_aes_decryptor; | 517 return key_system_iter->second.use_aes_decryptor; |
| 545 } | 518 } |
| 546 | 519 |
| 547 #if defined(ENABLE_PEPPER_CDMS) | 520 #if defined(ENABLE_PEPPER_CDMS) |
| 548 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { | 521 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { |
| 549 DCHECK(thread_checker_.CalledOnValidThread()); | 522 DCHECK(thread_checker_.CalledOnValidThread()); |
| 550 | 523 |
| 551 KeySystemPropertiesMap::const_iterator key_system_iter = | 524 KeySystemInfoMap::const_iterator key_system_iter = |
| 552 concrete_key_system_map_.find(concrete_key_system); | 525 concrete_key_system_map_.find(concrete_key_system); |
| 553 if (key_system_iter == concrete_key_system_map_.end()) { | 526 if (key_system_iter == concrete_key_system_map_.end()) { |
| 554 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 527 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 555 return std::string(); | 528 return std::string(); |
| 556 } | 529 } |
| 557 | 530 |
| 558 const std::string& type = key_system_iter->second.pepper_type; | 531 const std::string& type = key_system_iter->second.pepper_type; |
| 559 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 532 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
| 560 return type; | 533 return type; |
| 561 } | 534 } |
| 562 #endif | 535 #endif |
| 563 | 536 |
| 537 bool KeySystems::IsSupportedDistinctiveIdentifierRequirement( | |
| 538 const std::string& key_system, | |
| 539 EmeRequirement requirement) { | |
| 540 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 541 | |
| 542 KeySystemInfoMap::const_iterator key_system_iter = | |
| 543 concrete_key_system_map_.find(key_system); | |
| 544 if (key_system_iter == concrete_key_system_map_.end()) | |
| 545 return false; | |
| 546 EmeRequirement requirement_mask = | |
|
ddorwin
2015/02/17 22:34:58
An enum cannot be a mask. You must use an int. If
sandersd (OOO until July 31)
2015/02/18 23:41:18
Acknowledged.
| |
| 547 key_system_iter->second.distinctive_identifier_requirement; | |
| 548 | |
| 549 return (requirement & requirement_mask) != 0; | |
| 550 } | |
| 551 | |
| 552 bool KeySystems::IsSupportedPersistentStateRequirement( | |
| 553 const std::string& key_system, | |
| 554 EmeRequirement requirement) { | |
| 555 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 556 | |
| 557 KeySystemInfoMap::const_iterator key_system_iter = | |
| 558 concrete_key_system_map_.find(key_system); | |
| 559 if (key_system_iter == concrete_key_system_map_.end()) | |
| 560 return false; | |
| 561 EmeRequirement requirement_mask = | |
|
ddorwin
2015/02/17 22:34:57
ditto
sandersd (OOO until July 31)
2015/02/18 23:41:17
Acknowledged.
| |
| 562 key_system_iter->second.persistent_state_requirement; | |
| 563 | |
| 564 return (requirement & requirement_mask) != 0; | |
| 565 } | |
| 566 | |
| 567 bool KeySystems::IsSupportedSessionType( | |
| 568 const std::string& key_system, | |
| 569 EmeSessionType session_type) { | |
| 570 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 571 | |
| 572 KeySystemInfoMap::const_iterator key_system_iter = | |
| 573 concrete_key_system_map_.find(key_system); | |
| 574 if (key_system_iter == concrete_key_system_map_.end()) | |
| 575 return false; | |
| 576 SupportedSessionTypes session_type_mask = | |
|
ddorwin
2015/02/17 22:34:58
This one is okay.
sandersd (OOO until July 31)
2015/02/18 23:41:17
Acknowledged.
| |
| 577 key_system_iter->second.supported_session_types; | |
| 578 | |
| 579 return (session_type & session_type_mask) != 0; | |
| 580 } | |
| 581 | |
| 564 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 582 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
| 565 DCHECK(thread_checker_.CalledOnValidThread()); | 583 DCHECK(thread_checker_.CalledOnValidThread()); |
| 566 DCHECK(!container_to_codec_mask_map_.count(container)); | 584 DCHECK(!container_to_codec_mask_map_.count(container)); |
| 567 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 585 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
| 568 } | 586 } |
| 569 | 587 |
| 570 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 588 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
| 571 DCHECK(thread_checker_.CalledOnValidThread()); | 589 DCHECK(thread_checker_.CalledOnValidThread()); |
| 572 DCHECK(!codec_string_map_.count(codec)); | 590 DCHECK(!codec_string_map_.count(codec)); |
| 573 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | 591 codec_string_map_[codec] = static_cast<EmeCodec>(mask); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 662 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
| 645 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 663 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
| 646 } | 664 } |
| 647 | 665 |
| 648 #if defined(ENABLE_PEPPER_CDMS) | 666 #if defined(ENABLE_PEPPER_CDMS) |
| 649 std::string GetPepperType(const std::string& concrete_key_system) { | 667 std::string GetPepperType(const std::string& concrete_key_system) { |
| 650 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 668 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
| 651 } | 669 } |
| 652 #endif | 670 #endif |
| 653 | 671 |
| 672 bool IsSupportedDistinctiveIdentifierRequirement( | |
| 673 const std::string& key_system, | |
| 674 EmeRequirement requirement) { | |
| 675 return KeySystems::GetInstance().IsSupportedDistinctiveIdentifierRequirement( | |
| 676 key_system, requirement); | |
| 677 } | |
| 678 | |
| 679 bool IsSupportedPersistentStateRequirement( | |
| 680 const std::string& key_system, | |
| 681 EmeRequirement requirement) { | |
| 682 return KeySystems::GetInstance().IsSupportedPersistentStateRequirement( | |
| 683 key_system, requirement); | |
| 684 } | |
| 685 | |
| 686 bool IsSupportedSessionType( | |
| 687 const std::string& key_system, | |
| 688 EmeSessionType session_type) { | |
| 689 return KeySystems::GetInstance().IsSupportedSessionType( | |
| 690 key_system, session_type); | |
| 691 } | |
| 692 | |
| 654 // These two functions are for testing purpose only. The declaration in the | 693 // These two functions are for testing purpose only. The declaration in the |
| 655 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used | 694 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used |
| 656 // by tests but not non-test code. However, this .cc file is compiled as part of | 695 // by tests but not non-test code. However, this .cc file is compiled as part of |
| 657 // "media" where "UNIT_TEST" is not defined. So we need to specify | 696 // "media" where "UNIT_TEST" is not defined. So we need to specify |
| 658 // "MEDIA_EXPORT" here again so that they are visible to tests. | 697 // "MEDIA_EXPORT" here again so that they are visible to tests. |
| 659 | 698 |
| 660 MEDIA_EXPORT void AddContainerMask(const std::string& container, | 699 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
| 661 uint32 mask) { | |
| 662 KeySystems::GetInstance().AddContainerMask(container, mask); | 700 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 663 } | 701 } |
| 664 | 702 |
| 665 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 703 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 666 KeySystems::GetInstance().AddCodecMask(codec, mask); | 704 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 667 } | 705 } |
| 668 | 706 |
| 669 } // namespace media | 707 } // namespace media |
| OLD | NEW |