| 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 if (robustness > max_robustness) |
| 694 return EmeConfigRule::NOT_SUPPORTED; |
| 695 |
| 696 #if defined(OS_CHROMEOS) |
| 697 if (key_system == kWidevineKeySystem) { |
| 698 // Above SW_SECURE_DECODE, remote attestation is required. |
| 699 if (robustness > EmeRobustness::SW_SECURE_DECODE) |
| 700 return EmeConfigRule::IDENTIFIER_REQUIRED; |
| 701 |
| 702 // For video, recommend remote attestation if HW_SECURE_ALL is available, |
| 703 // because it enables hardware accelerated decoding. |
| 704 // TODO(sandersd): Only do this when hardware accelerated decoding is |
| 705 // available for the requested codecs. |
| 706 if (media_type == EmeMediaType::VIDEO && |
| 707 max_robustness == EmeRobustness::HW_SECURE_ALL) { |
| 708 return EmeConfigRule::IDENTIFIER_RECOMMENDED; |
| 709 } |
| 710 } |
| 711 #endif // defined(OS_CHROMEOS) |
| 712 |
| 713 return EmeConfigRule::SUPPORTED; |
| 714 } |
| 715 |
| 716 EmeConfigRule KeySystems::GetPersistentLicenseSessionConfigRule( |
| 717 const std::string& key_system) { |
| 624 DCHECK(thread_checker_.CalledOnValidThread()); | 718 DCHECK(thread_checker_.CalledOnValidThread()); |
| 625 | 719 |
| 626 KeySystemInfoMap::const_iterator key_system_iter = | 720 KeySystemInfoMap::const_iterator key_system_iter = |
| 627 concrete_key_system_map_.find(key_system); | 721 concrete_key_system_map_.find(key_system); |
| 628 if (key_system_iter == concrete_key_system_map_.end()) { | 722 if (key_system_iter == concrete_key_system_map_.end()) { |
| 629 NOTREACHED(); | 723 NOTREACHED(); |
| 630 return false; | 724 return EmeConfigRule::NOT_SUPPORTED; |
| 631 } | 725 } |
| 632 | 726 return ConvertSessionTypeSupport( |
| 633 switch (key_system_iter->second.persistent_license_support) { | 727 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 } | 728 } |
| 648 | 729 |
| 649 bool KeySystems::IsPersistentReleaseMessageSessionSupported( | 730 EmeConfigRule KeySystems::GetPersistentReleaseMessageSessionConfigRule( |
| 650 const std::string& key_system, | 731 const std::string& key_system) { |
| 651 bool is_permission_granted) { | |
| 652 DCHECK(thread_checker_.CalledOnValidThread()); | 732 DCHECK(thread_checker_.CalledOnValidThread()); |
| 653 | 733 |
| 654 KeySystemInfoMap::const_iterator key_system_iter = | 734 KeySystemInfoMap::const_iterator key_system_iter = |
| 655 concrete_key_system_map_.find(key_system); | 735 concrete_key_system_map_.find(key_system); |
| 656 if (key_system_iter == concrete_key_system_map_.end()) { | 736 if (key_system_iter == concrete_key_system_map_.end()) { |
| 657 NOTREACHED(); | 737 NOTREACHED(); |
| 658 return false; | 738 return EmeConfigRule::NOT_SUPPORTED; |
| 659 } | 739 } |
| 660 | 740 return ConvertSessionTypeSupport( |
| 661 switch (key_system_iter->second.persistent_release_message_support) { | 741 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 } | 742 } |
| 676 | 743 |
| 677 bool KeySystems::IsPersistentStateRequirementSupported( | 744 EmeConfigRule KeySystems::GetPersistentStateConfigRule( |
| 678 const std::string& key_system, | 745 const std::string& key_system, |
| 679 EmeFeatureRequirement requirement, | 746 EmeFeatureRequirement requirement) { |
| 680 bool is_permission_granted) { | |
| 681 DCHECK(thread_checker_.CalledOnValidThread()); | 747 DCHECK(thread_checker_.CalledOnValidThread()); |
| 682 | 748 |
| 683 KeySystemInfoMap::const_iterator key_system_iter = | 749 KeySystemInfoMap::const_iterator key_system_iter = |
| 684 concrete_key_system_map_.find(key_system); | 750 concrete_key_system_map_.find(key_system); |
| 685 if (key_system_iter == concrete_key_system_map_.end()) { | 751 if (key_system_iter == concrete_key_system_map_.end()) { |
| 686 NOTREACHED(); | 752 NOTREACHED(); |
| 687 return false; | 753 return EmeConfigRule::NOT_SUPPORTED; |
| 688 } | 754 } |
| 689 | 755 |
| 690 switch (key_system_iter->second.persistent_state_support) { | 756 // For NOT_ALLOWED and REQUIRED, the result is as expected. For OPTIONAL, we |
| 691 case EME_FEATURE_INVALID: | 757 // return the least restrictive of the two rules; this guarantees that if |
| 692 NOTREACHED(); | 758 // OPTIONAL is accepted, then it can always be resolved to some value. (In |
| 693 return false; | 759 // fact OPTIONAL is always accepted, because the least restrictive rule is |
| 694 case EME_FEATURE_NOT_SUPPORTED: | 760 // always SUPPORTED.) |
| 695 return requirement != EME_FEATURE_REQUIRED; | 761 // |
| 696 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 762 // Note that even if permission is not required for persistent state, it may |
| 697 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 763 // be required for specific persistent session types. |
| 698 case EME_FEATURE_REQUESTABLE: | 764 // |
| 699 return true; | 765 // NOT_ALLOWED OPTIONAL REQUIRED |
| 700 case EME_FEATURE_ALWAYS_ENABLED: | 766 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED |
| 701 // Persistent state does not require user permission, but the session | 767 // REQUESTABLE_WITH_IDENTIFIER SUPPORTED SUPPORTED IDENTIFIER_REQ |
| 702 // types that use it might. | 768 // REQUESTABLE SUPPORTED SUPPORTED SUPPORTED |
| 703 return requirement != EME_FEATURE_NOT_ALLOWED; | 769 // ALWAYS_ENABLED NOT_SUPPORTED SUPPORTED SUPPORTED |
| 770 EmeFeatureSupport support = key_system_iter->second.persistent_state_support; |
| 771 if (support == EME_FEATURE_NOT_SUPPORTED && |
| 772 requirement == EME_FEATURE_REQUIRED) { |
| 773 return EmeConfigRule::NOT_SUPPORTED; |
| 704 } | 774 } |
| 705 | 775 if (support == EME_FEATURE_ALWAYS_ENABLED && |
| 706 NOTREACHED(); | 776 requirement == EME_FEATURE_NOT_ALLOWED) { |
| 707 return false; | 777 return EmeConfigRule::NOT_SUPPORTED; |
| 778 } |
| 779 if (support == EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER && |
| 780 requirement == EME_FEATURE_REQUIRED) { |
| 781 return EmeConfigRule::IDENTIFIER_REQUIRED; |
| 782 } |
| 783 return EmeConfigRule::SUPPORTED; |
| 708 } | 784 } |
| 709 | 785 |
| 710 bool KeySystems::IsDistinctiveIdentifierRequirementSupported( | 786 EmeConfigRule KeySystems::GetDistinctiveIdentifierConfigRule( |
| 711 const std::string& key_system, | 787 const std::string& key_system, |
| 712 EmeFeatureRequirement requirement, | 788 EmeFeatureRequirement requirement) { |
| 713 bool is_permission_granted) { | |
| 714 DCHECK(thread_checker_.CalledOnValidThread()); | 789 DCHECK(thread_checker_.CalledOnValidThread()); |
| 715 | 790 |
| 716 KeySystemInfoMap::const_iterator key_system_iter = | 791 KeySystemInfoMap::const_iterator key_system_iter = |
| 717 concrete_key_system_map_.find(key_system); | 792 concrete_key_system_map_.find(key_system); |
| 718 if (key_system_iter == concrete_key_system_map_.end()) { | 793 if (key_system_iter == concrete_key_system_map_.end()) { |
| 719 NOTREACHED(); | 794 NOTREACHED(); |
| 720 return false; | 795 return EmeConfigRule::NOT_SUPPORTED; |
| 721 } | 796 } |
| 722 | 797 |
| 723 switch (key_system_iter->second.distinctive_identifier_support) { | 798 // Permission is required for REQUIRED, but not for NOT_ALLOWED. For OPTIONAL, |
| 724 case EME_FEATURE_INVALID: | 799 // we return the least restrictive of the two rules; this guarantees that if |
| 725 NOTREACHED(); | 800 // OPTIONAL is accepted, then it can always be resolved to some value. |
| 726 return false; | 801 // |
| 727 case EME_FEATURE_NOT_SUPPORTED: | 802 // NOT_ALLOWED OPTIONAL REQUIRED |
| 728 return requirement != EME_FEATURE_REQUIRED; | 803 // NOT_SUPPORTED SUPPORTED SUPPORTED NOT_SUPPORTED |
| 729 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 804 // REQUESTABLE_WITH_IDENTIFIER SUPPORTED SUPPORTED IDENTIFIER_REQ |
| 730 // TODO(sandersd): Remove this hack once crbug.com/457482 and | 805 // ALWAYS_ENABLED NOT_SUPPORTED IDENTIFIER_REQ IDENTIFIER_REQ |
| 731 // crbug.com/460616 are addressed. | 806 EmeFeatureSupport support = |
| 732 // We cannot currently enforce "not-allowed", so don't allow it. | 807 key_system_iter->second.distinctive_identifier_support; |
| 733 // Note: Removing this check will expose crbug.com/460616. | 808 DCHECK(support != EME_FEATURE_REQUESTABLE); |
| 734 if (requirement == EME_FEATURE_NOT_ALLOWED) | 809 if (support == EME_FEATURE_NOT_SUPPORTED && |
| 735 return false; | 810 requirement == EME_FEATURE_REQUIRED) { |
| 736 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 811 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 } | 812 } |
| 744 | 813 if (support == EME_FEATURE_ALWAYS_ENABLED && |
| 745 NOTREACHED(); | 814 requirement == EME_FEATURE_NOT_ALLOWED) { |
| 746 return false; | 815 return EmeConfigRule::NOT_SUPPORTED; |
| 816 } |
| 817 if (support == EME_FEATURE_ALWAYS_ENABLED || |
| 818 requirement == EME_FEATURE_REQUIRED) { |
| 819 return EmeConfigRule::IDENTIFIER_REQUIRED; |
| 820 } |
| 821 return EmeConfigRule::SUPPORTED; |
| 747 } | 822 } |
| 748 | 823 |
| 749 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 824 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
| 750 DCHECK(thread_checker_.CalledOnValidThread()); | 825 DCHECK(thread_checker_.CalledOnValidThread()); |
| 751 DCHECK(!container_to_codec_mask_map_.count(container)); | 826 DCHECK(!container_to_codec_mask_map_.count(container)); |
| 752 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 827 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
| 753 } | 828 } |
| 754 | 829 |
| 755 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 830 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
| 756 DCHECK(thread_checker_.CalledOnValidThread()); | 831 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) { | 916 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
| 842 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 917 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
| 843 } | 918 } |
| 844 | 919 |
| 845 #if defined(ENABLE_PEPPER_CDMS) | 920 #if defined(ENABLE_PEPPER_CDMS) |
| 846 std::string GetPepperType(const std::string& concrete_key_system) { | 921 std::string GetPepperType(const std::string& concrete_key_system) { |
| 847 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 922 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
| 848 } | 923 } |
| 849 #endif | 924 #endif |
| 850 | 925 |
| 851 bool IsPersistentLicenseSessionSupported( | 926 EmeConfigRule GetRobustnessConfigRule( |
| 852 const std::string& key_system, | 927 const std::string& key_system, |
| 853 bool is_permission_granted) { | 928 EmeMediaType media_type, |
| 854 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported( | 929 EmeRobustness robustness) { |
| 855 key_system, is_permission_granted); | 930 return KeySystems::GetInstance().GetRobustnessConfigRule( |
| 931 key_system, media_type, robustness); |
| 856 } | 932 } |
| 857 | 933 |
| 858 bool IsPersistentReleaseMessageSessionSupported( | 934 EmeConfigRule GetPersistentLicenseSessionConfigRule( |
| 859 const std::string& key_system, | 935 const std::string& key_system) { |
| 860 bool is_permission_granted) { | 936 return KeySystems::GetInstance().GetPersistentLicenseSessionConfigRule( |
| 861 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported( | 937 key_system); |
| 862 key_system, is_permission_granted); | |
| 863 } | 938 } |
| 864 | 939 |
| 865 bool IsPersistentStateRequirementSupported( | 940 EmeConfigRule GetPersistentReleaseMessageSessionConfigRule( |
| 866 const std::string& key_system, | 941 const std::string& key_system) { |
| 867 EmeFeatureRequirement requirement, | 942 return KeySystems::GetInstance().GetPersistentReleaseMessageSessionConfigRule( |
| 868 bool is_permission_granted) { | 943 key_system); |
| 869 return KeySystems::GetInstance().IsPersistentStateRequirementSupported( | |
| 870 key_system, requirement, is_permission_granted); | |
| 871 } | 944 } |
| 872 | 945 |
| 873 bool IsDistinctiveIdentifierRequirementSupported( | 946 EmeConfigRule GetPersistentStateConfigRule( |
| 874 const std::string& key_system, | 947 const std::string& key_system, |
| 875 EmeFeatureRequirement requirement, | 948 EmeFeatureRequirement requirement) { |
| 876 bool is_permission_granted) { | 949 return KeySystems::GetInstance().GetPersistentStateConfigRule( |
| 877 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported( | 950 key_system, requirement); |
| 878 key_system, requirement, is_permission_granted); | 951 } |
| 952 |
| 953 EmeConfigRule GetDistinctiveIdentifierConfigRule( |
| 954 const std::string& key_system, |
| 955 EmeFeatureRequirement requirement) { |
| 956 return KeySystems::GetInstance().GetDistinctiveIdentifierConfigRule( |
| 957 key_system, requirement); |
| 879 } | 958 } |
| 880 | 959 |
| 881 // These two functions are for testing purpose only. The declaration in the | 960 // 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 | 961 // 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 | 962 // 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 | 963 // "media" where "UNIT_TEST" is not defined. So we need to specify |
| 885 // "MEDIA_EXPORT" here again so that they are visible to tests. | 964 // "MEDIA_EXPORT" here again so that they are visible to tests. |
| 886 | 965 |
| 887 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 966 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
| 888 KeySystems::GetInstance().AddContainerMask(container, mask); | 967 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 889 } | 968 } |
| 890 | 969 |
| 891 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 970 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 892 KeySystems::GetInstance().AddCodecMask(codec, mask); | 971 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 893 } | 972 } |
| 894 | 973 |
| 895 } // namespace media | 974 } // namespace media |
| OLD | NEW |