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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 return !is_identifier_not_allowed_ && IsPermissionPossible(); | 170 return !is_identifier_not_allowed_ && IsPermissionPossible(); |
| 171 case EmeConfigRule::IDENTIFIER_RECOMMENDED: | 171 case EmeConfigRule::IDENTIFIER_RECOMMENDED: |
| 172 return true; | 172 return true; |
| 173 case EmeConfigRule::PERSISTENCE_NOT_ALLOWED: | 173 case EmeConfigRule::PERSISTENCE_NOT_ALLOWED: |
| 174 return !is_persistence_required_; | 174 return !is_persistence_required_; |
| 175 case EmeConfigRule::PERSISTENCE_REQUIRED: | 175 case EmeConfigRule::PERSISTENCE_REQUIRED: |
| 176 return !is_persistence_not_allowed_; | 176 return !is_persistence_not_allowed_; |
| 177 case EmeConfigRule::IDENTIFIER_AND_PERSISTENCE_REQUIRED: | 177 case EmeConfigRule::IDENTIFIER_AND_PERSISTENCE_REQUIRED: |
| 178 return (!is_identifier_not_allowed_ && IsPermissionPossible() && | 178 return (!is_identifier_not_allowed_ && IsPermissionPossible() && |
| 179 !is_persistence_not_allowed_); | 179 !is_persistence_not_allowed_); |
| 180 #if defined(OS_ANDROID) | 180 #if defined(OS_ANDROID) |
|
ddorwin
2015/05/08 16:29:18
#include "build/build_config.h"
| |
| 181 case EmeConfigRule::SECURE_CODECS_NOT_ALLOWED: | 181 case EmeConfigRule::SECURE_CODECS_NOT_ALLOWED: |
| 182 return !are_secure_codecs_required_; | 182 return !are_secure_codecs_required_; |
| 183 case EmeConfigRule::SECURE_CODECS_REQUIRED: | 183 case EmeConfigRule::SECURE_CODECS_REQUIRED: |
| 184 return !are_secure_codecs_not_allowed_; | 184 return !are_secure_codecs_not_allowed_; |
| 185 #endif // defined(OS_ANDROID) | 185 #endif // defined(OS_ANDROID) |
| 186 case EmeConfigRule::SUPPORTED: | 186 case EmeConfigRule::SUPPORTED: |
| 187 return true; | 187 return true; |
| 188 } | 188 } |
| 189 NOTREACHED(); | 189 NOTREACHED(); |
| 190 return false; | 190 return false; |
| (...skipping 85 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 | 754 |
| 755 void KeySystemConfigSelector::OnPermissionResult( | 755 void KeySystemConfigSelector::OnPermissionResult( |
| 756 scoped_ptr<SelectionRequest> request, | 756 scoped_ptr<SelectionRequest> request, |
| 757 bool is_permission_granted) { | 757 bool is_permission_granted) { |
| 758 request->was_permission_requested = true; | 758 request->was_permission_requested = true; |
| 759 request->is_permission_granted = is_permission_granted; | 759 request->is_permission_granted = is_permission_granted; |
| 760 SelectConfigInternal(request.Pass()); | 760 SelectConfigInternal(request.Pass()); |
| 761 } | 761 } |
| 762 | 762 |
| 763 } // namespace media | 763 } // namespace media |
| OLD | NEW |