| 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" |
| 11 #include "media/base/key_systems.h" | 11 #include "media/base/key_systems.h" |
| 12 #include "media/base/media_permission.h" | 12 #include "media/base/media_permission.h" |
| 13 #include "media/base/mime_util.h" |
| 13 #include "media/blink/webmediaplayer_util.h" | 14 #include "media/blink/webmediaplayer_util.h" |
| 14 #include "net/base/mime_util.h" | |
| 15 #include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h" | 15 #include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h" |
| 16 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 16 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 17 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
| 18 #include "third_party/WebKit/public/platform/WebVector.h" | 18 #include "third_party/WebKit/public/platform/WebVector.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 using EmeFeatureRequirement = | 23 using EmeFeatureRequirement = |
| 24 blink::WebMediaKeySystemConfiguration::Requirement; | 24 blink::WebMediaKeySystemConfiguration::Requirement; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 const std::string& key_system, | 276 const std::string& key_system, |
| 277 EmeMediaType media_type, | 277 EmeMediaType media_type, |
| 278 const std::string& container_mime_type, | 278 const std::string& container_mime_type, |
| 279 const std::string& codecs, | 279 const std::string& codecs, |
| 280 KeySystemConfigSelector::ConfigState* config_state) { | 280 KeySystemConfigSelector::ConfigState* config_state) { |
| 281 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid | 281 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid |
| 282 // parameters can be rejected. http://crbug.com/417561 | 282 // parameters can be rejected. http://crbug.com/417561 |
| 283 std::string container_lower = base::StringToLowerASCII(container_mime_type); | 283 std::string container_lower = base::StringToLowerASCII(container_mime_type); |
| 284 | 284 |
| 285 // Check that |container_mime_type| is supported by Chrome. | 285 // Check that |container_mime_type| is supported by Chrome. |
| 286 if (!net::IsSupportedMediaMimeType(container_lower)) | 286 if (!media::IsSupportedMediaMimeType(container_lower)) |
| 287 return false; | 287 return false; |
| 288 | 288 |
| 289 // Check that |codecs| are supported by Chrome. This is done primarily to | 289 // Check that |codecs| are supported by Chrome. This is done primarily to |
| 290 // validate extended codecs, but it also ensures that the CDM cannot support | 290 // validate extended codecs, but it also ensures that the CDM cannot support |
| 291 // codecs that Chrome does not (which could complicate the robustness | 291 // codecs that Chrome does not (which could complicate the robustness |
| 292 // algorithm). | 292 // algorithm). |
| 293 std::vector<std::string> codec_vector; | 293 std::vector<std::string> codec_vector; |
| 294 net::ParseCodecString(codecs, &codec_vector, false); | 294 media::ParseCodecString(codecs, &codec_vector, false); |
| 295 if (!codec_vector.empty() && | 295 if (!codec_vector.empty() && |
| 296 (net::IsSupportedStrictMediaMimeType(container_lower, codec_vector) != | 296 (media::IsSupportedStrictMediaMimeType(container_lower, codec_vector) != |
| 297 net::IsSupported)) { | 297 media::IsSupported)) { |
| 298 return false; | 298 return false; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Check that |container_mime_type| and |codecs| are supported by the CDM. | 301 // Check that |container_mime_type| and |codecs| are supported by the CDM. |
| 302 // This check does not handle extended codecs, so extended codec information | 302 // This check does not handle extended codecs, so extended codec information |
| 303 // is stripped (extended codec information was checked above). | 303 // is stripped (extended codec information was checked above). |
| 304 std::vector<std::string> stripped_codec_vector; | 304 std::vector<std::string> stripped_codec_vector; |
| 305 net::ParseCodecString(codecs, &stripped_codec_vector, true); | 305 media::ParseCodecString(codecs, &stripped_codec_vector, true); |
| 306 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( | 306 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( |
| 307 key_system, media_type, container_lower, stripped_codec_vector); | 307 key_system, media_type, container_lower, stripped_codec_vector); |
| 308 if (!config_state->IsRuleSupported(codecs_rule)) | 308 if (!config_state->IsRuleSupported(codecs_rule)) |
| 309 return false; | 309 return false; |
| 310 config_state->AddRule(codecs_rule); | 310 config_state->AddRule(codecs_rule); |
| 311 | 311 |
| 312 return true; | 312 return true; |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool KeySystemConfigSelector::GetSupportedCapabilities( | 315 bool KeySystemConfigSelector::GetSupportedCapabilities( |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 760 |
| 761 void KeySystemConfigSelector::OnPermissionResult( | 761 void KeySystemConfigSelector::OnPermissionResult( |
| 762 scoped_ptr<SelectionRequest> request, | 762 scoped_ptr<SelectionRequest> request, |
| 763 bool is_permission_granted) { | 763 bool is_permission_granted) { |
| 764 request->was_permission_requested = true; | 764 request->was_permission_requested = true; |
| 765 request->is_permission_granted = is_permission_granted; | 765 request->is_permission_granted = is_permission_granted; |
| 766 SelectConfigInternal(request.Pass()); | 766 SelectConfigInternal(request.Pass()); |
| 767 } | 767 } |
| 768 | 768 |
| 769 } // namespace media | 769 } // namespace media |
| OLD | NEW |