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

Side by Side Diff: media/blink/key_system_config_selector.cc

Issue 2349813002: EME: Update MediaKeySystemConfiguration defaults; require non-empty capabilities (Closed)
Patch Set: changes Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/blink/key_system_config_selector.h" 5 #include "media/blink/key_system_config_selector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 requirement == EmeFeatureRequirement::Optional) { 122 requirement == EmeFeatureRequirement::Optional) {
123 return EmeConfigRule::SUPPORTED; 123 return EmeConfigRule::SUPPORTED;
124 } 124 }
125 if (support == EmeFeatureSupport::NOT_SUPPORTED || 125 if (support == EmeFeatureSupport::NOT_SUPPORTED ||
126 requirement == EmeFeatureRequirement::NotAllowed) { 126 requirement == EmeFeatureRequirement::NotAllowed) {
127 return EmeConfigRule::PERSISTENCE_NOT_ALLOWED; 127 return EmeConfigRule::PERSISTENCE_NOT_ALLOWED;
128 } 128 }
129 return EmeConfigRule::PERSISTENCE_REQUIRED; 129 return EmeConfigRule::PERSISTENCE_REQUIRED;
130 } 130 }
131 131
132 static bool IsPersistentSessionType(
133 blink::WebEncryptedMediaSessionType sessionType) {
134 switch (sessionType) {
135 case blink::WebEncryptedMediaSessionType::Temporary:
136 return false;
137 case blink::WebEncryptedMediaSessionType::PersistentLicense:
138 return true;
139 case blink::WebEncryptedMediaSessionType::PersistentReleaseMessage:
140 return true;
141 case blink::WebEncryptedMediaSessionType::Unknown:
142 break;
143 }
144
145 NOTREACHED();
146 return false;
147 }
148
132 } // namespace 149 } // namespace
133 150
134 struct KeySystemConfigSelector::SelectionRequest { 151 struct KeySystemConfigSelector::SelectionRequest {
135 std::string key_system; 152 std::string key_system;
136 blink::WebVector<blink::WebMediaKeySystemConfiguration> 153 blink::WebVector<blink::WebMediaKeySystemConfiguration>
137 candidate_configurations; 154 candidate_configurations;
138 blink::WebSecurityOrigin security_origin; 155 blink::WebSecurityOrigin security_origin;
139 base::Callback<void(const blink::WebMediaKeySystemConfiguration&, 156 base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
140 const CdmConfig&)> succeeded_cb; 157 const CdmConfig&)> succeeded_cb;
141 base::Callback<void(const blink::WebString&)> not_supported_cb; 158 base::Callback<void(const blink::WebString&)> not_supported_cb;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // 5. Return media type capabilities. 444 // 5. Return media type capabilities.
428 return true; 445 return true;
429 } 446 }
430 447
431 KeySystemConfigSelector::ConfigurationSupport 448 KeySystemConfigSelector::ConfigurationSupport
432 KeySystemConfigSelector::GetSupportedConfiguration( 449 KeySystemConfigSelector::GetSupportedConfiguration(
433 const std::string& key_system, 450 const std::string& key_system,
434 const blink::WebMediaKeySystemConfiguration& candidate, 451 const blink::WebMediaKeySystemConfiguration& candidate,
435 ConfigState* config_state, 452 ConfigState* config_state,
436 blink::WebMediaKeySystemConfiguration* accumulated_configuration) { 453 blink::WebMediaKeySystemConfiguration* accumulated_configuration) {
437 // From https://w3c.github.io/encrypted-media/#get-supported-configuration 454 // From
438 // 1. Let accumulated configuration be empty. (Done by caller.) 455 // http://w3c.github.io/encrypted-media/#get-supported-configuration-and-conse nt
439 // 2. If the initDataTypes member is present in candidate configuration, run 456 // 1. Let accumulated configuration be a new MediaKeySystemConfiguration
440 // the following steps: 457 // dictionary. (Done by caller.)
441 if (candidate.hasInitDataTypes) { 458 // 2. Set the label member of accumulated configuration to equal the label
442 // 2.1. Let supported types be empty. 459 // member of candidate configuration.
460 accumulated_configuration->label = candidate.label;
461
462 // 3. If the initDataTypes member of candidate configuration is non-empty,
463 // run the following steps:
464 if (!candidate.initDataTypes.isEmpty()) {
465 // 3.1. Let supported types be an empty sequence of DOMStrings.
443 std::vector<blink::WebEncryptedMediaInitDataType> supported_types; 466 std::vector<blink::WebEncryptedMediaInitDataType> supported_types;
444 467
445 // 2.2. For each value in candidate configuration's initDataTypes member: 468 // 3.2. For each value in candidate configuration's initDataTypes member:
446 for (size_t i = 0; i < candidate.initDataTypes.size(); i++) { 469 for (size_t i = 0; i < candidate.initDataTypes.size(); i++) {
447 // 2.2.1. Let initDataType be the value. 470 // 3.2.1. Let initDataType be the value.
448 blink::WebEncryptedMediaInitDataType init_data_type = 471 blink::WebEncryptedMediaInitDataType init_data_type =
449 candidate.initDataTypes[i]; 472 candidate.initDataTypes[i];
450 // 2.2.2. If the implementation supports generating requests based on 473
474 // 3.2.2. If the implementation supports generating requests based on
451 // initDataType, add initDataType to supported types. String 475 // initDataType, add initDataType to supported types. String
452 // comparison is case-sensitive. The empty string is never 476 // comparison is case-sensitive. The empty string is never
453 // supported. 477 // supported.
454 if (key_systems_->IsSupportedInitDataType( 478 if (key_systems_->IsSupportedInitDataType(
455 key_system, ConvertToEmeInitDataType(init_data_type))) { 479 key_system, ConvertToEmeInitDataType(init_data_type))) {
456 supported_types.push_back(init_data_type); 480 supported_types.push_back(init_data_type);
457 } 481 }
458 } 482 }
459 483
460 // 2.3. If supported types is empty, return null. 484 // 3.3. If supported types is empty, return null.
461 if (supported_types.empty()) { 485 if (supported_types.empty()) {
462 DVLOG(2) << "Rejecting requested configuration because " 486 DVLOG(2) << "Rejecting requested configuration because "
463 << "no initDataType values were supported."; 487 << "no initDataType values were supported.";
464 return CONFIGURATION_NOT_SUPPORTED; 488 return CONFIGURATION_NOT_SUPPORTED;
465 } 489 }
466 490
467 // 2.4. Add supported types to accumulated configuration. 491 // 3.4. Set the initDataTypes member of accumulated configuration to
492 // supported types.
468 accumulated_configuration->initDataTypes = supported_types; 493 accumulated_configuration->initDataTypes = supported_types;
469 } 494 }
470 495
471 // 3. Follow the steps for the value of candidate configuration's 496 // 4. Let distinctive identifier requirement be the value of candidate
472 // distinctiveIdentifier member from the following list: 497 // configuration's distinctiveIdentifier member.
473 // - "required": If the implementation does not support a persistent 498 EmeFeatureRequirement distinctive_identifier =
474 // Distinctive Identifier in combination with accumulated 499 candidate.distinctiveIdentifier;
475 // configuration, return null. 500
476 // - "optional": Continue. 501 // 5. If distinctive identifier requirement is "optional" and Distinctive
477 // - "not-allowed": If the implementation requires a Distinctive 502 // Identifiers are not allowed according to restrictions, set distinctive
478 // Identifier in combination with accumulated configuration, return 503 // identifier requirement to "not-allowed".
479 // null. 504 EmeFeatureSupport distinctive_identifier_support =
505 key_systems_->GetDistinctiveIdentifierSupport(key_system);
506 if (distinctive_identifier == EmeFeatureRequirement::Optional) {
507 if (distinctive_identifier_support == EmeFeatureSupport::INVALID ||
508 distinctive_identifier_support == EmeFeatureSupport::NOT_SUPPORTED) {
509 distinctive_identifier = EmeFeatureRequirement::NotAllowed;
510 }
511 }
512
513 // 6. Follow the steps for distinctive identifier requirement from the
514 // following list:
515 // - "required": If the implementation does not support use of
516 // Distinctive Identifier(s) in combination with accumulated
517 // configuration and restrictions, return NotSupported.
518 // - "optional": Continue with the following steps.
519 // - "not-allowed": If the implementation requires use Distinctive
520 // Identifier(s) or Distinctive Permanent Identifier(s) in
521 // combination with accumulated configuration and restrictions,
522 // return NotSupported.
480 // We also reject OPTIONAL when distinctive identifiers are ALWAYS_ENABLED and 523 // We also reject OPTIONAL when distinctive identifiers are ALWAYS_ENABLED and
481 // permission has already been denied. This would happen anyway at step 11. 524 // permission has already been denied. This would happen anyway later.
482 EmeConfigRule di_rule = GetDistinctiveIdentifierConfigRule( 525 EmeConfigRule di_rule = GetDistinctiveIdentifierConfigRule(
483 key_systems_->GetDistinctiveIdentifierSupport(key_system), 526 distinctive_identifier_support, distinctive_identifier);
484 candidate.distinctiveIdentifier);
485 if (!config_state->IsRuleSupported(di_rule)) { 527 if (!config_state->IsRuleSupported(di_rule)) {
486 DVLOG(2) << "Rejecting requested configuration because " 528 DVLOG(2) << "Rejecting requested configuration because "
487 << "the distinctiveIdentifier requirement was not supported."; 529 << "the distinctiveIdentifier requirement was not supported.";
488 return CONFIGURATION_NOT_SUPPORTED; 530 return CONFIGURATION_NOT_SUPPORTED;
489 } 531 }
490 config_state->AddRule(di_rule); 532 config_state->AddRule(di_rule);
491 533
492 // 4. Add the value of the candidate configuration's distinctiveIdentifier 534 // 7. Set the distinctiveIdentifier member of accumulated configuration to
493 // member to accumulated configuration. 535 // equal distinctive identifier requirement.
494 accumulated_configuration->distinctiveIdentifier = 536 accumulated_configuration->distinctiveIdentifier = distinctive_identifier;
495 candidate.distinctiveIdentifier;
496 537
497 // 5. Follow the steps for the value of candidate configuration's 538 // 8. Let persistent state requirement be equal to the value of candidate
498 // persistentState member from the following list: 539 // configuration's persistentState member.
499 // - "required": If the implementation does not support persisting state 540 EmeFeatureRequirement persistent_state = candidate.persistentState;
500 // in combination with accumulated configuration, return null. 541
501 // - "optional": Continue. 542 // 9. If persistent state requirement is "optional" and persisting state is
502 // - "not-allowed": If the implementation requires persisting state in 543 // not allowed according to restrictions, set persistent state requirement
503 // combination with accumulated configuration, return null. 544 // to "not-allowed".
504 EmeConfigRule ps_rule = GetPersistentStateConfigRule( 545 EmeFeatureSupport persistent_state_support =
505 key_systems_->GetPersistentStateSupport(key_system), 546 key_systems_->GetPersistentStateSupport(key_system);
506 candidate.persistentState); 547 if (persistent_state == EmeFeatureRequirement::Optional) {
548 if (persistent_state_support == EmeFeatureSupport::INVALID ||
549 persistent_state_support == EmeFeatureSupport::NOT_SUPPORTED) {
550 persistent_state = EmeFeatureRequirement::NotAllowed;
551 }
552 }
553
554 // 10. Follow the steps for persistent state requirement from the following
555 // list:
556 // - "required": If the implementation does not support persisting
557 // state in combination with accumulated configuration and
558 // restrictions, return NotSupported.
559 // - "optional": Continue with the following steps.
560 // - "not-allowed": If the implementation requires persisting state in
561 // combination with accumulated configuration and restrictions,
562 // return NotSupported.
563 EmeConfigRule ps_rule =
564 GetPersistentStateConfigRule(persistent_state_support, persistent_state);
507 if (!config_state->IsRuleSupported(ps_rule)) { 565 if (!config_state->IsRuleSupported(ps_rule)) {
508 DVLOG(2) << "Rejecting requested configuration because " 566 DVLOG(2) << "Rejecting requested configuration because "
509 << "the persistentState requirement was not supported."; 567 << "the persistentState requirement was not supported.";
510 return CONFIGURATION_NOT_SUPPORTED; 568 return CONFIGURATION_NOT_SUPPORTED;
511 } 569 }
512 config_state->AddRule(ps_rule); 570 config_state->AddRule(ps_rule);
513 571
514 // 6. Add the value of the candidate configuration's persistentState 572 // 11. Set the persistentState member of accumulated configuration to equal
515 // member to accumulated configuration. 573 // the value of persistent state requirement.
516 accumulated_configuration->persistentState = candidate.persistentState; 574 accumulated_configuration->persistentState = persistent_state;
517 575
518 // 7. Follow the steps for the first matching condition from the following 576 // 12. Follow the steps for the first matching condition from the following
519 // list: 577 // list:
520 // - If the sessionTypes member is present in candidate configuration, 578 // - If the sessionTypes member is present in candidate configuration,
521 // let session types be candidate configuration's sessionTypes member. 579 // let session types be candidate configuration's sessionTypes member.
522 // - Otherwise, let session types be [ "temporary" ]. 580 // - Otherwise, let session types be [ "temporary" ].
523 blink::WebVector<blink::WebEncryptedMediaSessionType> session_types; 581 blink::WebVector<blink::WebEncryptedMediaSessionType> session_types;
524 if (candidate.hasSessionTypes) { 582 if (candidate.hasSessionTypes) {
525 session_types = candidate.sessionTypes; 583 session_types = candidate.sessionTypes;
526 } else { 584 } else {
527 std::vector<blink::WebEncryptedMediaSessionType> temporary(1); 585 std::vector<blink::WebEncryptedMediaSessionType> temporary(1);
528 temporary[0] = blink::WebEncryptedMediaSessionType::Temporary; 586 temporary[0] = blink::WebEncryptedMediaSessionType::Temporary;
529 session_types = temporary; 587 session_types = temporary;
530 } 588 }
531 589
532 // 8. For each value in session types: 590 // 13. For each value in session types:
533 for (size_t i = 0; i < session_types.size(); i++) { 591 for (size_t i = 0; i < session_types.size(); i++) {
534 // 8.1. Let session type be the value. 592 // 13.1. Let session type be the value.
535 blink::WebEncryptedMediaSessionType session_type = session_types[i]; 593 blink::WebEncryptedMediaSessionType session_type = session_types[i];
536 // 8.2. If the implementation does not support session type in combination 594
537 // with accumulated configuration, return null. 595 // 13.2. If accumulated configuration's persistentState value is
538 // 8.3. If session type is "persistent-license" or 596 // "not-allowed" and the Is persistent session type? algorithm
539 // "persistent-release-message", follow the steps for accumulated 597 // returns true for session type return NotSupported.
540 // configuration's persistentState value from the following list: 598 if (accumulated_configuration->persistentState ==
541 // - "required": Continue. 599 EmeFeatureRequirement::NotAllowed &&
542 // - "optional": Change accumulated configuration's persistentState 600 IsPersistentSessionType(session_type)) {
543 // value to "required". 601 DVLOG(2) << "Rejecting requested configuration because persistent "
544 // - "not-allowed": Return null. 602 "sessions are not allowed.";
603 return CONFIGURATION_NOT_SUPPORTED;
604 }
605
606 // 13.3. If the implementation does not support session type in combination
607 // with accumulated configuration and restrictions for other reasons,
608 // return NotSupported.
545 EmeConfigRule session_type_rule = EmeConfigRule::NOT_SUPPORTED; 609 EmeConfigRule session_type_rule = EmeConfigRule::NOT_SUPPORTED;
546 switch (session_type) { 610 switch (session_type) {
547 case blink::WebEncryptedMediaSessionType::Unknown: 611 case blink::WebEncryptedMediaSessionType::Unknown:
548 DVLOG(2) << "Rejecting requested configuration because " 612 DVLOG(2) << "Rejecting requested configuration because "
549 << "a required session type was not recognized."; 613 << "a required session type was not recognized.";
550 return CONFIGURATION_NOT_SUPPORTED; 614 return CONFIGURATION_NOT_SUPPORTED;
551 case blink::WebEncryptedMediaSessionType::Temporary: 615 case blink::WebEncryptedMediaSessionType::Temporary:
552 session_type_rule = EmeConfigRule::SUPPORTED; 616 session_type_rule = EmeConfigRule::SUPPORTED;
553 break; 617 break;
554 case blink::WebEncryptedMediaSessionType::PersistentLicense: 618 case blink::WebEncryptedMediaSessionType::PersistentLicense:
555 session_type_rule = GetSessionTypeConfigRule( 619 session_type_rule = GetSessionTypeConfigRule(
556 key_systems_->GetPersistentLicenseSessionSupport(key_system)); 620 key_systems_->GetPersistentLicenseSessionSupport(key_system));
557 break; 621 break;
558 case blink::WebEncryptedMediaSessionType::PersistentReleaseMessage: 622 case blink::WebEncryptedMediaSessionType::PersistentReleaseMessage:
559 session_type_rule = GetSessionTypeConfigRule( 623 session_type_rule = GetSessionTypeConfigRule(
560 key_systems_->GetPersistentReleaseMessageSessionSupport( 624 key_systems_->GetPersistentReleaseMessageSessionSupport(
561 key_system)); 625 key_system));
562 break; 626 break;
563 } 627 }
628
564 if (!config_state->IsRuleSupported(session_type_rule)) { 629 if (!config_state->IsRuleSupported(session_type_rule)) {
565 DVLOG(2) << "Rejecting requested configuration because " 630 DVLOG(2) << "Rejecting requested configuration because "
566 << "a required session type was not supported."; 631 << "a required session type was not supported.";
567 return CONFIGURATION_NOT_SUPPORTED; 632 return CONFIGURATION_NOT_SUPPORTED;
568 } 633 }
569 config_state->AddRule(session_type_rule); 634 config_state->AddRule(session_type_rule);
635
636 // 13.4. If accumulated configuration's persistentState value is "optional"
637 // and the result of running the Is persistent session type?
638 // algorithm on session type is true, change accumulated
639 // configuration's persistentState value to "required".
640 if (accumulated_configuration->persistentState ==
641 EmeFeatureRequirement::Optional &&
642 IsPersistentSessionType(session_type)) {
643 accumulated_configuration->persistentState =
644 EmeFeatureRequirement::Required;
645 }
570 } 646 }
571 647
572 // 9. Add session types to accumulated configuration. 648 // 14. Set the sessionTypes member of accumulated configuration to
649 // session types.
573 accumulated_configuration->sessionTypes = session_types; 650 accumulated_configuration->sessionTypes = session_types;
574 651
575 // 10. If the videoCapabilities member is present in candidate configuration: 652 // 15. If the videoCapabilities and audioCapabilities members in candidate
576 if (candidate.hasVideoCapabilities) { 653 // configuration are both empty, return NotSupported.
577 // 10.1. Let video capabilities be the result of executing the Get Supported 654 // TODO(jrummell): Enforce this once the deprecation warning is removed.
578 // Capabilities for Media Type algorithm on Video, candidate 655 // See http://crbug.com/616233.
579 // configuration's videoCapabilities member, and accumulated 656
580 // configuration. 657 // 16. If the videoCapabilities member in candidate configuration is
581 // 10.2. If video capabilities is null, return null. 658 // non-empty:
582 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities; 659 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities;
660 if (!candidate.videoCapabilities.isEmpty()) {
661 // 16.1. Let video capabilities be the result of executing the Get
662 // Supported Capabilities for Audio/Video Type algorithm on Video,
663 // candidate configuration's videoCapabilities member, accumulated
664 // configuration, and restrictions.
665 // 16.2. If video capabilities is null, return NotSupported.
583 if (!GetSupportedCapabilities(key_system, EmeMediaType::VIDEO, 666 if (!GetSupportedCapabilities(key_system, EmeMediaType::VIDEO,
584 candidate.videoCapabilities, config_state, 667 candidate.videoCapabilities, config_state,
585 &video_capabilities)) { 668 &video_capabilities)) {
586 return CONFIGURATION_NOT_SUPPORTED; 669 return CONFIGURATION_NOT_SUPPORTED;
587 } 670 }
588 671
589 // 10.3. Add video capabilities to accumulated configuration. 672 // 16.3. Set the videoCapabilities member of accumulated configuration
590 accumulated_configuration->hasVideoCapabilities = true; 673 // to video capabilities.
674 accumulated_configuration->videoCapabilities = video_capabilities;
675 } else {
676 // Otherwise set the videoCapabilities member of accumulated configuration
677 // to an empty sequence.
591 accumulated_configuration->videoCapabilities = video_capabilities; 678 accumulated_configuration->videoCapabilities = video_capabilities;
592 } 679 }
593 680
594 // 11. If the audioCapabilities member is present in candidate configuration: 681 // 17. If the audioCapabilities member in candidate configuration is
595 if (candidate.hasAudioCapabilities) { 682 // non-empty:
596 // 11.1. Let audio capabilities be the result of executing the Get Supported 683 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities;
597 // Capabilities for Media Type algorithm on Audio, candidate 684 if (!candidate.audioCapabilities.isEmpty()) {
598 // configuration's audioCapabilities member, and accumulated 685 // 17.1. Let audio capabilities be the result of executing the Get
599 // configuration. 686 // Supported Capabilities for Audio/Video Type algorithm on Audio,
600 // 11.2. If audio capabilities is null, return null. 687 // candidate configuration's audioCapabilities member, accumulated
601 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities; 688 // configuration, and restrictions.
689 // 17.2. If audio capabilities is null, return NotSupported.
602 if (!GetSupportedCapabilities(key_system, EmeMediaType::AUDIO, 690 if (!GetSupportedCapabilities(key_system, EmeMediaType::AUDIO,
603 candidate.audioCapabilities, config_state, 691 candidate.audioCapabilities, config_state,
604 &audio_capabilities)) { 692 &audio_capabilities)) {
605 return CONFIGURATION_NOT_SUPPORTED; 693 return CONFIGURATION_NOT_SUPPORTED;
606 } 694 }
607 695
608 // 11.3. Add audio capabilities to accumulated configuration. 696 // 17.3. Set the audioCapabilities member of accumulated configuration
609 accumulated_configuration->hasAudioCapabilities = true; 697 // to audio capabilities.
698 accumulated_configuration->audioCapabilities = audio_capabilities;
699 } else {
700 // Otherwise set the audioCapabilities member of accumulated configuration
701 // to an empty sequence.
610 accumulated_configuration->audioCapabilities = audio_capabilities; 702 accumulated_configuration->audioCapabilities = audio_capabilities;
611 } 703 }
612 704
613 // 12. If accumulated configuration's distinctiveIdentifier value is 705 // 18. If accumulated configuration's distinctiveIdentifier value is
614 // "optional", follow the steps for the first matching condition from the 706 // "optional", follow the steps for the first matching condition
615 // following list: 707 // from the following list:
616 // - If the implementation requires a Distinctive Identifier for any of 708 // - If the implementation requires use Distinctive Identifier(s) or
617 // the combinations in accumulated configuration, change accumulated 709 // Distinctive Permanent Identifier(s) for any of the combinations
618 // configuration's distinctiveIdentifier value to "required". 710 // in accumulated configuration, change accumulated configuration's
619 // - Otherwise, change accumulated configuration's distinctiveIdentifier 711 // distinctiveIdentifier value to "required".
620 // value to "not-allowed". 712 // - Otherwise, change accumulated configuration's
713 // distinctiveIdentifier value to "not-allowed".
621 if (accumulated_configuration->distinctiveIdentifier == 714 if (accumulated_configuration->distinctiveIdentifier ==
622 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { 715 EmeFeatureRequirement::Optional) {
623 EmeConfigRule not_allowed_rule = GetDistinctiveIdentifierConfigRule( 716 EmeConfigRule not_allowed_rule = GetDistinctiveIdentifierConfigRule(
624 key_systems_->GetDistinctiveIdentifierSupport(key_system), 717 key_systems_->GetDistinctiveIdentifierSupport(key_system),
625 EmeFeatureRequirement::NotAllowed); 718 EmeFeatureRequirement::NotAllowed);
626 EmeConfigRule required_rule = GetDistinctiveIdentifierConfigRule( 719 EmeConfigRule required_rule = GetDistinctiveIdentifierConfigRule(
627 key_systems_->GetDistinctiveIdentifierSupport(key_system), 720 key_systems_->GetDistinctiveIdentifierSupport(key_system),
628 EmeFeatureRequirement::Required); 721 EmeFeatureRequirement::Required);
629 bool not_allowed_supported = 722 bool not_allowed_supported =
630 config_state->IsRuleSupported(not_allowed_rule); 723 config_state->IsRuleSupported(not_allowed_rule);
631 bool required_supported = config_state->IsRuleSupported(required_rule); 724 bool required_supported = config_state->IsRuleSupported(required_rule);
632 // If a distinctive identifier is recommend and that is a possible outcome, 725 // If a distinctive identifier is recommend and that is a possible outcome,
633 // prefer that. 726 // prefer that.
634 if (required_supported && config_state->IsIdentifierRecommended() && 727 if (required_supported && config_state->IsIdentifierRecommended() &&
635 config_state->IsPermissionPossible()) { 728 config_state->IsPermissionPossible()) {
636 not_allowed_supported = false; 729 not_allowed_supported = false;
637 } 730 }
638 if (not_allowed_supported) { 731 if (not_allowed_supported) {
639 accumulated_configuration->distinctiveIdentifier = 732 accumulated_configuration->distinctiveIdentifier =
640 blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed; 733 EmeFeatureRequirement::NotAllowed;
641 config_state->AddRule(not_allowed_rule); 734 config_state->AddRule(not_allowed_rule);
642 } else if (required_supported) { 735 } else if (required_supported) {
643 accumulated_configuration->distinctiveIdentifier = 736 accumulated_configuration->distinctiveIdentifier =
644 blink::WebMediaKeySystemConfiguration::Requirement::Required; 737 EmeFeatureRequirement::Required;
645 config_state->AddRule(required_rule); 738 config_state->AddRule(required_rule);
646 } else { 739 } else {
647 // We should not have passed step 3. 740 // We should not have passed step 6.
648 NOTREACHED(); 741 NOTREACHED();
649 return CONFIGURATION_NOT_SUPPORTED; 742 return CONFIGURATION_NOT_SUPPORTED;
650 } 743 }
651 } 744 }
652 745
653 // 13. If accumulated configuration's persistentState value is "optional", 746 // 19. If accumulated configuration's persistentState value is "optional",
654 // follow the steps for the first matching condition from the following 747 // follow the steps for the first matching condition from the following
655 // list: 748 // list:
656 // - If the implementation requires persisting state for any of the 749 // - If the implementation requires persisting state for any of the
657 // combinations in accumulated configuration, change accumulated 750 // combinations in accumulated configuration, change accumulated
658 // configuration's persistentState value to "required". 751 // configuration's persistentState value to "required".
659 // - Otherwise, change accumulated configuration's persistentState value 752 // - Otherwise, change accumulated configuration's persistentState
660 // to "not-allowed". 753 // value to "not-allowed".
661 if (accumulated_configuration->persistentState == 754 if (accumulated_configuration->persistentState ==
662 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { 755 EmeFeatureRequirement::Optional) {
663 EmeConfigRule not_allowed_rule = GetPersistentStateConfigRule( 756 EmeConfigRule not_allowed_rule = GetPersistentStateConfigRule(
664 key_systems_->GetPersistentStateSupport(key_system), 757 key_systems_->GetPersistentStateSupport(key_system),
665 EmeFeatureRequirement::NotAllowed); 758 EmeFeatureRequirement::NotAllowed);
666 EmeConfigRule required_rule = GetPersistentStateConfigRule( 759 EmeConfigRule required_rule = GetPersistentStateConfigRule(
667 key_systems_->GetPersistentStateSupport(key_system), 760 key_systems_->GetPersistentStateSupport(key_system),
668 EmeFeatureRequirement::Required); 761 EmeFeatureRequirement::Required);
669 // |distinctiveIdentifier| should not be affected after it is decided. 762 // |distinctiveIdentifier| should not be affected after it is decided.
670 DCHECK(not_allowed_rule == EmeConfigRule::NOT_SUPPORTED || 763 DCHECK(not_allowed_rule == EmeConfigRule::NOT_SUPPORTED ||
671 not_allowed_rule == EmeConfigRule::PERSISTENCE_NOT_ALLOWED); 764 not_allowed_rule == EmeConfigRule::PERSISTENCE_NOT_ALLOWED);
672 DCHECK(required_rule == EmeConfigRule::NOT_SUPPORTED || 765 DCHECK(required_rule == EmeConfigRule::NOT_SUPPORTED ||
673 required_rule == EmeConfigRule::PERSISTENCE_REQUIRED); 766 required_rule == EmeConfigRule::PERSISTENCE_REQUIRED);
674 bool not_allowed_supported = 767 bool not_allowed_supported =
675 config_state->IsRuleSupported(not_allowed_rule); 768 config_state->IsRuleSupported(not_allowed_rule);
676 bool required_supported = config_state->IsRuleSupported(required_rule); 769 bool required_supported = config_state->IsRuleSupported(required_rule);
677 if (not_allowed_supported) { 770 if (not_allowed_supported) {
678 accumulated_configuration->persistentState = 771 accumulated_configuration->persistentState =
679 blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed; 772 EmeFeatureRequirement::NotAllowed;
680 config_state->AddRule(not_allowed_rule); 773 config_state->AddRule(not_allowed_rule);
681 } else if (required_supported) { 774 } else if (required_supported) {
682 accumulated_configuration->persistentState = 775 accumulated_configuration->persistentState =
683 blink::WebMediaKeySystemConfiguration::Requirement::Required; 776 EmeFeatureRequirement::Required;
684 config_state->AddRule(required_rule); 777 config_state->AddRule(required_rule);
685 } else { 778 } else {
686 // We should not have passed step 5. 779 // We should not have passed step 5.
687 NOTREACHED(); 780 NOTREACHED();
688 return CONFIGURATION_NOT_SUPPORTED; 781 return CONFIGURATION_NOT_SUPPORTED;
689 } 782 }
690 } 783 }
691 784
692 // 14. If implementation in the configuration specified by the combination of 785 // 20. If implementation in the configuration specified by the combination of
693 // the values in accumulated configuration is not supported or not allowed 786 // the values in accumulated configuration is not supported or not allowed
694 // in the origin, return null. 787 // in the origin, return NotSupported.
695 // 15. If accumulated configuration's distinctiveIdentifier value is 788 // TODO(jrummell): can we check that the CDM can't be loaded by the origin?
696 // "required", [prompt the user for consent]. 789
790 // 21. If accumulated configuration's distinctiveIdentifier value is
791 // "required" and the Distinctive Identifier(s) associated with
792 // accumulated configuration are not unique per origin and profile
793 // and clearable:
794 // 21.1. Update restrictions to reflect that all configurations described
795 // by accumulated configuration do not have user consent.
796 // 21.2. Return ConsentDenied and restrictions.
797 // (Not required as data is unique per origin and clearable.)
798
799 // 22. Let consent status and updated restrictions be the result of running
800 // the Get Consent Status algorithm on accumulated configuration,
801 // restrictions and origin and follow the steps for the value of consent
802 // status from the following list:
803 // - "ConsentDenied": Return ConsentDenied and updated restrictions.
804 // - "InformUser": Inform the user that accumulated configuration is
805 // in use in the origin including, specifically, the information
806 // that Distinctive Identifier(s) and/or Distinctive Permanent
807 // Identifier(s) as appropriate will be used if the
808 // distinctiveIdentifier member of accumulated configuration is
809 // "required". Continue to the next step.
810 // - "Allowed": Continue to the next step.
811 // Accumulated configuration's distinctiveIdentifier should be "required" or
812 // "notallowed"" due to step 18. If it is "required", prompt the user for
813 // consent unless it has already been granted.
697 if (accumulated_configuration->distinctiveIdentifier == 814 if (accumulated_configuration->distinctiveIdentifier ==
698 blink::WebMediaKeySystemConfiguration::Requirement::Required) { 815 EmeFeatureRequirement::Required) {
699 // The caller is responsible for resolving what to do if permission is 816 // The caller is responsible for resolving what to do if permission is
700 // required but has been denied (it should treat it as NOT_SUPPORTED). 817 // required but has been denied (it should treat it as NOT_SUPPORTED).
701 if (!config_state->IsPermissionGranted()) 818 if (!config_state->IsPermissionGranted())
702 return CONFIGURATION_REQUIRES_PERMISSION; 819 return CONFIGURATION_REQUIRES_PERMISSION;
703 } 820 }
704 821
705 // 16. If the label member is present in candidate configuration, add the 822 // 23. Return accumulated configuration.
706 // value of the candidate configuration's label member to accumulated
707 // configuration.
708 accumulated_configuration->label = candidate.label;
709
710 // 17. Return accumulated configuration.
711 return CONFIGURATION_SUPPORTED; 823 return CONFIGURATION_SUPPORTED;
712 } 824 }
713 825
714 void KeySystemConfigSelector::SelectConfig( 826 void KeySystemConfigSelector::SelectConfig(
715 const blink::WebString& key_system, 827 const blink::WebString& key_system,
716 const blink::WebVector<blink::WebMediaKeySystemConfiguration>& 828 const blink::WebVector<blink::WebMediaKeySystemConfiguration>&
717 candidate_configurations, 829 candidate_configurations,
718 const blink::WebSecurityOrigin& security_origin, 830 const blink::WebSecurityOrigin& security_origin,
719 bool are_secure_codecs_supported, 831 bool are_secure_codecs_supported,
720 base::Callback<void(const blink::WebMediaKeySystemConfiguration&, 832 base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
721 const CdmConfig&)> succeeded_cb, 833 const CdmConfig&)> succeeded_cb,
722 base::Callback<void(const blink::WebString&)> not_supported_cb) { 834 base::Callback<void(const blink::WebString&)> not_supported_cb) {
723 // Continued from requestMediaKeySystemAccess(), step 7, from 835 // Continued from requestMediaKeySystemAccess(), step 6, from
724 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess 836 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess
725 // 837 //
726 // 7.1. If keySystem is not one of the Key Systems supported by the user 838 // 6.1 If keySystem is not one of the Key Systems supported by the user
727 // agent, reject promise with with a new DOMException whose name is 839 // agent, reject promise with a NotSupportedError. String comparison
728 // NotSupportedError. String comparison is case-sensitive. 840 // is case-sensitive.
729 if (!base::IsStringASCII(key_system)) { 841 if (!base::IsStringASCII(key_system)) {
730 not_supported_cb.Run("Only ASCII keySystems are supported"); 842 not_supported_cb.Run("Only ASCII keySystems are supported");
731 return; 843 return;
732 } 844 }
733 845
734 std::string key_system_ascii = 846 std::string key_system_ascii =
735 base::UTF16ToASCII(base::StringPiece16(key_system)); 847 base::UTF16ToASCII(base::StringPiece16(key_system));
736 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { 848 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) {
737 not_supported_cb.Run("Unsupported keySystem"); 849 not_supported_cb.Run("Unsupported keySystem");
738 return; 850 return;
739 } 851 }
740 852
741 // 7.2-7.4. Implemented by OnSelectConfig(). 853 // 6.2-6.4. Implemented by OnSelectConfig().
742 // TODO(sandersd): This should be async, ideally not on the main thread. 854 // TODO(sandersd): This should be async, ideally not on the main thread.
743 std::unique_ptr<SelectionRequest> request(new SelectionRequest()); 855 std::unique_ptr<SelectionRequest> request(new SelectionRequest());
744 request->key_system = key_system_ascii; 856 request->key_system = key_system_ascii;
745 request->candidate_configurations = candidate_configurations; 857 request->candidate_configurations = candidate_configurations;
746 request->security_origin = security_origin; 858 request->security_origin = security_origin;
747 request->are_secure_codecs_supported = are_secure_codecs_supported; 859 request->are_secure_codecs_supported = are_secure_codecs_supported;
748 request->succeeded_cb = succeeded_cb; 860 request->succeeded_cb = succeeded_cb;
749 request->not_supported_cb = not_supported_cb; 861 request->not_supported_cb = not_supported_cb;
750 SelectConfigInternal(std::move(request)); 862 SelectConfigInternal(std::move(request));
751 } 863 }
752 864
753 void KeySystemConfigSelector::SelectConfigInternal( 865 void KeySystemConfigSelector::SelectConfigInternal(
754 std::unique_ptr<SelectionRequest> request) { 866 std::unique_ptr<SelectionRequest> request) {
755 // Continued from requestMediaKeySystemAccess(), step 7.1, from 867 // Continued from requestMediaKeySystemAccess(), step 6, from
756 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess 868 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess
757 // 869 //
758 // 7.2. Let implementation be the implementation of keySystem. 870 // 6.2. Let implementation be the implementation of keySystem.
759 // (|key_systems_| fills this role.) 871 // (|key_systems_| fills this role.)
760 // 7.3. For each value in supportedConfigurations: 872 // 6.3. For each value in supportedConfigurations:
761 for (size_t i = 0; i < request->candidate_configurations.size(); i++) { 873 for (size_t i = 0; i < request->candidate_configurations.size(); i++) {
762 // 7.3.1. Let candidate configuration be the value. 874 // 6.3.1. Let candidate configuration be the value.
763 // 7.3.2. Let supported configuration be the result of executing the Get 875 // 6.3.2. Let supported configuration be the result of executing the Get
764 // Supported Configuration algorithm on implementation, candidate 876 // Supported Configuration algorithm on implementation, candidate
765 // configuration, and origin. 877 // configuration, and origin.
766 // 7.3.3. If supported configuration is not null, [initialize and return a 878 // 6.3.3. If supported configuration is not NotSupported, [initialize
767 // new MediaKeySystemAccess object.] 879 // and return a new MediaKeySystemAccess object.]
768 ConfigState config_state(request->was_permission_requested, 880 ConfigState config_state(request->was_permission_requested,
769 request->is_permission_granted); 881 request->is_permission_granted);
770 DCHECK(config_state.IsRuleSupported( 882 DCHECK(config_state.IsRuleSupported(
771 EmeConfigRule::HW_SECURE_CODECS_NOT_ALLOWED)); 883 EmeConfigRule::HW_SECURE_CODECS_NOT_ALLOWED));
772 if (!request->are_secure_codecs_supported) 884 if (!request->are_secure_codecs_supported)
773 config_state.AddRule(EmeConfigRule::HW_SECURE_CODECS_NOT_ALLOWED); 885 config_state.AddRule(EmeConfigRule::HW_SECURE_CODECS_NOT_ALLOWED);
774 blink::WebMediaKeySystemConfiguration accumulated_configuration; 886 blink::WebMediaKeySystemConfiguration accumulated_configuration;
775 CdmConfig cdm_config; 887 CdmConfig cdm_config;
776 ConfigurationSupport support = GetSupportedConfiguration( 888 ConfigurationSupport support = GetSupportedConfiguration(
777 request->key_system, request->candidate_configurations[i], 889 request->key_system, request->candidate_configurations[i],
(...skipping 14 matching lines...) Expand all
792 blink::WebStringToGURL(request->security_origin.toString())); 904 blink::WebStringToGURL(request->security_origin.toString()));
793 media_permission_->RequestPermission( 905 media_permission_->RequestPermission(
794 MediaPermission::PROTECTED_MEDIA_IDENTIFIER, security_origin, 906 MediaPermission::PROTECTED_MEDIA_IDENTIFIER, security_origin,
795 base::Bind(&KeySystemConfigSelector::OnPermissionResult, 907 base::Bind(&KeySystemConfigSelector::OnPermissionResult,
796 weak_factory_.GetWeakPtr(), base::Passed(&request))); 908 weak_factory_.GetWeakPtr(), base::Passed(&request)));
797 } 909 }
798 return; 910 return;
799 case CONFIGURATION_SUPPORTED: 911 case CONFIGURATION_SUPPORTED:
800 cdm_config.allow_distinctive_identifier = 912 cdm_config.allow_distinctive_identifier =
801 (accumulated_configuration.distinctiveIdentifier == 913 (accumulated_configuration.distinctiveIdentifier ==
802 blink::WebMediaKeySystemConfiguration::Requirement::Required); 914 EmeFeatureRequirement::Required);
803 cdm_config.allow_persistent_state = 915 cdm_config.allow_persistent_state =
804 (accumulated_configuration.persistentState == 916 (accumulated_configuration.persistentState ==
805 blink::WebMediaKeySystemConfiguration::Requirement::Required); 917 EmeFeatureRequirement::Required);
806 cdm_config.use_hw_secure_codecs = 918 cdm_config.use_hw_secure_codecs =
807 config_state.AreHwSecureCodecsRequired(); 919 config_state.AreHwSecureCodecsRequired();
808 request->succeeded_cb.Run(accumulated_configuration, cdm_config); 920 request->succeeded_cb.Run(accumulated_configuration, cdm_config);
809 return; 921 return;
810 } 922 }
811 } 923 }
812 924
813 // 7.4. Reject promise with a new DOMException whose name is 925 // 6.4. Reject promise with a NotSupportedError.
814 // NotSupportedError.
815 request->not_supported_cb.Run( 926 request->not_supported_cb.Run(
816 "None of the requested configurations were supported."); 927 "None of the requested configurations were supported.");
817 } 928 }
818 929
819 void KeySystemConfigSelector::OnPermissionResult( 930 void KeySystemConfigSelector::OnPermissionResult(
820 std::unique_ptr<SelectionRequest> request, 931 std::unique_ptr<SelectionRequest> request,
821 bool is_permission_granted) { 932 bool is_permission_granted) {
822 request->was_permission_requested = true; 933 request->was_permission_requested = true;
823 request->is_permission_granted = is_permission_granted; 934 request->is_permission_granted = is_permission_granted;
824 SelectConfigInternal(std::move(request)); 935 SelectConfigInternal(std::move(request));
825 } 936 }
826 937
827 } // namespace media 938 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698