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_PERMISSION: | |
87 return EmeConfigRule::PERMISSION_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 // If persistent state is not supported, then persistent sessions are not |
403 // TODO(sandersd): Allow REQUESTABLE_WITH_PERMISSION for all key systems on | 421 // either. This is enforced in requestMediaKeySystemAccess(), but we want |
404 // all platforms once we have proper enforcement (http://crbug.com/457482). | 422 // to catch the miconfiguration early. |
405 // On Chrome OS, an ID will not be used without permission, but we cannot | 423 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { |
406 // currently prevent the CDM from requesting the permission again when no | 424 DCHECK(info.persistent_license_support == EME_SESSION_TYPE_NOT_SUPPORTED); |
407 // there was no initial prompt. Thus, we block "not-allowed" below. | 425 DCHECK(info.persistent_release_message_support == |
408 #if defined(OS_CHROMEOS) | 426 EME_SESSION_TYPE_NOT_SUPPORTED); |
409 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || | 427 } |
410 (info.distinctive_identifier_support == | 428 |
ddorwin
2015/03/16 23:25:08
// Do not allow registration because it is not cur
sandersd (OOO until July 31)
2015/03/17 22:10:39
Done.
| |
411 EME_FEATURE_REQUESTABLE_WITH_PERMISSION && | 429 // Distinctive identifiers always require permission. |
412 info.key_system == kWidevineKeySystem) || | 430 DCHECK(info.distinctive_identifier_support != EME_FEATURE_REQUESTABLE); |
413 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); | 431 |
414 #else | 432 // Distinctive identifiers and persistent state can only be reliably blocked |
415 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || | 433 // for PPAPI key systems. |
ddorwin
2015/03/16 23:25:08
nit: s/PPAPI/Pepper-hosted/
new sentence - someth
sandersd (OOO until July 31)
2015/03/17 22:10:39
Done.
| |
416 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); | 434 bool can_block = false; |
435 #if defined(ENABLE_PEPPER_CDMS) | |
436 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); | |
437 can_block = !info.pepper_type.empty(); | |
417 #endif | 438 #endif |
418 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { | 439 if (!can_block) { |
419 DCHECK_EQ(info.persistent_license_support, | 440 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || |
ddorwin
2015/03/16 23:25:08
Should we be checking persistent state too?
sandersd (OOO until July 31)
2015/03/17 22:10:39
Done.
| |
420 EME_SESSION_TYPE_NOT_SUPPORTED); | 441 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); |
421 DCHECK_EQ(info.persistent_release_message_support, | |
422 EME_SESSION_TYPE_NOT_SUPPORTED); | |
423 } | 442 } |
443 | |
424 DCHECK(!IsSupportedKeySystem(info.key_system)) | 444 DCHECK(!IsSupportedKeySystem(info.key_system)) |
425 << "Key system '" << info.key_system << "' already registered"; | 445 << "Key system '" << info.key_system << "' already registered"; |
426 DCHECK(!parent_key_system_map_.count(info.key_system)) | 446 DCHECK(!parent_key_system_map_.count(info.key_system)) |
427 << "'" << info.key_system << "' is already registered as a parent"; | 447 << "'" << 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; | 448 concrete_key_system_map_[info.key_system] = info; |
433 | |
434 if (!info.parent_key_system.empty()) { | 449 if (!info.parent_key_system.empty()) { |
435 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) | 450 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
436 << "Parent '" << info.parent_key_system << "' " | 451 << "Parent '" << info.parent_key_system << "' " |
437 << "already registered concrete"; | 452 << "already registered concrete"; |
438 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) | 453 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
439 << "Parent '" << info.parent_key_system << "' already registered"; | 454 << "Parent '" << info.parent_key_system << "' already registered"; |
440 parent_key_system_map_[info.parent_key_system] = info.key_system; | 455 parent_key_system_map_[info.parent_key_system] = info.key_system; |
441 } | 456 } |
442 } | 457 } |
443 } | 458 } |
(...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"; | 626 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
612 return std::string(); | 627 return std::string(); |
613 } | 628 } |
614 | 629 |
615 const std::string& type = key_system_iter->second.pepper_type; | 630 const std::string& type = key_system_iter->second.pepper_type; |
616 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 631 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
617 return type; | 632 return type; |
618 } | 633 } |
619 #endif | 634 #endif |
620 | 635 |
621 bool KeySystems::IsPersistentLicenseSessionSupported( | 636 EmeConfigRule KeySystems::GetRobustnessConfigRule( |
622 const std::string& key_system, | 637 const std::string& key_system, |
623 bool is_permission_granted) { | 638 EmeMediaType media_type, |
639 EmeRobustness robustness) { | |
640 DCHECK(thread_checker_.CalledOnValidThread()); | |
641 | |
642 if (robustness == EmeRobustness::INVALID) | |
643 return EmeConfigRule::NOT_SUPPORTED; | |
644 if (robustness == EmeRobustness::EMPTY) | |
645 return EmeConfigRule::SUPPORTED; | |
646 | |
647 KeySystemInfoMap::const_iterator key_system_iter = | |
648 concrete_key_system_map_.find(key_system); | |
649 if (key_system_iter == concrete_key_system_map_.end()) { | |
650 NOTREACHED(); | |
651 return EmeConfigRule::NOT_SUPPORTED; | |
652 } | |
653 | |
654 EmeRobustness max_robustness = EmeRobustness::INVALID; | |
655 switch (media_type) { | |
656 case EmeMediaType::AUDIO: | |
657 max_robustness = key_system_iter->second.max_audio_robustness; | |
658 break; | |
659 case EmeMediaType::VIDEO: | |
660 max_robustness = key_system_iter->second.max_video_robustness; | |
661 break; | |
662 } | |
663 | |
664 #if defined(OS_CHROMEOS) | |
665 if (key_system == kWidevineKeySystem) { | |
666 // CrOS Widevine supports L1 when remote attestation succeeds, but the | |
667 // encrypted media permission is required to do so. Even when not strictly | |
668 // requred, we prefer to support L1 for video because it allows hardware | |
669 // acceleration to be used. | |
670 // TODO(sandersd): Only recommend permission when hardware acceleration is | |
671 // available for the specific codecs requested. | |
672 EmeConfigRule recommendation = | |
673 (media_type == EmeMediaType::VIDEO) | |
674 ? EmeConfigRule::PERMISSION_RECOMMENDED | |
675 : EmeConfigRule::SUPPORTED; | |
676 return (robustness <= max_robustness) | |
ddorwin
2015/03/16 23:25:08
You could get rid of this by having
#else
recomm
sandersd (OOO until July 31)
2015/03/17 22:10:39
See next comment.
| |
677 ? recommendation | |
678 : EmeConfigRule::PERMISSION_REQUIRED; | |
ddorwin
2015/03/16 23:25:08
Otherwise: NOT_SUPPORTED, right?
sandersd (OOO until July 31)
2015/03/17 22:10:39
This is confusing because I am imagining that max_
| |
679 } | |
680 #endif // defined(OS_CHROMEOS) | |
681 | |
682 return (robustness <= max_robustness) | |
683 ? EmeConfigRule::SUPPORTED | |
684 : EmeConfigRule::NOT_SUPPORTED; | |
685 } | |
686 | |
687 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( | |
688 const std::string& key_system) { | |
624 DCHECK(thread_checker_.CalledOnValidThread()); | 689 DCHECK(thread_checker_.CalledOnValidThread()); |
625 | 690 |
626 KeySystemInfoMap::const_iterator key_system_iter = | 691 KeySystemInfoMap::const_iterator key_system_iter = |
627 concrete_key_system_map_.find(key_system); | 692 concrete_key_system_map_.find(key_system); |
628 if (key_system_iter == concrete_key_system_map_.end()) { | 693 if (key_system_iter == concrete_key_system_map_.end()) { |
629 NOTREACHED(); | 694 NOTREACHED(); |
630 return false; | 695 return EmeConfigRule::NOT_SUPPORTED; |
631 } | 696 } |
632 | 697 return ConvertSessionTypeSupport( |
633 switch (key_system_iter->second.persistent_license_support) { | 698 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 } | 699 } |
648 | 700 |
649 bool KeySystems::IsPersistentReleaseMessageSessionSupported( | 701 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( |
650 const std::string& key_system, | 702 const std::string& key_system) { |
651 bool is_permission_granted) { | |
652 DCHECK(thread_checker_.CalledOnValidThread()); | 703 DCHECK(thread_checker_.CalledOnValidThread()); |
653 | 704 |
654 KeySystemInfoMap::const_iterator key_system_iter = | 705 KeySystemInfoMap::const_iterator key_system_iter = |
655 concrete_key_system_map_.find(key_system); | 706 concrete_key_system_map_.find(key_system); |
656 if (key_system_iter == concrete_key_system_map_.end()) { | 707 if (key_system_iter == concrete_key_system_map_.end()) { |
657 NOTREACHED(); | 708 NOTREACHED(); |
658 return false; | 709 return EmeConfigRule::NOT_SUPPORTED; |
659 } | 710 } |
660 | 711 return ConvertSessionTypeSupport( |
661 switch (key_system_iter->second.persistent_release_message_support) { | 712 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 } | 713 } |
676 | 714 |
677 bool KeySystems::IsPersistentStateRequirementSupported( | 715 EmeConfigRule KeySystems::GetPersistentStateConfigRule( |
678 const std::string& key_system, | 716 const std::string& key_system, |
679 EmeFeatureRequirement requirement, | 717 EmeFeatureRequirement requirement) { |
680 bool is_permission_granted) { | |
681 DCHECK(thread_checker_.CalledOnValidThread()); | 718 DCHECK(thread_checker_.CalledOnValidThread()); |
682 | 719 |
683 KeySystemInfoMap::const_iterator key_system_iter = | 720 KeySystemInfoMap::const_iterator key_system_iter = |
684 concrete_key_system_map_.find(key_system); | 721 concrete_key_system_map_.find(key_system); |
685 if (key_system_iter == concrete_key_system_map_.end()) { | 722 if (key_system_iter == concrete_key_system_map_.end()) { |
686 NOTREACHED(); | 723 NOTREACHED(); |
687 return false; | 724 return EmeConfigRule::NOT_SUPPORTED; |
688 } | 725 } |
689 | 726 |
690 switch (key_system_iter->second.persistent_state_support) { | 727 EmeFeatureSupport support = key_system_iter->second.persistent_state_support; |
691 case EME_FEATURE_INVALID: | 728 if (support == EME_FEATURE_NOT_SUPPORTED && |
692 NOTREACHED(); | 729 requirement == EME_FEATURE_REQUIRED) { |
693 return false; | 730 return EmeConfigRule::NOT_SUPPORTED; |
694 case EME_FEATURE_NOT_SUPPORTED: | 731 } |
695 return requirement != EME_FEATURE_REQUIRED; | 732 if (support == EME_FEATURE_ALWAYS_ENABLED && |
696 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 733 requirement == EME_FEATURE_NOT_ALLOWED) { |
ddorwin
2015/03/16 23:25:08
It is line 440 that ensures that EME_FEATURE_REQUE
sandersd (OOO until July 31)
2015/03/17 22:10:39
It turns out that the state table is really simple
| |
697 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 734 return EmeConfigRule::NOT_SUPPORTED; |
698 case EME_FEATURE_REQUESTABLE: | |
699 return true; | |
700 case EME_FEATURE_ALWAYS_ENABLED: | |
701 // Persistent state does not require user permission, but the session | |
702 // types that use it might. | |
703 return requirement != EME_FEATURE_NOT_ALLOWED; | |
704 } | 735 } |
705 | 736 |
706 NOTREACHED(); | 737 // Permission is required only if the feature requires it; permission may |
707 return false; | 738 // still be required for individual persistent session types. Permission |
739 // for optional requirements will be handled when they are resolved to | |
ddorwin
2015/03/16 23:25:08
Just so I understand, EME_FEATURE_OPTIONAL could g
sandersd (OOO until July 31)
2015/03/17 22:10:39
Indeed.
| |
740 // a specific value. | |
741 if (support == EME_FEATURE_REQUESTABLE_WITH_PERMISSION && | |
742 requirement == EME_FEATURE_REQUIRED) { | |
743 return EmeConfigRule::PERMISSION_REQUIRED; | |
744 } | |
745 return EmeConfigRule::SUPPORTED; | |
708 } | 746 } |
709 | 747 |
710 bool KeySystems::IsDistinctiveIdentifierRequirementSupported( | 748 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( |
711 const std::string& key_system, | 749 const std::string& key_system, |
712 EmeFeatureRequirement requirement, | 750 EmeFeatureRequirement requirement) { |
713 bool is_permission_granted) { | |
714 DCHECK(thread_checker_.CalledOnValidThread()); | 751 DCHECK(thread_checker_.CalledOnValidThread()); |
715 | 752 |
716 KeySystemInfoMap::const_iterator key_system_iter = | 753 KeySystemInfoMap::const_iterator key_system_iter = |
717 concrete_key_system_map_.find(key_system); | 754 concrete_key_system_map_.find(key_system); |
718 if (key_system_iter == concrete_key_system_map_.end()) { | 755 if (key_system_iter == concrete_key_system_map_.end()) { |
719 NOTREACHED(); | 756 NOTREACHED(); |
720 return false; | 757 return EmeConfigRule::NOT_SUPPORTED; |
721 } | 758 } |
722 | 759 |
723 switch (key_system_iter->second.distinctive_identifier_support) { | 760 EmeFeatureSupport support = |
724 case EME_FEATURE_INVALID: | 761 key_system_iter->second.distinctive_identifier_support; |
725 NOTREACHED(); | 762 if (support == EME_FEATURE_NOT_SUPPORTED && |
726 return false; | 763 requirement == EME_FEATURE_REQUIRED) { |
727 case EME_FEATURE_NOT_SUPPORTED: | 764 return EmeConfigRule::NOT_SUPPORTED; |
728 return requirement != EME_FEATURE_REQUIRED; | 765 } |
729 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 766 if (support == EME_FEATURE_ALWAYS_ENABLED && |
730 // TODO(sandersd): Remove this hack once crbug.com/457482 and | 767 requirement == EME_FEATURE_NOT_ALLOWED) { |
ddorwin
2015/03/16 23:25:08
ditto
sandersd (OOO until July 31)
2015/03/17 22:10:39
Acknowledged.
| |
731 // crbug.com/460616 are addressed. | 768 return EmeConfigRule::NOT_SUPPORTED; |
732 // We cannot currently enforce "not-allowed", so don't allow it. | |
733 // Note: Removing this check will expose crbug.com/460616. | |
734 if (requirement == EME_FEATURE_NOT_ALLOWED) | |
735 return false; | |
736 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | |
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 } | 769 } |
744 | 770 |
745 NOTREACHED(); | 771 // Permission is always required, but permission for optional requirements |
746 return false; | 772 // will be handled when they are resolved to a specific value. |
773 if (requirement == EME_FEATURE_REQUIRED) | |
774 return EmeConfigRule::PERMISSION_REQUIRED; | |
775 return EmeConfigRule::SUPPORTED; | |
747 } | 776 } |
748 | 777 |
749 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 778 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
750 DCHECK(thread_checker_.CalledOnValidThread()); | 779 DCHECK(thread_checker_.CalledOnValidThread()); |
751 DCHECK(!container_to_codec_mask_map_.count(container)); | 780 DCHECK(!container_to_codec_mask_map_.count(container)); |
752 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 781 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
753 } | 782 } |
754 | 783 |
755 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 784 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
756 DCHECK(thread_checker_.CalledOnValidThread()); | 785 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) { | 870 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
842 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 871 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
843 } | 872 } |
844 | 873 |
845 #if defined(ENABLE_PEPPER_CDMS) | 874 #if defined(ENABLE_PEPPER_CDMS) |
846 std::string GetPepperType(const std::string& concrete_key_system) { | 875 std::string GetPepperType(const std::string& concrete_key_system) { |
847 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 876 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
848 } | 877 } |
849 #endif | 878 #endif |
850 | 879 |
851 bool IsPersistentLicenseSessionSupported( | 880 EmeConfigRule GetRobustnessConfigRule( |
852 const std::string& key_system, | 881 const std::string& key_system, |
853 bool is_permission_granted) { | 882 EmeMediaType media_type, |
854 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported( | 883 EmeRobustness robustness) { |
855 key_system, is_permission_granted); | 884 return KeySystems::GetInstance().GetRobustnessConfigRule( |
885 key_system, media_type, robustness); | |
856 } | 886 } |
857 | 887 |
858 bool IsPersistentReleaseMessageSessionSupported( | 888 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
859 const std::string& key_system, | 889 const std::string& key_system) { |
860 bool is_permission_granted) { | 890 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule( |
861 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported( | 891 key_system); |
862 key_system, is_permission_granted); | |
863 } | 892 } |
864 | 893 |
865 bool IsPersistentStateRequirementSupported( | 894 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( |
866 const std::string& key_system, | 895 const std::string& key_system) { |
867 EmeFeatureRequirement requirement, | 896 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule( |
868 bool is_permission_granted) { | 897 key_system); |
869 return KeySystems::GetInstance().IsPersistentStateRequirementSupported( | |
870 key_system, requirement, is_permission_granted); | |
871 } | 898 } |
872 | 899 |
873 bool IsDistinctiveIdentifierRequirementSupported( | 900 EmeConfigRule GetPersistentStateConfigRule( |
874 const std::string& key_system, | 901 const std::string& key_system, |
875 EmeFeatureRequirement requirement, | 902 EmeFeatureRequirement requirement) { |
876 bool is_permission_granted) { | 903 return KeySystems::GetInstance().GetPersistentStateConfigRule( |
877 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported( | 904 key_system, requirement); |
878 key_system, requirement, is_permission_granted); | 905 } |
906 | |
907 EmeConfigRule GetDistinctiveIdentifierConfigRule( | |
908 const std::string& key_system, | |
909 EmeFeatureRequirement requirement) { | |
910 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule( | |
911 key_system, requirement); | |
879 } | 912 } |
880 | 913 |
881 // These two functions are for testing purpose only. The declaration in the | 914 // 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 | 915 // 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 | 916 // 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 | 917 // "media" where "UNIT_TEST" is not defined. So we need to specify |
885 // "MEDIA_EXPORT" here again so that they are visible to tests. | 918 // "MEDIA_EXPORT" here again so that they are visible to tests. |
886 | 919 |
887 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 920 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
888 KeySystems::GetInstance().AddContainerMask(container, mask); | 921 KeySystems::GetInstance().AddContainerMask(container, mask); |
889 } | 922 } |
890 | 923 |
891 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 924 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
892 KeySystems::GetInstance().AddCodecMask(codec, mask); | 925 KeySystems::GetInstance().AddCodecMask(codec, mask); |
893 } | 926 } |
894 | 927 |
895 } // namespace media | 928 } // namespace media |
OLD | NEW |