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

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

Issue 1124863005: Restrict use of hardware-secure codecs based on the RendererPreference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setsecurity
Patch Set: Remove ifdefs. Created 5 years, 7 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
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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if ((key_system_codec_mask & container_codec_mask) == 0) 709 if ((key_system_codec_mask & container_codec_mask) == 0)
710 return EmeConfigRule::NOT_SUPPORTED; 710 return EmeConfigRule::NOT_SUPPORTED;
711 711
712 // Check that the codecs are supported by the key system and container. 712 // Check that the codecs are supported by the key system and container.
713 EmeConfigRule support = EmeConfigRule::SUPPORTED; 713 EmeConfigRule support = EmeConfigRule::SUPPORTED;
714 for (size_t i = 0; i < codecs.size(); i++) { 714 for (size_t i = 0; i < codecs.size(); i++) {
715 SupportedCodecs codec = GetCodecForString(codecs[i]); 715 SupportedCodecs codec = GetCodecForString(codecs[i]);
716 if ((codec & key_system_codec_mask & container_codec_mask) == 0) 716 if ((codec & key_system_codec_mask & container_codec_mask) == 0)
717 return EmeConfigRule::NOT_SUPPORTED; 717 return EmeConfigRule::NOT_SUPPORTED;
718 #if defined(OS_ANDROID) 718 #if defined(OS_ANDROID)
719 // Check whether the codec supports a hardware-secure mode; if not, indicate 719 // Check whether the codec supports a hardware-secure mode. The goal is to
720 // that hardware-secure codecs are not available for all listed codecs. 720 // prevent mixing of non-hardware-secure codecs with hardware-secure codecs,
721 // since the mode is fixed at CDM creation.
722 //
721 // Because the check for regular codec support is early-exit, we don't have 723 // Because the check for regular codec support is early-exit, we don't have
722 // to consider codecs that are only supported in hardware-secure mode. We 724 // to consider codecs that are only supported in hardware-secure mode. We
723 // could do so, and make use of SECURE_CODECS_REQUIRED, if it turns out that 725 // could do so, and make use of SECURE_SURFACES_REQUIRED, if it turns out
724 // hardware-secure-only codecs actually exist and are useful. 726 // that hardware-secure-only codecs actually exist and are useful.
725 if ((codec & key_system_secure_codec_mask) == 0) 727 if ((codec & key_system_secure_codec_mask) == 0)
726 support = EmeConfigRule::SECURE_CODECS_NOT_ALLOWED; 728 support = EmeConfigRule::SECURE_SURFACES_NOT_REQUIRABLE;
727 #endif // defined(OS_ANDROID) 729 #endif // defined(OS_ANDROID)
728 730
729 } 731 }
730 732
731 return support; 733 return support;
732 } 734 }
733 735
734 EmeConfigRule KeySystemsImpl::GetRobustnessConfigRule( 736 EmeConfigRule KeySystemsImpl::GetRobustnessConfigRule(
735 const std::string& key_system, 737 const std::string& key_system,
736 EmeMediaType media_type, 738 EmeMediaType media_type,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 // For video, recommend remote attestation if HW_SECURE_ALL is available, 782 // For video, recommend remote attestation if HW_SECURE_ALL is available,
781 // because it enables hardware accelerated decoding. 783 // because it enables hardware accelerated decoding.
782 // TODO(sandersd): Only do this when hardware accelerated decoding is 784 // TODO(sandersd): Only do this when hardware accelerated decoding is
783 // available for the requested codecs. 785 // available for the requested codecs.
784 if (media_type == EmeMediaType::VIDEO && 786 if (media_type == EmeMediaType::VIDEO &&
785 max_robustness == EmeRobustness::HW_SECURE_ALL) { 787 max_robustness == EmeRobustness::HW_SECURE_ALL) {
786 return EmeConfigRule::IDENTIFIER_RECOMMENDED; 788 return EmeConfigRule::IDENTIFIER_RECOMMENDED;
787 } 789 }
788 #elif defined(OS_ANDROID) 790 #elif defined(OS_ANDROID)
789 if (robustness > EmeRobustness::SW_SECURE_CRYPTO) 791 if (robustness > EmeRobustness::SW_SECURE_CRYPTO)
790 return EmeConfigRule::SECURE_CODECS_REQUIRED; 792 return EmeConfigRule::SECURE_SURFACES_REQUIRED;
791 #endif // defined(OS_CHROMEOS) 793 #endif // defined(OS_CHROMEOS)
792 } 794 }
793 795
794 return EmeConfigRule::SUPPORTED; 796 return EmeConfigRule::SUPPORTED;
795 } 797 }
796 798
797 EmeSessionTypeSupport KeySystemsImpl::GetPersistentLicenseSessionSupport( 799 EmeSessionTypeSupport KeySystemsImpl::GetPersistentLicenseSessionSupport(
798 const std::string& key_system) const { 800 const std::string& key_system) const {
799 DCHECK(thread_checker_.CalledOnValidThread()); 801 DCHECK(thread_checker_.CalledOnValidThread());
800 802
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 934 }
933 935
934 MEDIA_EXPORT void AddCodecMask( 936 MEDIA_EXPORT void AddCodecMask(
935 EmeMediaType media_type, 937 EmeMediaType media_type,
936 const std::string& codec, 938 const std::string& codec,
937 uint32 mask) { 939 uint32 mask) {
938 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); 940 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask);
939 } 941 }
940 942
941 } // namespace media 943 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698