| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 bool IsSupportedKeySystem(const std::string& key_system); | 114 bool IsSupportedKeySystem(const std::string& key_system); |
| 115 | 115 |
| 116 bool IsSupportedKeySystemWithInitDataType( | 116 bool IsSupportedKeySystemWithInitDataType( |
| 117 const std::string& key_system, | 117 const std::string& key_system, |
| 118 const std::string& init_data_type); | 118 const std::string& init_data_type); |
| 119 | 119 |
| 120 bool IsSupportedKeySystemWithMediaMimeType( | 120 bool IsSupportedKeySystemWithMediaMimeType( |
| 121 const std::string& mime_type, | 121 const std::string& mime_type, |
| 122 const std::vector<std::string>& codecs, | 122 const std::vector<std::string>& codecs, |
| 123 const std::string& key_system); | 123 const std::string& key_system, |
| 124 bool reportToUma); |
| 124 | 125 |
| 125 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 126 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
| 126 | 127 |
| 127 bool UseAesDecryptor(const std::string& concrete_key_system); | 128 bool UseAesDecryptor(const std::string& concrete_key_system); |
| 128 | 129 |
| 129 #if defined(ENABLE_PEPPER_CDMS) | 130 #if defined(ENABLE_PEPPER_CDMS) |
| 130 std::string GetPepperType(const std::string& concrete_key_system); | 131 std::string GetPepperType(const std::string& concrete_key_system); |
| 131 #endif | 132 #endif |
| 132 | 133 |
| 133 void AddContainerMask(const std::string& container, uint32 mask); | 134 void AddContainerMask(const std::string& container, uint32 mask); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); | 469 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
| 469 return (properties.supported_init_data_types & eme_init_data_type) != 0; | 470 return (properties.supported_init_data_types & eme_init_data_type) != 0; |
| 470 } | 471 } |
| 471 | 472 |
| 472 // TODO(sandersd): Reorganize to be more similar to | 473 // TODO(sandersd): Reorganize to be more similar to |
| 473 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be | 474 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be |
| 474 // required; http://crbug.com/417461. | 475 // required; http://crbug.com/417461. |
| 475 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 476 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
| 476 const std::string& mime_type, | 477 const std::string& mime_type, |
| 477 const std::vector<std::string>& codecs, | 478 const std::vector<std::string>& codecs, |
| 478 const std::string& key_system) { | 479 const std::string& key_system, |
| 480 bool reportToUma) { |
| 479 DCHECK(thread_checker_.CalledOnValidThread()); | 481 DCHECK(thread_checker_.CalledOnValidThread()); |
| 480 | 482 |
| 481 // If |key_system| is a parent key system, use its concrete child. | 483 // If |key_system| is a parent key system, use its concrete child. |
| 482 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); | 484 const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); |
| 483 | 485 |
| 484 bool has_type = !mime_type.empty(); | 486 bool has_type = !mime_type.empty(); |
| 485 | 487 |
| 486 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | 488 if (reportToUma) |
| 489 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
| 487 | 490 |
| 488 // Check key system support. | 491 // Check key system support. |
| 489 KeySystemPropertiesMap::const_iterator key_system_iter = | 492 KeySystemPropertiesMap::const_iterator key_system_iter = |
| 490 concrete_key_system_map_.find(concrete_key_system); | 493 concrete_key_system_map_.find(concrete_key_system); |
| 491 if (key_system_iter == concrete_key_system_map_.end()) | 494 if (key_system_iter == concrete_key_system_map_.end()) |
| 492 return false; | 495 return false; |
| 493 | 496 |
| 494 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | 497 if (reportToUma) |
| 498 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
| 495 | 499 |
| 496 if (!has_type) { | 500 if (!has_type) { |
| 497 DCHECK(codecs.empty()); | 501 DCHECK(codecs.empty()); |
| 498 return true; | 502 return true; |
| 499 } | 503 } |
| 500 | 504 |
| 501 SupportedCodecs key_system_supported_codecs = | 505 SupportedCodecs key_system_supported_codecs = |
| 502 key_system_iter->second.supported_codecs; | 506 key_system_iter->second.supported_codecs; |
| 503 | 507 |
| 504 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) | 508 if (!IsSupportedContainer(mime_type, key_system_supported_codecs)) |
| 505 return false; | 509 return false; |
| 506 | 510 |
| 507 if (!codecs.empty() && | 511 if (!codecs.empty() && |
| 508 !IsSupportedContainerAndCodecs( | 512 !IsSupportedContainerAndCodecs( |
| 509 mime_type, codecs, key_system_supported_codecs)) { | 513 mime_type, codecs, key_system_supported_codecs)) { |
| 510 return false; | 514 return false; |
| 511 } | 515 } |
| 512 | 516 |
| 513 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); | 517 if (reportToUma) |
| 518 key_systems_support_uma_.ReportKeySystemSupport(key_system, true); |
| 514 return true; | 519 return true; |
| 515 } | 520 } |
| 516 | 521 |
| 517 std::string KeySystems::GetKeySystemNameForUMA( | 522 std::string KeySystems::GetKeySystemNameForUMA( |
| 518 const std::string& key_system) const { | 523 const std::string& key_system) const { |
| 519 DCHECK(thread_checker_.CalledOnValidThread()); | 524 DCHECK(thread_checker_.CalledOnValidThread()); |
| 520 | 525 |
| 521 KeySystemNameForUMAMap::const_iterator iter = | 526 KeySystemNameForUMAMap::const_iterator iter = |
| 522 key_system_name_for_uma_map_.find(key_system); | 527 key_system_name_for_uma_map_.find(key_system); |
| 523 if (iter == key_system_name_for_uma_map_.end()) | 528 if (iter == key_system_name_for_uma_map_.end()) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 bool IsSupportedKeySystemWithInitDataType( | 617 bool IsSupportedKeySystemWithInitDataType( |
| 613 const std::string& key_system, | 618 const std::string& key_system, |
| 614 const std::string& init_data_type) { | 619 const std::string& init_data_type) { |
| 615 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType( | 620 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType( |
| 616 key_system, init_data_type); | 621 key_system, init_data_type); |
| 617 } | 622 } |
| 618 | 623 |
| 619 bool IsSupportedKeySystemWithMediaMimeType( | 624 bool IsSupportedKeySystemWithMediaMimeType( |
| 620 const std::string& mime_type, | 625 const std::string& mime_type, |
| 621 const std::vector<std::string>& codecs, | 626 const std::vector<std::string>& codecs, |
| 622 const std::string& key_system) { | 627 const std::string& key_system, |
| 628 bool reportToUma) { |
| 623 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( | 629 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType( |
| 624 mime_type, codecs, key_system); | 630 mime_type, codecs, key_system, reportToUma); |
| 625 } | 631 } |
| 626 | 632 |
| 627 std::string GetKeySystemNameForUMA(const std::string& key_system) { | 633 std::string GetKeySystemNameForUMA(const std::string& key_system) { |
| 628 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system); | 634 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system); |
| 629 } | 635 } |
| 630 | 636 |
| 631 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 637 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
| 632 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 638 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
| 633 } | 639 } |
| 634 | 640 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 647 MEDIA_EXPORT void AddContainerMask(const std::string& container, | 653 MEDIA_EXPORT void AddContainerMask(const std::string& container, |
| 648 uint32 mask) { | 654 uint32 mask) { |
| 649 KeySystems::GetInstance().AddContainerMask(container, mask); | 655 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 650 } | 656 } |
| 651 | 657 |
| 652 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 658 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 653 KeySystems::GetInstance().AddCodecMask(codec, mask); | 659 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 654 } | 660 } |
| 655 | 661 |
| 656 } // namespace media | 662 } // namespace media |
| OLD | NEW |