| 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 | |
| 8 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 9 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 12 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 13 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 14 #include "media/base/key_system_info.h" | 13 #include "media/base/key_system_info.h" |
| 15 #include "media/base/key_systems_support_uma.h" | 14 #include "media/base/key_systems_support_uma.h" |
| 16 #include "media/base/media_client.h" | 15 #include "media/base/media_client.h" |
| 17 #include "media/cdm/key_system_names.h" | 16 #include "media/cdm/key_system_names.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 const std::string& key_system); | 180 const std::string& key_system); |
| 182 | 181 |
| 183 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 182 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
| 184 | 183 |
| 185 bool UseAesDecryptor(const std::string& concrete_key_system) const; | 184 bool UseAesDecryptor(const std::string& concrete_key_system) const; |
| 186 | 185 |
| 187 #if defined(ENABLE_PEPPER_CDMS) | 186 #if defined(ENABLE_PEPPER_CDMS) |
| 188 std::string GetPepperType(const std::string& concrete_key_system) const; | 187 std::string GetPepperType(const std::string& concrete_key_system) const; |
| 189 #endif | 188 #endif |
| 190 | 189 |
| 191 void AddContainerMask(const std::string& container, uint32 mask); | 190 void AddContainerMask(const std::string& container, uint32_t mask); |
| 192 void AddCodecMask( | 191 void AddCodecMask(EmeMediaType media_type, |
| 193 EmeMediaType media_type, | 192 const std::string& codec, |
| 194 const std::string& codec, | 193 uint32_t mask); |
| 195 uint32 mask); | |
| 196 | 194 |
| 197 // Implementation of KeySystems interface. | 195 // Implementation of KeySystems interface. |
| 198 bool IsSupportedKeySystem(const std::string& key_system) const override; | 196 bool IsSupportedKeySystem(const std::string& key_system) const override; |
| 199 | 197 |
| 200 bool IsSupportedInitDataType(const std::string& key_system, | 198 bool IsSupportedInitDataType(const std::string& key_system, |
| 201 EmeInitDataType init_data_type) const override; | 199 EmeInitDataType init_data_type) const override; |
| 202 | 200 |
| 203 EmeConfigRule GetContentTypeConfigRule( | 201 EmeConfigRule GetContentTypeConfigRule( |
| 204 const std::string& key_system, | 202 const std::string& key_system, |
| 205 EmeMediaType media_type, | 203 EmeMediaType media_type, |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 627 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
| 630 return std::string(); | 628 return std::string(); |
| 631 } | 629 } |
| 632 | 630 |
| 633 const std::string& type = key_system_iter->second.pepper_type; | 631 const std::string& type = key_system_iter->second.pepper_type; |
| 634 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 632 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
| 635 return type; | 633 return type; |
| 636 } | 634 } |
| 637 #endif | 635 #endif |
| 638 | 636 |
| 639 void KeySystemsImpl::AddContainerMask( | 637 void KeySystemsImpl::AddContainerMask(const std::string& container, |
| 640 const std::string& container, | 638 uint32_t mask) { |
| 641 uint32 mask) { | |
| 642 DCHECK(thread_checker_.CalledOnValidThread()); | 639 DCHECK(thread_checker_.CalledOnValidThread()); |
| 643 DCHECK(!container_to_codec_mask_map_.count(container)); | 640 DCHECK(!container_to_codec_mask_map_.count(container)); |
| 644 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 641 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
| 645 } | 642 } |
| 646 | 643 |
| 647 void KeySystemsImpl::AddCodecMask( | 644 void KeySystemsImpl::AddCodecMask(EmeMediaType media_type, |
| 648 EmeMediaType media_type, | 645 const std::string& codec, |
| 649 const std::string& codec, | 646 uint32_t mask) { |
| 650 uint32 mask) { | |
| 651 DCHECK(thread_checker_.CalledOnValidThread()); | 647 DCHECK(thread_checker_.CalledOnValidThread()); |
| 652 DCHECK(!codec_string_map_.count(codec)); | 648 DCHECK(!codec_string_map_.count(codec)); |
| 653 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | 649 codec_string_map_[codec] = static_cast<EmeCodec>(mask); |
| 654 if (media_type == EmeMediaType::AUDIO) { | 650 if (media_type == EmeMediaType::AUDIO) { |
| 655 audio_codec_mask_ |= mask; | 651 audio_codec_mask_ |= mask; |
| 656 } else { | 652 } else { |
| 657 video_codec_mask_ |= mask; | 653 video_codec_mask_ |= mask; |
| 658 } | 654 } |
| 659 } | 655 } |
| 660 | 656 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 return KeySystemsImpl::GetInstance()->GetPepperType(concrete_key_system); | 914 return KeySystemsImpl::GetInstance()->GetPepperType(concrete_key_system); |
| 919 } | 915 } |
| 920 #endif | 916 #endif |
| 921 | 917 |
| 922 // These two functions are for testing purpose only. The declaration in the | 918 // These two functions are for testing purpose only. The declaration in the |
| 923 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used | 919 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used |
| 924 // by tests but not non-test code. However, this .cc file is compiled as part of | 920 // by tests but not non-test code. However, this .cc file is compiled as part of |
| 925 // "media" where "UNIT_TEST" is not defined. So we need to specify | 921 // "media" where "UNIT_TEST" is not defined. So we need to specify |
| 926 // "MEDIA_EXPORT" here again so that they are visible to tests. | 922 // "MEDIA_EXPORT" here again so that they are visible to tests. |
| 927 | 923 |
| 928 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 924 MEDIA_EXPORT void AddContainerMask(const std::string& container, |
| 925 uint32_t mask) { |
| 929 KeySystemsImpl::GetInstance()->AddContainerMask(container, mask); | 926 KeySystemsImpl::GetInstance()->AddContainerMask(container, mask); |
| 930 } | 927 } |
| 931 | 928 |
| 932 MEDIA_EXPORT void AddCodecMask( | 929 MEDIA_EXPORT void AddCodecMask(EmeMediaType media_type, |
| 933 EmeMediaType media_type, | 930 const std::string& codec, |
| 934 const std::string& codec, | 931 uint32_t mask) { |
| 935 uint32 mask) { | |
| 936 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); | 932 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); |
| 937 } | 933 } |
| 938 | 934 |
| 939 } // namespace media | 935 } // namespace media |
| OLD | NEW |