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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 {"vp8.0", EME_CODEC_WEBM_VP8}, | 68 {"vp8.0", EME_CODEC_WEBM_VP8}, |
69 {"vp9", EME_CODEC_WEBM_VP9}, | 69 {"vp9", EME_CODEC_WEBM_VP9}, |
70 {"vp9.0", EME_CODEC_WEBM_VP9}, | 70 {"vp9.0", EME_CODEC_WEBM_VP9}, |
71 #if defined(USE_PROPRIETARY_CODECS) | 71 #if defined(USE_PROPRIETARY_CODECS) |
72 {"mp4a", EME_CODEC_MP4_AAC}, | 72 {"mp4a", EME_CODEC_MP4_AAC}, |
73 {"avc1", EME_CODEC_MP4_AVC1}, | 73 {"avc1", EME_CODEC_MP4_AVC1}, |
74 {"avc3", EME_CODEC_MP4_AVC1} | 74 {"avc3", EME_CODEC_MP4_AVC1} |
75 #endif // defined(USE_PROPRIETARY_CODECS) | 75 #endif // defined(USE_PROPRIETARY_CODECS) |
76 }; | 76 }; |
77 | 77 |
78 static EmeConfigRule ConvertSessionTypeSupport( | |
79 EmeSessionTypeSupport support) { | |
80 switch (support) { | |
81 case EME_SESSION_TYPE_INVALID: | |
82 NOTREACHED(); | |
83 return EmeConfigRule::NOT_SUPPORTED; | |
84 case EME_SESSION_TYPE_NOT_SUPPORTED: | |
85 return EmeConfigRule::NOT_SUPPORTED; | |
86 case EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER: | |
87 return EmeConfigRule::IDENTIFIER_REQUIRED; | |
88 case EME_SESSION_TYPE_SUPPORTED: | |
89 return EmeConfigRule::SUPPORTED; | |
90 } | |
91 NOTREACHED(); | |
92 return EmeConfigRule::NOT_SUPPORTED; | |
93 } | |
94 | |
78 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { | 95 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { |
79 KeySystemInfo info; | 96 KeySystemInfo info; |
80 info.key_system = kClearKeyKeySystem; | 97 info.key_system = kClearKeyKeySystem; |
81 | 98 |
82 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: | 99 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: |
83 // http://developer.android.com/guide/appendix/media-formats.html | 100 // http://developer.android.com/guide/appendix/media-formats.html |
84 // VP9 support is device dependent. | 101 // VP9 support is device dependent. |
85 | 102 |
86 info.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM; | 103 info.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM; |
87 info.supported_codecs = EME_CODEC_WEBM_ALL; | 104 info.supported_codecs = EME_CODEC_WEBM_ALL; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 bool is_prefixed); | 199 bool is_prefixed); |
183 | 200 |
184 std::string GetKeySystemNameForUMA(const std::string& key_system) const; | 201 std::string GetKeySystemNameForUMA(const std::string& key_system) const; |
185 | 202 |
186 bool UseAesDecryptor(const std::string& concrete_key_system); | 203 bool UseAesDecryptor(const std::string& concrete_key_system); |
187 | 204 |
188 #if defined(ENABLE_PEPPER_CDMS) | 205 #if defined(ENABLE_PEPPER_CDMS) |
189 std::string GetPepperType(const std::string& concrete_key_system); | 206 std::string GetPepperType(const std::string& concrete_key_system); |
190 #endif | 207 #endif |
191 | 208 |
192 bool IsPersistentLicenseSessionSupported( | 209 EmeConfigRule GetRobustnessConfigRule( |
193 const std::string& key_system, | 210 const std::string& key_system, |
194 bool is_permission_granted); | 211 EmeMediaType media_type, |
212 EmeRobustness robustness); | |
195 | 213 |
196 bool IsPersistentReleaseMessageSessionSupported( | 214 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
215 const std::string& key_system); | |
216 | |
217 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( | |
218 const std::string& key_system); | |
219 | |
220 EmeConfigRule GetPersistentStateConfigRule( | |
197 const std::string& key_system, | 221 const std::string& key_system, |
198 bool is_permission_granted); | 222 EmeFeatureRequirement requirement); |
199 | 223 |
200 bool IsPersistentStateRequirementSupported( | 224 EmeConfigRule GetDistinctiveIdentifierConfigRule( |
201 const std::string& key_system, | 225 const std::string& key_system, |
202 EmeFeatureRequirement requirement, | 226 EmeFeatureRequirement requirement); |
203 bool is_permission_granted); | |
204 | |
205 bool IsDistinctiveIdentifierRequirementSupported( | |
206 const std::string& key_system, | |
207 EmeFeatureRequirement requirement, | |
208 bool is_permission_granted); | |
209 | 227 |
210 void AddContainerMask(const std::string& container, uint32 mask); | 228 void AddContainerMask(const std::string& container, uint32 mask); |
211 void AddCodecMask(const std::string& codec, uint32 mask); | 229 void AddCodecMask(const std::string& codec, uint32 mask); |
212 | 230 |
213 private: | 231 private: |
214 void InitializeUMAInfo(); | 232 void InitializeUMAInfo(); |
215 | 233 |
216 void UpdateSupportedKeySystems(); | 234 void UpdateSupportedKeySystems(); |
217 | 235 |
218 void AddConcreteSupportedKeySystems( | 236 void AddConcreteSupportedKeySystems( |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 } | 403 } |
386 | 404 |
387 void KeySystems::AddConcreteSupportedKeySystems( | 405 void KeySystems::AddConcreteSupportedKeySystems( |
388 const std::vector<KeySystemInfo>& concrete_key_systems) { | 406 const std::vector<KeySystemInfo>& concrete_key_systems) { |
389 DCHECK(thread_checker_.CalledOnValidThread()); | 407 DCHECK(thread_checker_.CalledOnValidThread()); |
390 DCHECK(concrete_key_system_map_.empty()); | 408 DCHECK(concrete_key_system_map_.empty()); |
391 DCHECK(parent_key_system_map_.empty()); | 409 DCHECK(parent_key_system_map_.empty()); |
392 | 410 |
393 for (const KeySystemInfo& info : concrete_key_systems) { | 411 for (const KeySystemInfo& info : concrete_key_systems) { |
394 DCHECK(!info.key_system.empty()); | 412 DCHECK(!info.key_system.empty()); |
395 DCHECK_NE(info.persistent_license_support, EME_SESSION_TYPE_INVALID); | 413 DCHECK(info.max_audio_robustness != EmeRobustness::INVALID); |
396 DCHECK_NE(info.persistent_release_message_support, | 414 DCHECK(info.max_video_robustness != EmeRobustness::INVALID); |
397 EME_SESSION_TYPE_INVALID); | 415 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID); |
398 // TODO(sandersd): Add REQUESTABLE and REQUESTABLE_WITH_PERMISSION for | 416 DCHECK(info.persistent_release_message_support != EME_SESSION_TYPE_INVALID); |
399 // persistent_state_support once we can block access per-CDM-instance | 417 DCHECK(info.persistent_state_support != EME_FEATURE_INVALID); |
400 // (http://crbug.com/457482). | 418 DCHECK(info.distinctive_identifier_support != EME_FEATURE_INVALID); |
401 DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED || | 419 |
402 info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED); | 420 // Supporting persistent state is a prerequsite for supporting persistent |
403 // TODO(sandersd): Allow REQUESTABLE_WITH_PERMISSION for all key systems on | 421 // sessions. |
404 // all platforms once we have proper enforcement (http://crbug.com/457482). | 422 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { |
405 // On Chrome OS, an ID will not be used without permission, but we cannot | 423 DCHECK(info.persistent_license_support == EME_SESSION_TYPE_NOT_SUPPORTED); |
406 // currently prevent the CDM from requesting the permission again when no | 424 DCHECK(info.persistent_release_message_support == |
407 // there was no initial prompt. Thus, we block "not-allowed" below. | 425 EME_SESSION_TYPE_NOT_SUPPORTED); |
408 #if defined(OS_CHROMEOS) | 426 } |
409 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || | 427 else if (info.persistent_state_support == |
410 (info.distinctive_identifier_support == | 428 EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER) { |
411 EME_FEATURE_REQUESTABLE_WITH_PERMISSION && | 429 // Must be either NOT_SUPPORTED or SUPPORTED_WITH_IDENTIFIER. |
412 info.key_system == kWidevineKeySystem) || | 430 DCHECK(info.persistent_license_support != EME_SESSION_TYPE_SUPPORTED); |
413 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); | 431 DCHECK(info.persistent_release_message_support != |
414 #else | 432 EME_SESSION_TYPE_SUPPORTED); |
415 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || | 433 } |
416 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); | 434 |
435 // persistent-release-message sessions are not currently supported. | |
436 // http://crbug.com/448888 | |
437 DCHECK(info.persistent_release_message_support == | |
438 EME_SESSION_TYPE_NOT_SUPPORTED); | |
439 | |
440 // Because an optional persistent state value is resolved after an optional | |
441 // distinctive identifier, persistent state requiring a distinctive | |
442 // identifier may not resolve correctly. | |
443 DCHECK(info.persistent_state_support != | |
444 EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER); | |
445 | |
446 // If supported, distinctive identifiers always require permission. | |
447 DCHECK(info.distinctive_identifier_support != EME_FEATURE_REQUESTABLE); | |
448 | |
449 // If distinctive identifiers are not supported, then no other features can | |
450 // require them. | |
451 if (info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED) { | |
452 DCHECK(info.persistent_license_support != | |
453 EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER); | |
454 DCHECK(info.persistent_release_message_support != | |
455 EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER); | |
456 } | |
457 | |
458 // Distinctive identifiers and persistent state can only be reliably blocked | |
459 // (and therefore be safely configurable) for Pepper-hosted key systems. For | |
460 // other platforms, only non-configurable values are valid. | |
461 bool can_block = false; | |
462 #if defined(ENABLE_PEPPER_CDMS) | |
463 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); | |
464 can_block = !info.pepper_type.empty(); | |
417 #endif | 465 #endif |
418 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { | 466 if (!can_block) { |
419 DCHECK_EQ(info.persistent_license_support, | 467 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || |
420 EME_SESSION_TYPE_NOT_SUPPORTED); | 468 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); |
421 DCHECK_EQ(info.persistent_release_message_support, | 469 DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED || |
422 EME_SESSION_TYPE_NOT_SUPPORTED); | 470 info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED); |
423 } | 471 } |
472 | |
424 DCHECK(!IsSupportedKeySystem(info.key_system)) | 473 DCHECK(!IsSupportedKeySystem(info.key_system)) |
425 << "Key system '" << info.key_system << "' already registered"; | 474 << "Key system '" << info.key_system << "' already registered"; |
426 DCHECK(!parent_key_system_map_.count(info.key_system)) | 475 DCHECK(!parent_key_system_map_.count(info.key_system)) |
427 << "'" << info.key_system << "' is already registered as a parent"; | 476 << "'" << info.key_system << "' is already registered as a parent"; |
428 #if defined(ENABLE_PEPPER_CDMS) | |
429 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); | |
430 #endif | |
431 | |
432 concrete_key_system_map_[info.key_system] = info; | 477 concrete_key_system_map_[info.key_system] = info; |
433 | |
434 if (!info.parent_key_system.empty()) { | 478 if (!info.parent_key_system.empty()) { |
435 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) | 479 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
436 << "Parent '" << info.parent_key_system << "' " | 480 << "Parent '" << info.parent_key_system << "' " |
437 << "already registered concrete"; | 481 << "already registered concrete"; |
438 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) | 482 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
439 << "Parent '" << info.parent_key_system << "' already registered"; | 483 << "Parent '" << info.parent_key_system << "' already registered"; |
440 parent_key_system_map_[info.parent_key_system] = info.key_system; | 484 parent_key_system_map_[info.parent_key_system] = info.key_system; |
441 } | 485 } |
442 } | 486 } |
443 } | 487 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 655 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
612 return std::string(); | 656 return std::string(); |
613 } | 657 } |
614 | 658 |
615 const std::string& type = key_system_iter->second.pepper_type; | 659 const std::string& type = key_system_iter->second.pepper_type; |
616 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 660 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
617 return type; | 661 return type; |
618 } | 662 } |
619 #endif | 663 #endif |
620 | 664 |
621 bool KeySystems::IsPersistentLicenseSessionSupported( | 665 EmeConfigRule KeySystems::GetRobustnessConfigRule( |
622 const std::string& key_system, | 666 const std::string& key_system, |
623 bool is_permission_granted) { | 667 EmeMediaType media_type, |
668 EmeRobustness robustness) { | |
669 DCHECK(thread_checker_.CalledOnValidThread()); | |
670 | |
671 if (robustness == EmeRobustness::INVALID) | |
672 return EmeConfigRule::NOT_SUPPORTED; | |
673 if (robustness == EmeRobustness::EMPTY) | |
674 return EmeConfigRule::SUPPORTED; | |
675 | |
676 KeySystemInfoMap::const_iterator key_system_iter = | |
677 concrete_key_system_map_.find(key_system); | |
678 if (key_system_iter == concrete_key_system_map_.end()) { | |
679 NOTREACHED(); | |
680 return EmeConfigRule::NOT_SUPPORTED; | |
681 } | |
682 | |
683 EmeRobustness max_robustness = EmeRobustness::INVALID; | |
684 switch (media_type) { | |
685 case EmeMediaType::AUDIO: | |
686 max_robustness = key_system_iter->second.max_audio_robustness; | |
687 break; | |
688 case EmeMediaType::VIDEO: | |
689 max_robustness = key_system_iter->second.max_video_robustness; | |
690 break; | |
691 } | |
692 | |
693 // We can compare robustness levels whenever they are not HW_SECURE_CRYPTO | |
694 // and SW_SECURE_DECODE in some order. If they are exactly those two then the | |
695 // robustness requirement is not supported. | |
gunsch
2015/03/24 00:12:00
This seems awkward---isn't there an implicit assum
sandersd (OOO until July 31)
2015/03/24 00:21:53
There is no such implicit assumption, and that ass
| |
696 if ((max_robustness == EmeRobustness::HW_SECURE_CRYPTO && | |
697 robustness == EmeRobustness::SW_SECURE_DECODE) || | |
698 (max_robustness == EmeRobustness::SW_SECURE_DECODE && | |
699 robustness == EmeRobustness::HW_SECURE_CRYPTO) || | |
700 robustness > max_robustness) { | |
701 return EmeConfigRule::NOT_SUPPORTED; | |
702 } | |
703 | |
704 #if defined(OS_CHROMEOS) | |
705 if (key_system == kWidevineKeySystem) { | |
706 // Hardware security requires remote attestation. | |
707 if (robustness >= EmeRobustness::HW_SECURE_CRYPTO) | |
708 return EmeConfigRule::IDENTIFIER_REQUIRED; | |
709 | |
710 // For video, recommend remote attestation if HW_SECURE_ALL is available, | |
711 // because it enables hardware accelerated decoding. | |
712 // TODO(sandersd): Only do this when hardware accelerated decoding is | |
713 // available for the requested codecs. | |
714 if (media_type == EmeMediaType::VIDEO && | |
715 max_robustness == EmeRobustness::HW_SECURE_ALL) { | |
716 return EmeConfigRule::IDENTIFIER_RECOMMENDED; | |
717 } | |
718 } | |
719 #endif // defined(OS_CHROMEOS) | |
720 | |
721 return EmeConfigRule::SUPPORTED; | |
722 } | |
723 | |
724 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( | |
725 const std::string& key_system) { | |
624 DCHECK(thread_checker_.CalledOnValidThread()); | 726 DCHECK(thread_checker_.CalledOnValidThread()); |
625 | 727 |
626 KeySystemInfoMap::const_iterator key_system_iter = | 728 KeySystemInfoMap::const_iterator key_system_iter = |
627 concrete_key_system_map_.find(key_system); | 729 concrete_key_system_map_.find(key_system); |
628 if (key_system_iter == concrete_key_system_map_.end()) { | 730 if (key_system_iter == concrete_key_system_map_.end()) { |
629 NOTREACHED(); | 731 NOTREACHED(); |
630 return false; | 732 return EmeConfigRule::NOT_SUPPORTED; |
631 } | 733 } |
632 | 734 return ConvertSessionTypeSupport( |
633 switch (key_system_iter->second.persistent_license_support) { | 735 key_system_iter->second.persistent_license_support); |
634 case EME_SESSION_TYPE_INVALID: | |
635 NOTREACHED(); | |
636 return false; | |
637 case EME_SESSION_TYPE_NOT_SUPPORTED: | |
638 return false; | |
639 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION: | |
640 return is_permission_granted; | |
641 case EME_SESSION_TYPE_SUPPORTED: | |
642 return true; | |
643 } | |
644 | |
645 NOTREACHED(); | |
646 return false; | |
647 } | 736 } |
648 | 737 |
649 bool KeySystems::IsPersistentReleaseMessageSessionSupported( | 738 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( |
650 const std::string& key_system, | 739 const std::string& key_system) { |
651 bool is_permission_granted) { | |
652 DCHECK(thread_checker_.CalledOnValidThread()); | 740 DCHECK(thread_checker_.CalledOnValidThread()); |
653 | 741 |
654 KeySystemInfoMap::const_iterator key_system_iter = | 742 KeySystemInfoMap::const_iterator key_system_iter = |
655 concrete_key_system_map_.find(key_system); | 743 concrete_key_system_map_.find(key_system); |
656 if (key_system_iter == concrete_key_system_map_.end()) { | 744 if (key_system_iter == concrete_key_system_map_.end()) { |
657 NOTREACHED(); | 745 NOTREACHED(); |
658 return false; | 746 return EmeConfigRule::NOT_SUPPORTED; |
659 } | 747 } |
660 | 748 return ConvertSessionTypeSupport( |
661 switch (key_system_iter->second.persistent_release_message_support) { | 749 key_system_iter->second.persistent_release_message_support); |
662 case EME_SESSION_TYPE_INVALID: | |
663 NOTREACHED(); | |
664 return false; | |
665 case EME_SESSION_TYPE_NOT_SUPPORTED: | |
666 return false; | |
667 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION: | |
668 return is_permission_granted; | |
669 case EME_SESSION_TYPE_SUPPORTED: | |
670 return true; | |
671 } | |
672 | |
673 NOTREACHED(); | |
674 return false; | |
675 } | 750 } |
676 | 751 |
677 bool KeySystems::IsPersistentStateRequirementSupported( | 752 EmeConfigRule KeySystems::GetPersistentStateConfigRule( |
678 const std::string& key_system, | 753 const std::string& key_system, |
679 EmeFeatureRequirement requirement, | 754 EmeFeatureRequirement requirement) { |
680 bool is_permission_granted) { | |
681 DCHECK(thread_checker_.CalledOnValidThread()); | 755 DCHECK(thread_checker_.CalledOnValidThread()); |
682 | 756 |
683 KeySystemInfoMap::const_iterator key_system_iter = | 757 KeySystemInfoMap::const_iterator key_system_iter = |
684 concrete_key_system_map_.find(key_system); | 758 concrete_key_system_map_.find(key_system); |
685 if (key_system_iter == concrete_key_system_map_.end()) { | 759 if (key_system_iter == concrete_key_system_map_.end()) { |
686 NOTREACHED(); | 760 NOTREACHED(); |
687 return false; | 761 return EmeConfigRule::NOT_SUPPORTED; |
688 } | 762 } |
689 | 763 |
690 switch (key_system_iter->second.persistent_state_support) { | 764 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we |
691 case EME_FEATURE_INVALID: | 765 // return the least restrictive of the two rules; this guarantees that if |
692 NOTREACHED(); | 766 // OPTIONAL is accepted, then it can always be resolved to some value. (In |
693 return false; | 767 // fact OPTIONAL is always accepted, because the least restrictive rule is |
694 case EME_FEATURE_NOT_SUPPORTED: | 768 // always SUPPORTED.) |
695 return requirement != EME_FEATURE_REQUIRED; | 769 // |
696 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 770 // Note that even if permission is not required for persistent state, it may |
697 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 771 // be required for specific persistent session types. |
698 case EME_FEATURE_REQUESTABLE: | 772 // |
699 return true; | 773 // NOT_ALLOWED OPTIONAL REQUIRED |
700 case EME_FEATURE_ALWAYS_ENABLED: | 774 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED |
701 // Persistent state does not require user permission, but the session | 775 // REQUESTABLE_WITH_IDENTIFIER SUPPORTED SUPPORTED IDENTIFIER_REQ |
702 // types that use it might. | 776 // REQUESTABLE SUPPORTED SUPPORTED SUPPORTED |
703 return requirement != EME_FEATURE_NOT_ALLOWED; | 777 // ALWAYS_ENABLED NOT_SUPPORTED SUPPORTED SUPPORTED |
778 EmeFeatureSupport support = key_system_iter->second.persistent_state_support; | |
779 if (support == EME_FEATURE_NOT_SUPPORTED && | |
780 requirement == EME_FEATURE_REQUIRED) { | |
781 return EmeConfigRule::NOT_SUPPORTED; | |
704 } | 782 } |
705 | 783 if (support == EME_FEATURE_ALWAYS_ENABLED && |
706 NOTREACHED(); | 784 requirement == EME_FEATURE_NOT_ALLOWED) { |
707 return false; | 785 return EmeConfigRule::NOT_SUPPORTED; |
786 } | |
787 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && | |
788 requirement == EME_FEATURE_REQUIRED) { | |
789 return EmeConfigRule::IDENTIFIER_REQUIRED; | |
790 } | |
791 return EmeConfigRule::SUPPORTED; | |
708 } | 792 } |
709 | 793 |
710 bool KeySystems::IsDistinctiveIdentifierRequirementSupported( | 794 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( |
711 const std::string& key_system, | 795 const std::string& key_system, |
712 EmeFeatureRequirement requirement, | 796 EmeFeatureRequirement requirement) { |
713 bool is_permission_granted) { | |
714 DCHECK(thread_checker_.CalledOnValidThread()); | 797 DCHECK(thread_checker_.CalledOnValidThread()); |
715 | 798 |
716 KeySystemInfoMap::const_iterator key_system_iter = | 799 KeySystemInfoMap::const_iterator key_system_iter = |
717 concrete_key_system_map_.find(key_system); | 800 concrete_key_system_map_.find(key_system); |
718 if (key_system_iter == concrete_key_system_map_.end()) { | 801 if (key_system_iter == concrete_key_system_map_.end()) { |
719 NOTREACHED(); | 802 NOTREACHED(); |
720 return false; | 803 return EmeConfigRule::NOT_SUPPORTED; |
721 } | 804 } |
722 | 805 |
723 switch (key_system_iter->second.distinctive_identifier_support) { | 806 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, |
724 case EME_FEATURE_INVALID: | 807 // we return the least restrictive of the two rules; this guarantees that if |
725 NOTREACHED(); | 808 // OPTIONAL is accepted, then it can always be resolved to some value. |
726 return false; | 809 // |
727 case EME_FEATURE_NOT_SUPPORTED: | 810 // NOT_ALLOWED OPTIONAL REQUIRED |
728 return requirement != EME_FEATURE_REQUIRED; | 811 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED |
729 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 812 // REQUESTABLE_WITH_IDENTIFIER SUPPORTED SUPPORTED IDENTIFIER_REQ |
730 // TODO(sandersd): Remove this hack once crbug.com/457482 and | 813 // ALWAYS_ENABLED NOT_SUPPORTED IDENTIFIER_REQ IDENTIFIER_REQ |
731 // crbug.com/460616 are addressed. | 814 EmeFeatureSupport support = |
732 // We cannot currently enforce "not-allowed", so don't allow it. | 815 key_system_iter->second.distinctive_identifier_support; |
733 // Note: Removing this check will expose crbug.com/460616. | 816 DCHECK(support != EME_FEATURE_REQUESTABLE); |
734 if (requirement == EME_FEATURE_NOT_ALLOWED) | 817 if (support == EME_FEATURE_NOT_SUPPORTED && |
735 return false; | 818 requirement == EME_FEATURE_REQUIRED) { |
736 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 819 return EmeConfigRule::NOT_SUPPORTED; |
737 case EME_FEATURE_REQUESTABLE: | |
738 NOTREACHED(); | |
739 return true; | |
740 case EME_FEATURE_ALWAYS_ENABLED: | |
741 // Distinctive identifiers always require user permission. | |
742 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted; | |
743 } | 820 } |
744 | 821 if (support == EME_FEATURE_ALWAYS_ENABLED && |
745 NOTREACHED(); | 822 requirement == EME_FEATURE_NOT_ALLOWED) { |
746 return false; | 823 return EmeConfigRule::NOT_SUPPORTED; |
824 } | |
825 if (support == EME_FEATURE_ALWAYS_ENABLED || | |
826 requirement == EME_FEATURE_REQUIRED) { | |
827 return EmeConfigRule::IDENTIFIER_REQUIRED; | |
828 } | |
829 return EmeConfigRule::SUPPORTED; | |
747 } | 830 } |
748 | 831 |
749 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 832 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
750 DCHECK(thread_checker_.CalledOnValidThread()); | 833 DCHECK(thread_checker_.CalledOnValidThread()); |
751 DCHECK(!container_to_codec_mask_map_.count(container)); | 834 DCHECK(!container_to_codec_mask_map_.count(container)); |
752 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 835 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
753 } | 836 } |
754 | 837 |
755 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 838 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
756 DCHECK(thread_checker_.CalledOnValidThread()); | 839 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
841 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 924 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
842 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 925 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
843 } | 926 } |
844 | 927 |
845 #if defined(ENABLE_PEPPER_CDMS) | 928 #if defined(ENABLE_PEPPER_CDMS) |
846 std::string GetPepperType(const std::string& concrete_key_system) { | 929 std::string GetPepperType(const std::string& concrete_key_system) { |
847 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 930 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
848 } | 931 } |
849 #endif | 932 #endif |
850 | 933 |
851 bool IsPersistentLicenseSessionSupported( | 934 EmeConfigRule GetRobustnessConfigRule( |
852 const std::string& key_system, | 935 const std::string& key_system, |
853 bool is_permission_granted) { | 936 EmeMediaType media_type, |
854 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported( | 937 EmeRobustness robustness) { |
855 key_system, is_permission_granted); | 938 return KeySystems::GetInstance().GetRobustnessConfigRule( |
939 key_system, media_type, robustness); | |
856 } | 940 } |
857 | 941 |
858 bool IsPersistentReleaseMessageSessionSupported( | 942 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
859 const std::string& key_system, | 943 const std::string& key_system) { |
860 bool is_permission_granted) { | 944 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule( |
861 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported( | 945 key_system); |
862 key_system, is_permission_granted); | |
863 } | 946 } |
864 | 947 |
865 bool IsPersistentStateRequirementSupported( | 948 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( |
866 const std::string& key_system, | 949 const std::string& key_system) { |
867 EmeFeatureRequirement requirement, | 950 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule( |
868 bool is_permission_granted) { | 951 key_system); |
869 return KeySystems::GetInstance().IsPersistentStateRequirementSupported( | |
870 key_system, requirement, is_permission_granted); | |
871 } | 952 } |
872 | 953 |
873 bool IsDistinctiveIdentifierRequirementSupported( | 954 EmeConfigRule GetPersistentStateConfigRule( |
874 const std::string& key_system, | 955 const std::string& key_system, |
875 EmeFeatureRequirement requirement, | 956 EmeFeatureRequirement requirement) { |
876 bool is_permission_granted) { | 957 return KeySystems::GetInstance().GetPersistentStateConfigRule( |
877 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported( | 958 key_system, requirement); |
878 key_system, requirement, is_permission_granted); | 959 } |
960 | |
961 EmeConfigRule GetDistinctiveIdentifierConfigRule( | |
962 const std::string& key_system, | |
963 EmeFeatureRequirement requirement) { | |
964 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule( | |
965 key_system, requirement); | |
879 } | 966 } |
880 | 967 |
881 // These two functions are for testing purpose only. The declaration in the | 968 // These two functions are for testing purpose only. The declaration in the |
882 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used | 969 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used |
883 // by tests but not non-test code. However, this .cc file is compiled as part of | 970 // by tests but not non-test code. However, this .cc file is compiled as part of |
884 // "media" where "UNIT_TEST" is not defined. So we need to specify | 971 // "media" where "UNIT_TEST" is not defined. So we need to specify |
885 // "MEDIA_EXPORT" here again so that they are visible to tests. | 972 // "MEDIA_EXPORT" here again so that they are visible to tests. |
886 | 973 |
887 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 974 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
888 KeySystems::GetInstance().AddContainerMask(container, mask); | 975 KeySystems::GetInstance().AddContainerMask(container, mask); |
889 } | 976 } |
890 | 977 |
891 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 978 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
892 KeySystems::GetInstance().AddCodecMask(codec, mask); | 979 KeySystems::GetInstance().AddCodecMask(codec, mask); |
893 } | 980 } |
894 | 981 |
895 } // namespace media | 982 } // namespace media |
OLD | NEW |