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