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 "key_system_config_selector.h" | 5 #include "key_system_config_selector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 DVLOG(2) << "Rejecting requested configuration because " | 340 DVLOG(2) << "Rejecting requested configuration because " |
341 << "a capability contentType was empty."; | 341 << "a capability contentType was empty."; |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 // 3.4-3.11. (Implemented by IsSupportedContentType().) | 345 // 3.4-3.11. (Implemented by IsSupportedContentType().) |
346 ConfigState proposed_config_state = *config_state; | 346 ConfigState proposed_config_state = *config_state; |
347 if (!base::IsStringASCII(capability.mimeType) || | 347 if (!base::IsStringASCII(capability.mimeType) || |
348 !base::IsStringASCII(capability.codecs) || | 348 !base::IsStringASCII(capability.codecs) || |
349 !IsSupportedContentType(key_system, media_type, | 349 !IsSupportedContentType(key_system, media_type, |
350 base::UTF16ToASCII(capability.mimeType), | 350 base::UTF16ToASCII( |
351 base::UTF16ToASCII(capability.codecs), | 351 base::StringPiece16(capability.mimeType)), |
| 352 base::UTF16ToASCII( |
| 353 base::StringPiece16(capability.codecs)), |
352 &proposed_config_state)) { | 354 &proposed_config_state)) { |
353 continue; | 355 continue; |
354 } | 356 } |
355 // 3.12. If robustness is not the empty string, run the following steps: | 357 // 3.12. If robustness is not the empty string, run the following steps: |
356 if (!capability.robustness.isEmpty()) { | 358 if (!capability.robustness.isEmpty()) { |
357 // 3.12.1. If robustness is an unrecognized value or not supported by | 359 // 3.12.1. If robustness is an unrecognized value or not supported by |
358 // implementation, continue to the next iteration. String | 360 // implementation, continue to the next iteration. String |
359 // comparison is case-sensitive. | 361 // comparison is case-sensitive. |
360 if (!base::IsStringASCII(capability.robustness)) | 362 if (!base::IsStringASCII(capability.robustness)) |
361 continue; | 363 continue; |
362 EmeConfigRule robustness_rule = key_systems_->GetRobustnessConfigRule( | 364 EmeConfigRule robustness_rule = key_systems_->GetRobustnessConfigRule( |
363 key_system, media_type, base::UTF16ToASCII(capability.robustness)); | 365 key_system, media_type, base::UTF16ToASCII( |
| 366 base::StringPiece16(capability.robustness))); |
364 if (!proposed_config_state.IsRuleSupported(robustness_rule)) | 367 if (!proposed_config_state.IsRuleSupported(robustness_rule)) |
365 continue; | 368 continue; |
366 proposed_config_state.AddRule(robustness_rule); | 369 proposed_config_state.AddRule(robustness_rule); |
367 // 3.12.2. Add robustness to configuration. | 370 // 3.12.2. Add robustness to configuration. |
368 // (It's already added, we use capability as configuration.) | 371 // (It's already added, we use capability as configuration.) |
369 } | 372 } |
370 // 3.13. If the user agent and implementation do not support playback of | 373 // 3.13. If the user agent and implementation do not support playback of |
371 // encrypted media data as specified by configuration, including all | 374 // encrypted media data as specified by configuration, including all |
372 // media types, in combination with local accumulated capabilities, | 375 // media types, in combination with local accumulated capabilities, |
373 // continue to the next iteration. | 376 // continue to the next iteration. |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess | 684 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess |
682 // | 685 // |
683 // 7.1. If keySystem is not one of the Key Systems supported by the user | 686 // 7.1. If keySystem is not one of the Key Systems supported by the user |
684 // agent, reject promise with with a new DOMException whose name is | 687 // agent, reject promise with with a new DOMException whose name is |
685 // NotSupportedError. String comparison is case-sensitive. | 688 // NotSupportedError. String comparison is case-sensitive. |
686 if (!base::IsStringASCII(key_system)) { | 689 if (!base::IsStringASCII(key_system)) { |
687 not_supported_cb.Run("Only ASCII keySystems are supported"); | 690 not_supported_cb.Run("Only ASCII keySystems are supported"); |
688 return; | 691 return; |
689 } | 692 } |
690 | 693 |
691 std::string key_system_ascii = base::UTF16ToASCII(key_system); | 694 std::string key_system_ascii = |
| 695 base::UTF16ToASCII(base::StringPiece16(key_system)); |
692 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { | 696 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { |
693 not_supported_cb.Run("Unsupported keySystem"); | 697 not_supported_cb.Run("Unsupported keySystem"); |
694 return; | 698 return; |
695 } | 699 } |
696 | 700 |
697 // 7.2-7.4. Implemented by OnSelectConfig(). | 701 // 7.2-7.4. Implemented by OnSelectConfig(). |
698 // TODO(sandersd): This should be async, ideally not on the main thread. | 702 // TODO(sandersd): This should be async, ideally not on the main thread. |
699 scoped_ptr<SelectionRequest> request(new SelectionRequest()); | 703 scoped_ptr<SelectionRequest> request(new SelectionRequest()); |
700 request->key_system = key_system_ascii; | 704 request->key_system = key_system_ascii; |
701 request->candidate_configurations = candidate_configurations; | 705 request->candidate_configurations = candidate_configurations; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 | 777 |
774 void KeySystemConfigSelector::OnPermissionResult( | 778 void KeySystemConfigSelector::OnPermissionResult( |
775 scoped_ptr<SelectionRequest> request, | 779 scoped_ptr<SelectionRequest> request, |
776 bool is_permission_granted) { | 780 bool is_permission_granted) { |
777 request->was_permission_requested = true; | 781 request->was_permission_requested = true; |
778 request->is_permission_granted = is_permission_granted; | 782 request->is_permission_granted = is_permission_granted; |
779 SelectConfigInternal(request.Pass()); | 783 SelectConfigInternal(request.Pass()); |
780 } | 784 } |
781 | 785 |
782 } // namespace media | 786 } // namespace media |
OLD | NEW |