| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // TODO(sandersd): Move implementation into KeySystemConfigSelector? | 56 // TODO(sandersd): Move implementation into KeySystemConfigSelector? |
| 57 bool IsSupportedInitDataType(const std::string& key_system, | 57 bool IsSupportedInitDataType(const std::string& key_system, |
| 58 EmeInitDataType init_data_type) const override { | 58 EmeInitDataType init_data_type) const override { |
| 59 switch (init_data_type) { | 59 switch (init_data_type) { |
| 60 case EmeInitDataType::UNKNOWN: | 60 case EmeInitDataType::UNKNOWN: |
| 61 return false; | 61 return false; |
| 62 case EmeInitDataType::WEBM: | 62 case EmeInitDataType::WEBM: |
| 63 return (init_data_types & kInitDataTypeMaskWebM) != 0; | 63 return init_data_type_webm_supported_; |
| 64 case EmeInitDataType::CENC: | 64 case EmeInitDataType::CENC: |
| 65 return (init_data_types & kInitDataTypeMaskCenc) != 0; | 65 return init_data_type_cenc_supported_; |
| 66 case EmeInitDataType::KEYIDS: | 66 case EmeInitDataType::KEYIDS: |
| 67 return (init_data_types & kInitDataTypeMaskKeyIds) != 0; | 67 return init_data_type_keyids_supported_; |
| 68 } | 68 } |
| 69 NOTREACHED(); | 69 NOTREACHED(); |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // TODO(sandersd): Secure codec simulation. | 73 // TODO(sandersd): Secure codec simulation. |
| 74 EmeConfigRule GetContentTypeConfigRule( | 74 EmeConfigRule GetContentTypeConfigRule( |
| 75 const std::string& key_system, | 75 const std::string& key_system, |
| 76 EmeMediaType media_type, | 76 EmeMediaType media_type, |
| 77 const std::string& container_mime_type, | 77 const std::string& container_mime_type, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 EmeFeatureSupport GetPersistentStateSupport( | 116 EmeFeatureSupport GetPersistentStateSupport( |
| 117 const std::string& key_system) const override { | 117 const std::string& key_system) const override { |
| 118 return persistent_state; | 118 return persistent_state; |
| 119 } | 119 } |
| 120 | 120 |
| 121 EmeFeatureSupport GetDistinctiveIdentifierSupport( | 121 EmeFeatureSupport GetDistinctiveIdentifierSupport( |
| 122 const std::string& key_system) const override { | 122 const std::string& key_system) const override { |
| 123 return distinctive_identifier; | 123 return distinctive_identifier; |
| 124 } | 124 } |
| 125 | 125 |
| 126 InitDataTypeMask init_data_types = kInitDataTypeMaskNone; | 126 bool init_data_type_webm_supported_ = false; |
| 127 bool init_data_type_cenc_supported_ = false; |
| 128 bool init_data_type_keyids_supported_ = false; |
| 127 | 129 |
| 128 // INVALID so that they must be set in any test that needs them. | 130 // INVALID so that they must be set in any test that needs them. |
| 129 EmeSessionTypeSupport persistent_license = EmeSessionTypeSupport::INVALID; | 131 EmeSessionTypeSupport persistent_license = EmeSessionTypeSupport::INVALID; |
| 130 EmeSessionTypeSupport persistent_release_message = | 132 EmeSessionTypeSupport persistent_release_message = |
| 131 EmeSessionTypeSupport::INVALID; | 133 EmeSessionTypeSupport::INVALID; |
| 132 | 134 |
| 133 // Every test implicitly requires these, so they must be set. They are set to | 135 // Every test implicitly requires these, so they must be set. They are set to |
| 134 // values that are likely to cause tests to fail if they are accidentally | 136 // values that are likely to cause tests to fail if they are accidentally |
| 135 // depended on. Test cases explicitly depending on them should set them, as | 137 // depended on. Test cases explicitly depending on them should set them, as |
| 136 // the default values may be changed. | 138 // the default values may be changed. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 290 |
| 289 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_Empty) { | 291 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_Empty) { |
| 290 blink::WebMediaKeySystemConfiguration config; | 292 blink::WebMediaKeySystemConfiguration config; |
| 291 config.hasInitDataTypes = true; | 293 config.hasInitDataTypes = true; |
| 292 configs_.push_back(config); | 294 configs_.push_back(config); |
| 293 | 295 |
| 294 ASSERT_TRUE(SelectConfigReturnsError()); | 296 ASSERT_TRUE(SelectConfigReturnsError()); |
| 295 } | 297 } |
| 296 | 298 |
| 297 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_NoneSupported) { | 299 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_NoneSupported) { |
| 298 key_systems_->init_data_types = kInitDataTypeMaskWebM; | 300 key_systems_->init_data_type_webm_supported_ = true; |
| 299 | 301 |
| 300 std::vector<blink::WebEncryptedMediaInitDataType> init_data_types; | 302 std::vector<blink::WebEncryptedMediaInitDataType> init_data_types; |
| 301 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Unknown); | 303 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Unknown); |
| 302 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Cenc); | 304 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Cenc); |
| 303 | 305 |
| 304 blink::WebMediaKeySystemConfiguration config; | 306 blink::WebMediaKeySystemConfiguration config; |
| 305 config.hasInitDataTypes = true; | 307 config.hasInitDataTypes = true; |
| 306 config.initDataTypes = init_data_types; | 308 config.initDataTypes = init_data_types; |
| 307 configs_.push_back(config); | 309 configs_.push_back(config); |
| 308 | 310 |
| 309 ASSERT_TRUE(SelectConfigReturnsError()); | 311 ASSERT_TRUE(SelectConfigReturnsError()); |
| 310 } | 312 } |
| 311 | 313 |
| 312 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_SubsetSupported) { | 314 TEST_F(KeySystemConfigSelectorTest, InitDataTypes_SubsetSupported) { |
| 313 key_systems_->init_data_types = kInitDataTypeMaskWebM; | 315 key_systems_->init_data_type_webm_supported_ = true; |
| 314 | 316 |
| 315 std::vector<blink::WebEncryptedMediaInitDataType> init_data_types; | 317 std::vector<blink::WebEncryptedMediaInitDataType> init_data_types; |
| 316 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Unknown); | 318 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Unknown); |
| 317 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Cenc); | 319 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Cenc); |
| 318 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Webm); | 320 init_data_types.push_back(blink::WebEncryptedMediaInitDataType::Webm); |
| 319 | 321 |
| 320 blink::WebMediaKeySystemConfiguration config; | 322 blink::WebMediaKeySystemConfiguration config; |
| 321 config.hasInitDataTypes = true; | 323 config.hasInitDataTypes = true; |
| 322 config.initDataTypes = init_data_types; | 324 config.initDataTypes = init_data_types; |
| 323 configs_.push_back(config); | 325 configs_.push_back(config); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 761 |
| 760 blink::WebMediaKeySystemConfiguration config2; | 762 blink::WebMediaKeySystemConfiguration config2; |
| 761 config2.label = "b"; | 763 config2.label = "b"; |
| 762 configs_.push_back(config2); | 764 configs_.push_back(config2); |
| 763 | 765 |
| 764 ASSERT_TRUE(SelectConfigRequestsPermissionAndReturnsConfig()); | 766 ASSERT_TRUE(SelectConfigRequestsPermissionAndReturnsConfig()); |
| 765 ASSERT_EQ("b", config_.label); | 767 ASSERT_EQ("b", config_.label); |
| 766 } | 768 } |
| 767 | 769 |
| 768 } // namespace media | 770 } // namespace media |
| OLD | NEW |