| OLD | NEW |
| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if (capability.mimeType.isEmpty()) { | 395 if (capability.mimeType.isEmpty()) { |
| 396 DVLOG(2) << "Rejecting requested configuration because " | 396 DVLOG(2) << "Rejecting requested configuration because " |
| 397 << "a capability contentType was empty."; | 397 << "a capability contentType was empty."; |
| 398 return false; | 398 return false; |
| 399 } | 399 } |
| 400 | 400 |
| 401 // 3.4-3.11. (Implemented by IsSupportedContentType().) | 401 // 3.4-3.11. (Implemented by IsSupportedContentType().) |
| 402 ConfigState proposed_config_state = *config_state; | 402 ConfigState proposed_config_state = *config_state; |
| 403 if (!base::IsStringASCII(capability.mimeType) || | 403 if (!base::IsStringASCII(capability.mimeType) || |
| 404 !base::IsStringASCII(capability.codecs) || | 404 !base::IsStringASCII(capability.codecs) || |
| 405 !IsSupportedContentType(key_system, media_type, | 405 !IsSupportedContentType( |
| 406 base::UTF16ToASCII( | 406 key_system, media_type, capability.mimeType.ascii(), |
| 407 base::StringPiece16(capability.mimeType)), | 407 capability.codecs.ascii(), &proposed_config_state)) { |
| 408 base::UTF16ToASCII( | |
| 409 base::StringPiece16(capability.codecs)), | |
| 410 &proposed_config_state)) { | |
| 411 continue; | 408 continue; |
| 412 } | 409 } |
| 413 // 3.12. If robustness is not the empty string, run the following steps: | 410 // 3.12. If robustness is not the empty string, run the following steps: |
| 414 if (!capability.robustness.isEmpty()) { | 411 if (!capability.robustness.isEmpty()) { |
| 415 // 3.12.1. If robustness is an unrecognized value or not supported by | 412 // 3.12.1. If robustness is an unrecognized value or not supported by |
| 416 // implementation, continue to the next iteration. String | 413 // implementation, continue to the next iteration. String |
| 417 // comparison is case-sensitive. | 414 // comparison is case-sensitive. |
| 418 if (!base::IsStringASCII(capability.robustness)) | 415 if (!base::IsStringASCII(capability.robustness)) |
| 419 continue; | 416 continue; |
| 420 EmeConfigRule robustness_rule = key_systems_->GetRobustnessConfigRule( | 417 EmeConfigRule robustness_rule = key_systems_->GetRobustnessConfigRule( |
| 421 key_system, media_type, base::UTF16ToASCII( | 418 key_system, media_type, capability.robustness.ascii()); |
| 422 base::StringPiece16(capability.robustness))); | |
| 423 if (!proposed_config_state.IsRuleSupported(robustness_rule)) | 419 if (!proposed_config_state.IsRuleSupported(robustness_rule)) |
| 424 continue; | 420 continue; |
| 425 proposed_config_state.AddRule(robustness_rule); | 421 proposed_config_state.AddRule(robustness_rule); |
| 426 // 3.12.2. Add robustness to configuration. | 422 // 3.12.2. Add robustness to configuration. |
| 427 // (It's already added, we use capability as configuration.) | 423 // (It's already added, we use capability as configuration.) |
| 428 } | 424 } |
| 429 // 3.13. If the user agent and implementation do not support playback of | 425 // 3.13. If the user agent and implementation do not support playback of |
| 430 // encrypted media data as specified by configuration, including all | 426 // encrypted media data as specified by configuration, including all |
| 431 // media types, in combination with local accumulated capabilities, | 427 // media types, in combination with local accumulated capabilities, |
| 432 // continue to the next iteration. | 428 // continue to the next iteration. |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 bool are_secure_codecs_supported, | 827 bool are_secure_codecs_supported, |
| 832 base::Callback<void(const blink::WebMediaKeySystemConfiguration&, | 828 base::Callback<void(const blink::WebMediaKeySystemConfiguration&, |
| 833 const CdmConfig&)> succeeded_cb, | 829 const CdmConfig&)> succeeded_cb, |
| 834 base::Callback<void(const blink::WebString&)> not_supported_cb) { | 830 base::Callback<void(const blink::WebString&)> not_supported_cb) { |
| 835 // Continued from requestMediaKeySystemAccess(), step 6, from | 831 // Continued from requestMediaKeySystemAccess(), step 6, from |
| 836 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess | 832 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess |
| 837 // | 833 // |
| 838 // 6.1 If keySystem is not one of the Key Systems supported by the user | 834 // 6.1 If keySystem is not one of the Key Systems supported by the user |
| 839 // agent, reject promise with a NotSupportedError. String comparison | 835 // agent, reject promise with a NotSupportedError. String comparison |
| 840 // is case-sensitive. | 836 // is case-sensitive. |
| 841 if (!base::IsStringASCII(key_system)) { | 837 if (!key_system.containsOnlyASCII()) { |
| 842 not_supported_cb.Run("Only ASCII keySystems are supported"); | 838 not_supported_cb.Run("Only ASCII keySystems are supported"); |
| 843 return; | 839 return; |
| 844 } | 840 } |
| 845 | 841 |
| 846 std::string key_system_ascii = | 842 std::string key_system_ascii = key_system.ascii(); |
| 847 base::UTF16ToASCII(base::StringPiece16(key_system)); | |
| 848 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { | 843 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { |
| 849 not_supported_cb.Run("Unsupported keySystem"); | 844 not_supported_cb.Run("Unsupported keySystem"); |
| 850 return; | 845 return; |
| 851 } | 846 } |
| 852 | 847 |
| 853 // 6.2-6.4. Implemented by OnSelectConfig(). | 848 // 6.2-6.4. Implemented by OnSelectConfig(). |
| 854 // TODO(sandersd): This should be async, ideally not on the main thread. | 849 // TODO(sandersd): This should be async, ideally not on the main thread. |
| 855 std::unique_ptr<SelectionRequest> request(new SelectionRequest()); | 850 std::unique_ptr<SelectionRequest> request(new SelectionRequest()); |
| 856 request->key_system = key_system_ascii; | 851 request->key_system = key_system_ascii; |
| 857 request->candidate_configurations = candidate_configurations; | 852 request->candidate_configurations = candidate_configurations; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 923 |
| 929 void KeySystemConfigSelector::OnPermissionResult( | 924 void KeySystemConfigSelector::OnPermissionResult( |
| 930 std::unique_ptr<SelectionRequest> request, | 925 std::unique_ptr<SelectionRequest> request, |
| 931 bool is_permission_granted) { | 926 bool is_permission_granted) { |
| 932 request->was_permission_requested = true; | 927 request->was_permission_requested = true; |
| 933 request->is_permission_granted = is_permission_granted; | 928 request->is_permission_granted = is_permission_granted; |
| 934 SelectConfigInternal(std::move(request)); | 929 SelectConfigInternal(std::move(request)); |
| 935 } | 930 } |
| 936 | 931 |
| 937 } // namespace media | 932 } // namespace media |
| OLD | NEW |