Chromium Code Reviews| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 const std::string& container_mime_type, | 258 const std::string& container_mime_type, |
| 259 const std::string& codecs) { | 259 const std::string& codecs) { |
| 260 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid | 260 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid |
| 261 // parameters can be rejected. http://crbug.com/417561 | 261 // parameters can be rejected. http://crbug.com/417561 |
| 262 std::string container_lower = base::StringToLowerASCII(container_mime_type); | 262 std::string container_lower = base::StringToLowerASCII(container_mime_type); |
| 263 | 263 |
| 264 // Check that |container_mime_type| and |codecs| are supported by the CDM. | 264 // Check that |container_mime_type| and |codecs| are supported by the CDM. |
| 265 // This check does not handle extended codecs, so extended codec information | 265 // This check does not handle extended codecs, so extended codec information |
| 266 // is stripped. | 266 // is stripped. |
| 267 std::vector<std::string> codec_vector; | 267 std::vector<std::string> codec_vector; |
| 268 net::ParseCodecString(codecs, &codec_vector, true); | 268 media::ParseCodecString(codecs, &codec_vector, true); |
| 269 if (!key_systems_->IsSupportedCodecCombination( | 269 if (!key_systems_->IsSupportedCodecCombination( |
| 270 key_system, media_type, container_lower, codec_vector)) { | 270 key_system, media_type, container_lower, codec_vector)) { |
| 271 return false; | 271 return false; |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Check that |container_mime_type| is supported by Chrome. This can only | 274 // Check that |container_mime_type| is supported by Chrome. This can only |
| 275 // happen if the CDM declares support for a container that Chrome does not. | 275 // happen if the CDM declares support for a container that Chrome does not. |
| 276 if (!net::IsSupportedMediaMimeType(container_lower)) { | 276 if (!media::IsSupportedMediaMimeType(container_lower)) { |
| 277 NOTREACHED(); | 277 NOTREACHED(); |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Check that |codecs| are supported by Chrome. This is done primarily to | 281 // Check that |codecs| are supported by Chrome. This is done primarily to |
| 282 // validate extended codecs, but it also ensures that the CDM cannot support | 282 // validate extended codecs, but it also ensures that the CDM cannot support |
| 283 // codecs that Chrome does not (which could complicate the robustness | 283 // codecs that Chrome does not (which could complicate the robustness |
| 284 // algorithm). | 284 // algorithm). |
| 285 if (codec_vector.empty()) | 285 if (codec_vector.empty()) |
| 286 return true; | 286 return true; |
| 287 codec_vector.clear(); | 287 codec_vector.clear(); |
| 288 net::ParseCodecString(codecs, &codec_vector, false); | 288 media::ParseCodecString(codecs, &codec_vector, false); |
| 289 return (net::IsSupportedStrictMediaMimeType(container_lower, codec_vector) == | 289 return (media::IsSupportedStrictMediaMimeType(container_lower, codec_vector) |
| 290 net::IsSupported); | 290 == media::IsSupported); |
|
Ryan Sleevi
2015/05/06 00:59:13
is this git cl formatted?
servolk
2015/05/06 01:13:39
No, for some reason it's broken on my machine, and
| |
| 291 } | 291 } |
| 292 | 292 |
| 293 bool KeySystemConfigSelector::GetSupportedCapabilities( | 293 bool KeySystemConfigSelector::GetSupportedCapabilities( |
| 294 const std::string& key_system, | 294 const std::string& key_system, |
| 295 EmeMediaType media_type, | 295 EmeMediaType media_type, |
| 296 const blink::WebVector<blink::WebMediaKeySystemMediaCapability>& | 296 const blink::WebVector<blink::WebMediaKeySystemMediaCapability>& |
| 297 requested_media_capabilities, | 297 requested_media_capabilities, |
| 298 KeySystemConfigSelector::ConfigState* config_state, | 298 KeySystemConfigSelector::ConfigState* config_state, |
| 299 std::vector<blink::WebMediaKeySystemMediaCapability>* | 299 std::vector<blink::WebMediaKeySystemMediaCapability>* |
| 300 supported_media_capabilities) { | 300 supported_media_capabilities) { |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 | 728 |
| 729 void KeySystemConfigSelector::OnPermissionResult( | 729 void KeySystemConfigSelector::OnPermissionResult( |
| 730 scoped_ptr<SelectionRequest> request, | 730 scoped_ptr<SelectionRequest> request, |
| 731 bool is_permission_granted) { | 731 bool is_permission_granted) { |
| 732 request->was_permission_requested = true; | 732 request->was_permission_requested = true; |
| 733 request->is_permission_granted = is_permission_granted; | 733 request->is_permission_granted = is_permission_granted; |
| 734 SelectConfigInternal(request.Pass()); | 734 SelectConfigInternal(request.Pass()); |
| 735 } | 735 } |
| 736 | 736 |
| 737 } // namespace media | 737 } // namespace media |
| OLD | NEW |