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

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

Issue 1005903003: Implement robustness strings in requestMediaKeySystemAccess(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify CrOS Widevine robustness rules. Created 5 years, 9 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 if (info.persistent_state_support ==
ddorwin 2015/03/18 01:08:04 nit: else if. You could also make this a switch s
sandersd (OOO until July 31) 2015/03/18 20:41:37 Done.
410 (info.distinctive_identifier_support == 428 EME_FEATURE_REQUESTABLE_WITH_PERMISSION) {
411 EME_FEATURE_REQUESTABLE_WITH_PERMISSION && 429 // Must be either NOT_SUPPORTED or SUPPORTED_WITH_PERMISSION.
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_PERMISSION);
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_PERMISSION);
454 DCHECK(info.persistent_release_message_support !=
455 EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION);
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
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 #if defined(OS_CHROMEOS)
694 if (key_system == kWidevineKeySystem) {
695 if (robustness > max_robustness)
ddorwin 2015/03/18 01:08:04 You _could_ move this to 692 and simplify 714.
sandersd (OOO until July 31) 2015/03/18 20:41:37 Done.
696 return EmeConfigRule::NOT_SUPPORTED;
697
698 // We want to recommend permission for video when L1 is supported, as it
699 // will enable hardware decoding.
700 // TODO(sandersd): Only recommend permission when hardware decoding is
701 // available for the specific codecs requested.
702 EmeConfigRule supported_rule = EmeConfigRule::SUPPORTED;
703 if (media_type == EmeMediaType::VIDEO &&
704 max_robustness == EmeRobustness::HW_SECURE_ALL) {
705 supported_rule = EmeConfigRule::PERMISSION_RECOMMENDED;
706 }
707
708 // Above L3 (SW_SECURE_DECODE), permission is required.
709 return (robustness <= EmeRobustness::SW_SECURE_DECODE)
ddorwin 2015/03/18 01:08:04 It might be possible to simplify this logic with a
sandersd (OOO until July 31) 2015/03/18 20:41:37 Done.
710 ? supported_rule
711 : EmeConfigRule::PERMISSION_REQUIRED;
712 }
713 #endif // defined(OS_CHROMEOS)
714
715 return (robustness <= max_robustness)
716 ? EmeConfigRule::SUPPORTED
717 : EmeConfigRule::NOT_SUPPORTED;
718 }
719
720 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule(
721 const std::string& key_system) {
624 DCHECK(thread_checker_.CalledOnValidThread()); 722 DCHECK(thread_checker_.CalledOnValidThread());
625 723
626 KeySystemInfoMap::const_iterator key_system_iter = 724 KeySystemInfoMap::const_iterator key_system_iter =
627 concrete_key_system_map_.find(key_system); 725 concrete_key_system_map_.find(key_system);
628 if (key_system_iter == concrete_key_system_map_.end()) { 726 if (key_system_iter == concrete_key_system_map_.end()) {
629 NOTREACHED(); 727 NOTREACHED();
630 return false; 728 return EmeConfigRule::NOT_SUPPORTED;
631 } 729 }
632 730 return ConvertSessionTypeSupport(
633 switch (key_system_iter->second.persistent_license_support) { 731 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 } 732 }
648 733
649 bool KeySystems::IsPersistentReleaseMessageSessionSupported( 734 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule(
650 const std::string& key_system, 735 const std::string& key_system) {
651 bool is_permission_granted) {
652 DCHECK(thread_checker_.CalledOnValidThread()); 736 DCHECK(thread_checker_.CalledOnValidThread());
653 737
654 KeySystemInfoMap::const_iterator key_system_iter = 738 KeySystemInfoMap::const_iterator key_system_iter =
655 concrete_key_system_map_.find(key_system); 739 concrete_key_system_map_.find(key_system);
656 if (key_system_iter == concrete_key_system_map_.end()) { 740 if (key_system_iter == concrete_key_system_map_.end()) {
657 NOTREACHED(); 741 NOTREACHED();
658 return false; 742 return EmeConfigRule::NOT_SUPPORTED;
659 } 743 }
660 744 return ConvertSessionTypeSupport(
661 switch (key_system_iter->second.persistent_release_message_support) { 745 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 } 746 }
676 747
677 bool KeySystems::IsPersistentStateRequirementSupported( 748 EmeConfigRule KeySystems::GetPersistentStateConfigRule(
678 const std::string& key_system, 749 const std::string& key_system,
679 EmeFeatureRequirement requirement, 750 EmeFeatureRequirement requirement) {
680 bool is_permission_granted) {
681 DCHECK(thread_checker_.CalledOnValidThread()); 751 DCHECK(thread_checker_.CalledOnValidThread());
682 752
683 KeySystemInfoMap::const_iterator key_system_iter = 753 KeySystemInfoMap::const_iterator key_system_iter =
684 concrete_key_system_map_.find(key_system); 754 concrete_key_system_map_.find(key_system);
685 if (key_system_iter == concrete_key_system_map_.end()) { 755 if (key_system_iter == concrete_key_system_map_.end()) {
686 NOTREACHED(); 756 NOTREACHED();
687 return false; 757 return EmeConfigRule::NOT_SUPPORTED;
688 } 758 }
689 759
690 switch (key_system_iter->second.persistent_state_support) { 760 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we
691 case EME_FEATURE_INVALID: 761 // return the lest restrictive of the two rules; this guarantees that if
ddorwin 2015/03/18 01:08:04 s/lest/least/
sandersd (OOO until July 31) 2015/03/18 20:41:37 Done.
692 NOTREACHED(); 762 // OPTIONAL is accepted, then it can always be resolved to some value. (In
693 return false; 763 // fact OPTIONAL is always accepted, because the least restrictive rule is
694 case EME_FEATURE_NOT_SUPPORTED: 764 // always SUPPORTED.)
695 return requirement != EME_FEATURE_REQUIRED; 765 //
696 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: 766 // Note that even if permission is not required for persistent state, it may
697 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; 767 // be required for specific persistent session types.
698 case EME_FEATURE_REQUESTABLE: 768 //
699 return true; 769 // NOT_ALLOWED OPTIONAL REQUIRED
700 case EME_FEATURE_ALWAYS_ENABLED: 770 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED
701 // Persistent state does not require user permission, but the session 771 // REQUESTABLE_WITH_PERMISSION SUPPORTED SUPPORTED PERMISSION_REQ
702 // types that use it might. 772 // REQUESTABLE SUPPORTED SUPPORTED SUPPORTED
703 return requirement != EME_FEATURE_NOT_ALLOWED; 773 // ALWAYS_ENABLED NOT_SUPPORTED SUPPORTED SUPPORTED
774 EmeFeatureSupport support = key_system_iter->second.persistent_state_support;
775 if (support == EME_FEATURE_NOT_SUPPORTED &&
776 requirement == EME_FEATURE_REQUIRED) {
777 return EmeConfigRule::NOT_SUPPORTED;
704 } 778 }
705 779 if (support == EME_FEATURE_ALWAYS_ENABLED &&
706 NOTREACHED(); 780 requirement == EME_FEATURE_NOT_ALLOWED) {
707 return false; 781 return EmeConfigRule::NOT_SUPPORTED;
782 }
783 if (support == EME_FEATURE_REQUESTABLE_WITH_PERMISSION &&
784 requirement == EME_FEATURE_REQUIRED) {
785 return EmeConfigRule::PERMISSION_REQUIRED;
786 }
787 return EmeConfigRule::SUPPORTED;
708 } 788 }
709 789
710 bool KeySystems::IsDistinctiveIdentifierRequirementSupported( 790 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule(
711 const std::string& key_system, 791 const std::string& key_system,
712 EmeFeatureRequirement requirement, 792 EmeFeatureRequirement requirement) {
713 bool is_permission_granted) {
714 DCHECK(thread_checker_.CalledOnValidThread()); 793 DCHECK(thread_checker_.CalledOnValidThread());
715 794
716 KeySystemInfoMap::const_iterator key_system_iter = 795 KeySystemInfoMap::const_iterator key_system_iter =
717 concrete_key_system_map_.find(key_system); 796 concrete_key_system_map_.find(key_system);
718 if (key_system_iter == concrete_key_system_map_.end()) { 797 if (key_system_iter == concrete_key_system_map_.end()) {
719 NOTREACHED(); 798 NOTREACHED();
720 return false; 799 return EmeConfigRule::NOT_SUPPORTED;
721 } 800 }
722 801
723 switch (key_system_iter->second.distinctive_identifier_support) { 802 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL,
724 case EME_FEATURE_INVALID: 803 // we return the least restrictive of the two rules; this guarantees that if
725 NOTREACHED(); 804 // OPTIONAL is accepted, then it can always be resolved to some value.
726 return false; 805 //
727 case EME_FEATURE_NOT_SUPPORTED: 806 // NOT_ALLOWED OPTIONAL REQUIRED
728 return requirement != EME_FEATURE_REQUIRED; 807 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED
729 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: 808 // REQUESTABLE_WITH_PERMISSION SUPPORTED SUPPORTED PERMISSION_REQ
730 // TODO(sandersd): Remove this hack once crbug.com/457482 and 809 // ALWAYS_ENABLED NOT_SUPPORTED PERMISSION_REQ PERMISSION_REQ
731 // crbug.com/460616 are addressed. 810 EmeFeatureSupport support =
732 // We cannot currently enforce "not-allowed", so don't allow it. 811 key_system_iter->second.distinctive_identifier_support;
733 // Note: Removing this check will expose crbug.com/460616. 812 DCHECK(support != EME_FEATURE_REQUESTABLE);
734 if (requirement == EME_FEATURE_NOT_ALLOWED) 813
735 return false; 814 if (support == EME_FEATURE_NOT_SUPPORTED &&
736 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; 815 requirement == EME_FEATURE_REQUIRED) {
ddorwin 2015/03/18 01:08:04 This might be easier to follow if it was a switch(
sandersd (OOO until July 31) 2015/03/18 20:41:37 Done.
737 case EME_FEATURE_REQUESTABLE: 816 return EmeConfigRule::NOT_SUPPORTED;
738 NOTREACHED(); 817 }
739 return true; 818 if (support == EME_FEATURE_ALWAYS_ENABLED &&
740 case EME_FEATURE_ALWAYS_ENABLED: 819 requirement == EME_FEATURE_NOT_ALLOWED) {
741 // Distinctive identifiers always require user permission. 820 return EmeConfigRule::NOT_SUPPORTED;
742 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted; 821 }
822 if (support == EME_FEATURE_ALWAYS_ENABLED &&
823 requirement == EME_FEATURE_OPTIONAL) {
824 return EmeConfigRule::PERMISSION_REQUIRED;
743 } 825 }
744 826
745 NOTREACHED(); 827 if (requirement == EME_FEATURE_REQUIRED)
746 return false; 828 return EmeConfigRule::PERMISSION_REQUIRED;
829
830 return EmeConfigRule::SUPPORTED;
747 } 831 }
748 832
749 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { 833 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) {
750 DCHECK(thread_checker_.CalledOnValidThread()); 834 DCHECK(thread_checker_.CalledOnValidThread());
751 DCHECK(!container_to_codec_mask_map_.count(container)); 835 DCHECK(!container_to_codec_mask_map_.count(container));
752 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); 836 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask);
753 } 837 }
754 838
755 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { 839 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) {
756 DCHECK(thread_checker_.CalledOnValidThread()); 840 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 bool CanUseAesDecryptor(const std::string& concrete_key_system) { 925 bool CanUseAesDecryptor(const std::string& concrete_key_system) {
842 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); 926 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system);
843 } 927 }
844 928
845 #if defined(ENABLE_PEPPER_CDMS) 929 #if defined(ENABLE_PEPPER_CDMS)
846 std::string GetPepperType(const std::string& concrete_key_system) { 930 std::string GetPepperType(const std::string& concrete_key_system) {
847 return KeySystems::GetInstance().GetPepperType(concrete_key_system); 931 return KeySystems::GetInstance().GetPepperType(concrete_key_system);
848 } 932 }
849 #endif 933 #endif
850 934
851 bool IsPersistentLicenseSessionSupported( 935 EmeConfigRule GetRobustnessConfigRule(
852 const std::string& key_system, 936 const std::string& key_system,
853 bool is_permission_granted) { 937 EmeMediaType media_type,
854 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported( 938 EmeRobustness robustness) {
855 key_system, is_permission_granted); 939 return KeySystems::GetInstance().GetRobustnessConfigRule(
940 key_system, media_type, robustness);
856 } 941 }
857 942
858 bool IsPersistentReleaseMessageSessionSupported( 943 EmeConfigRule GetPersistentLicenseSessionConfigRule(
859 const std::string& key_system, 944 const std::string& key_system) {
860 bool is_permission_granted) { 945 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule(
861 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported( 946 key_system);
862 key_system, is_permission_granted);
863 } 947 }
864 948
865 bool IsPersistentStateRequirementSupported( 949 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule(
866 const std::string& key_system, 950 const std::string& key_system) {
867 EmeFeatureRequirement requirement, 951 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule(
868 bool is_permission_granted) { 952 key_system);
869 return KeySystems::GetInstance().IsPersistentStateRequirementSupported(
870 key_system, requirement, is_permission_granted);
871 } 953 }
872 954
873 bool IsDistinctiveIdentifierRequirementSupported( 955 EmeConfigRule GetPersistentStateConfigRule(
874 const std::string& key_system, 956 const std::string& key_system,
875 EmeFeatureRequirement requirement, 957 EmeFeatureRequirement requirement) {
876 bool is_permission_granted) { 958 return KeySystems::GetInstance().GetPersistentStateConfigRule(
877 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported( 959 key_system, requirement);
878 key_system, requirement, is_permission_granted); 960 }
961
962 EmeConfigRule GetDistinctiveIdentifierConfigRule(
963 const std::string& key_system,
964 EmeFeatureRequirement requirement) {
965 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule(
966 key_system, requirement);
879 } 967 }
880 968
881 // These two functions are for testing purpose only. The declaration in the 969 // 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 970 // 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 971 // 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 972 // "media" where "UNIT_TEST" is not defined. So we need to specify
885 // "MEDIA_EXPORT" here again so that they are visible to tests. 973 // "MEDIA_EXPORT" here again so that they are visible to tests.
886 974
887 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { 975 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) {
888 KeySystems::GetInstance().AddContainerMask(container, mask); 976 KeySystems::GetInstance().AddContainerMask(container, mask);
889 } 977 }
890 978
891 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { 979 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) {
892 KeySystems::GetInstance().AddCodecMask(codec, mask); 980 KeySystems::GetInstance().AddCodecMask(codec, mask);
893 } 981 }
894 982
895 } // namespace media 983 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698