| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 : key_systems_(key_systems), | 270 : key_systems_(key_systems), |
| 271 media_permission_(media_permission), | 271 media_permission_(media_permission), |
| 272 weak_factory_(this) { | 272 weak_factory_(this) { |
| 273 DCHECK(key_systems_); | 273 DCHECK(key_systems_); |
| 274 DCHECK(media_permission_); | 274 DCHECK(media_permission_); |
| 275 } | 275 } |
| 276 | 276 |
| 277 KeySystemConfigSelector::~KeySystemConfigSelector() { | 277 KeySystemConfigSelector::~KeySystemConfigSelector() { |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool IsSupportedClearMediaFormat(const std::string& container_mime_type, | 280 bool IsSupportedMediaFormat(const std::string& container_mime_type, |
| 281 const std::string& codecs) { | 281 const std::string& codecs, |
| 282 bool use_aes_decryptor) { |
| 282 std::vector<std::string> codec_vector; | 283 std::vector<std::string> codec_vector; |
| 283 media::ParseCodecString(codecs, &codec_vector, false); | 284 ParseCodecString(codecs, &codec_vector, false); |
| 284 media::SupportsType support_result = | 285 // AesDecryptor decrypts the stream in the demuxer before it reaches the |
| 285 media::IsSupportedEncryptedMediaFormat(container_mime_type, codec_vector); | 286 // decoder so check whether the media format is supported when clear. |
| 287 SupportsType support_result = |
| 288 use_aes_decryptor |
| 289 ? IsSupportedMediaFormat(container_mime_type, codec_vector) |
| 290 : IsSupportedEncryptedMediaFormat(container_mime_type, codec_vector); |
| 286 switch (support_result) { | 291 switch (support_result) { |
| 287 case media::IsSupported: | 292 case IsSupported: |
| 288 return true; | 293 return true; |
| 289 case media::MayBeSupported: | 294 case MayBeSupported: |
| 290 // If no codecs were specified, the best possible result is | 295 // If no codecs were specified, the best possible result is |
| 291 // MayBeSupported, indicating support for the container. | 296 // MayBeSupported, indicating support for the container. |
| 292 return codec_vector.empty(); | 297 return codec_vector.empty(); |
| 293 case media::IsNotSupported: | 298 case IsNotSupported: |
| 294 return false; | 299 return false; |
| 295 } | 300 } |
| 296 NOTREACHED(); | 301 NOTREACHED(); |
| 297 return false; | 302 return false; |
| 298 } | 303 } |
| 299 | 304 |
| 300 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid | 305 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid |
| 301 // parameters can be rejected. http://crbug.com/417561 | 306 // parameters can be rejected. http://crbug.com/417561 |
| 302 bool KeySystemConfigSelector::IsSupportedContentType( | 307 bool KeySystemConfigSelector::IsSupportedContentType( |
| 303 const std::string& key_system, | 308 const std::string& key_system, |
| 304 EmeMediaType media_type, | 309 EmeMediaType media_type, |
| 305 const std::string& container_mime_type, | 310 const std::string& container_mime_type, |
| 306 const std::string& codecs, | 311 const std::string& codecs, |
| 307 KeySystemConfigSelector::ConfigState* config_state) { | 312 KeySystemConfigSelector::ConfigState* config_state) { |
| 308 // Check that |container_mime_type| and |codecs| are supported by Chrome. This | 313 // Check that |container_mime_type| and |codecs| are supported by Chrome. This |
| 309 // is done primarily to validate extended codecs, but it also ensures that the | 314 // is done primarily to validate extended codecs, but it also ensures that the |
| 310 // CDM cannot support codecs that Chrome does not (which could complicate the | 315 // CDM cannot support codecs that Chrome does not (which could complicate the |
| 311 // robustness algorithm). | 316 // robustness algorithm). |
| 312 if (!IsSupportedClearMediaFormat(container_mime_type, codecs)) | 317 if (!IsSupportedMediaFormat(container_mime_type, codecs, |
| 318 CanUseAesDecryptor(key_system))) { |
| 313 return false; | 319 return false; |
| 320 } |
| 314 | 321 |
| 315 // TODO(servolk): Converting |container_mime_type| to lower-case could be | 322 // TODO(servolk): Converting |container_mime_type| to lower-case could be |
| 316 // moved to KeySystemsImpl::GetContentTypeConfigRule, plus we could add some | 323 // moved to KeySystemsImpl::GetContentTypeConfigRule, plus we could add some |
| 317 // upper-case container name test cases in media/base/key_systems_unittest.cc. | 324 // upper-case container name test cases in media/base/key_systems_unittest.cc. |
| 318 std::string container_lower = base::ToLowerASCII(container_mime_type); | 325 std::string container_lower = base::ToLowerASCII(container_mime_type); |
| 319 | 326 |
| 320 // Check that |container_mime_type| and |codecs| are supported by the CDM. | 327 // Check that |container_mime_type| and |codecs| are supported by the CDM. |
| 321 // This check does not handle extended codecs, so extended codec information | 328 // This check does not handle extended codecs, so extended codec information |
| 322 // is stripped (extended codec information was checked above). | 329 // is stripped (extended codec information was checked above). |
| 323 std::vector<std::string> stripped_codec_vector; | 330 std::vector<std::string> stripped_codec_vector; |
| 324 media::ParseCodecString(codecs, &stripped_codec_vector, true); | 331 ParseCodecString(codecs, &stripped_codec_vector, true); |
| 325 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( | 332 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( |
| 326 key_system, media_type, container_lower, stripped_codec_vector); | 333 key_system, media_type, container_lower, stripped_codec_vector); |
| 327 if (!config_state->IsRuleSupported(codecs_rule)) | 334 if (!config_state->IsRuleSupported(codecs_rule)) |
| 328 return false; | 335 return false; |
| 329 config_state->AddRule(codecs_rule); | 336 config_state->AddRule(codecs_rule); |
| 330 | 337 |
| 331 return true; | 338 return true; |
| 332 } | 339 } |
| 333 | 340 |
| 334 bool KeySystemConfigSelector::GetSupportedCapabilities( | 341 bool KeySystemConfigSelector::GetSupportedCapabilities( |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 803 |
| 797 void KeySystemConfigSelector::OnPermissionResult( | 804 void KeySystemConfigSelector::OnPermissionResult( |
| 798 scoped_ptr<SelectionRequest> request, | 805 scoped_ptr<SelectionRequest> request, |
| 799 bool is_permission_granted) { | 806 bool is_permission_granted) { |
| 800 request->was_permission_requested = true; | 807 request->was_permission_requested = true; |
| 801 request->is_permission_granted = is_permission_granted; | 808 request->is_permission_granted = is_permission_granted; |
| 802 SelectConfigInternal(std::move(request)); | 809 SelectConfigInternal(std::move(request)); |
| 803 } | 810 } |
| 804 | 811 |
| 805 } // namespace media | 812 } // namespace media |
| OLD | NEW |