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 "webencryptedmediaclient_impl.h" | 5 #include "webencryptedmediaclient_impl.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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 return EmeRobustness::SW_SECURE_DECODE; | 135 return EmeRobustness::SW_SECURE_DECODE; |
136 if (robustness == "HW_SECURE_CRYPTO") | 136 if (robustness == "HW_SECURE_CRYPTO") |
137 return EmeRobustness::HW_SECURE_CRYPTO; | 137 return EmeRobustness::HW_SECURE_CRYPTO; |
138 if (robustness == "HW_SECURE_DECODE") | 138 if (robustness == "HW_SECURE_DECODE") |
139 return EmeRobustness::HW_SECURE_DECODE; | 139 return EmeRobustness::HW_SECURE_DECODE; |
140 if (robustness == "HW_SECURE_ALL") | 140 if (robustness == "HW_SECURE_ALL") |
141 return EmeRobustness::HW_SECURE_ALL; | 141 return EmeRobustness::HW_SECURE_ALL; |
142 return EmeRobustness::INVALID; | 142 return EmeRobustness::INVALID; |
143 } | 143 } |
144 | 144 |
145 static bool IsSupportedContentType(const std::string& key_system, | 145 static bool IsSupportedContentType( |
146 const std::string& mime_type, | 146 const KeySystems& key_systems, |
147 const std::string& codecs) { | 147 const std::string& key_system, |
148 EmeMediaType media_type, | |
149 const std::string& container_mime_type, | |
150 const std::string& codecs) { | |
148 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid | 151 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid |
149 // parameters can be rejected. http://crbug.com/417561 | 152 // parameters can be rejected. http://crbug.com/417561 |
150 // TODO(sandersd): Pass in the media type (audio or video) and check that the | 153 std::string container_lower = base::StringToLowerASCII(container_mime_type); |
151 // container type matches. http://crbug.com/457384 | 154 |
152 std::string container = base::StringToLowerASCII(mime_type); | 155 // Make sure the container matches |media_type|. |
156 switch (media_type) { | |
157 case EmeMediaType::AUDIO: | |
158 if (!StartsWithASCII(container_lower, "audio/", true)) | |
159 return false; | |
160 break; | |
161 case EmeMediaType::VIDEO: | |
162 if (!StartsWithASCII(container_lower, "video/", true)) | |
163 return false; | |
164 break; | |
165 } | |
153 | 166 |
154 // Check that |codecs| are supported by the CDM. This check does not handle | 167 // Check that |codecs| are supported by the CDM. This check does not handle |
155 // extended codecs, so extended codec information is stripped. | 168 // extended codecs, so extended codec information is stripped. |
156 // TODO(sandersd): Reject codecs that do not match the media type. | 169 // TODO(sandersd): Reject codecs that do not match the media type. |
157 // http://crbug.com/457386 | 170 // http://crbug.com/457386 |
158 std::vector<std::string> codec_vector; | 171 std::vector<std::string> codec_vector; |
159 net::ParseCodecString(codecs, &codec_vector, true); | 172 net::ParseCodecString(codecs, &codec_vector, true); |
160 if (!IsSupportedKeySystemWithMediaMimeType(container, codec_vector, | 173 if (!key_systems.IsSupportedCodecCombination( |
161 key_system)) { | 174 key_system, media_type, container_lower, codec_vector)) { |
162 return false; | 175 return false; |
163 } | 176 } |
164 | 177 |
165 // Check that |codecs| are supported by Chrome. This is done primarily to | 178 // Check that |codecs| are supported by Chrome. This is done primarily to |
166 // validate extended codecs, but it also ensures that the CDM cannot support | 179 // validate extended codecs, but it also ensures that the CDM cannot support |
167 // codecs that Chrome does not (which would be bad because it would require | 180 // codecs that Chrome does not (which would be bad because it would require |
168 // considering the accumulated configuration, and could affect whether secure | 181 // considering the accumulated configuration, and could affect whether secure |
169 // decode is required). | 182 // decode is required). |
170 // TODO(sandersd): Reject ambiguous codecs. http://crbug.com/374751 | 183 // TODO(sandersd): Reject ambiguous codecs. http://crbug.com/374751 |
171 codec_vector.clear(); | 184 codec_vector.clear(); |
172 net::ParseCodecString(codecs, &codec_vector, false); | 185 net::ParseCodecString(codecs, &codec_vector, false); |
173 return net::AreSupportedMediaCodecs(codec_vector); | 186 return net::AreSupportedMediaCodecs(codec_vector); |
174 } | 187 } |
175 | 188 |
176 static bool GetSupportedCapabilities( | 189 static bool GetSupportedCapabilities( |
190 const KeySystems& key_systems, | |
177 const std::string& key_system, | 191 const std::string& key_system, |
192 EmeMediaType media_type, | |
178 const blink::WebVector<blink::WebMediaKeySystemMediaCapability>& | 193 const blink::WebVector<blink::WebMediaKeySystemMediaCapability>& |
179 capabilities, | 194 capabilities, |
ddorwin
2015/03/20 00:55:03
rename this requested_ and l197 supported_capabili
sandersd (OOO until July 31)
2015/03/20 22:53:19
I'm not sure, this exactly matches the names from
| |
180 EmeMediaType media_type, | 195 ConfigState* config_state, |
181 std::vector<blink::WebMediaKeySystemMediaCapability>* | 196 std::vector<blink::WebMediaKeySystemMediaCapability>* |
182 media_type_capabilities, | 197 media_type_capabilities) { |
183 ConfigState* config_state) { | |
184 // From | 198 // From |
185 // https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-media -type | 199 // https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-media -type |
186 // 1. Let accumulated capabilities be partial configuration. | 200 // 1. Let accumulated capabilities be partial configuration. |
187 // (Skipped as there are no configuration-based codec restrictions.) | 201 // (Skipped as there are no configuration-based codec restrictions.) |
188 // 2. Let media type capabilities be empty. | 202 // 2. Let media type capabilities be empty. |
189 DCHECK_EQ(media_type_capabilities->size(), 0ul); | 203 DCHECK_EQ(media_type_capabilities->size(), 0ul); |
190 // 3. For each value in capabilities: | 204 // 3. For each value in capabilities: |
191 for (size_t i = 0; i < capabilities.size(); i++) { | 205 for (size_t i = 0; i < capabilities.size(); i++) { |
192 // 3.1. Let contentType be the value's contentType member. | 206 // 3.1. Let contentType be the value's contentType member. |
193 // 3.2. Let robustness be the value's robustness member. | 207 // 3.2. Let robustness be the value's robustness member. |
194 const blink::WebMediaKeySystemMediaCapability& capability = capabilities[i]; | 208 const blink::WebMediaKeySystemMediaCapability& capability = capabilities[i]; |
195 // 3.3. If contentType is the empty string, return null. | 209 // 3.3. If contentType is the empty string, return null. |
196 if (capability.mimeType.isEmpty()) { | 210 if (capability.mimeType.isEmpty()) { |
197 DVLOG(2) << "Rejecting requested configuration because " | 211 DVLOG(2) << "Rejecting requested configuration because " |
198 << "a capability contentType was empty."; | 212 << "a capability contentType was empty."; |
199 return false; | 213 return false; |
200 } | 214 } |
201 // 3.4-3.11. (Implemented by IsSupportedContentType().) | 215 // 3.4-3.11. (Implemented by IsSupportedContentType().) |
202 if (!base::IsStringASCII(capability.mimeType) || | 216 if (!base::IsStringASCII(capability.mimeType) || |
203 !base::IsStringASCII(capability.codecs) || | 217 !base::IsStringASCII(capability.codecs) || |
204 !IsSupportedContentType(key_system, | 218 !IsSupportedContentType(key_systems, key_system, media_type, |
205 base::UTF16ToASCII(capability.mimeType), | 219 base::UTF16ToASCII(capability.mimeType), |
206 base::UTF16ToASCII(capability.codecs))) { | 220 base::UTF16ToASCII(capability.codecs))) { |
207 continue; | 221 continue; |
208 } | 222 } |
209 // 3.12. If robustness is not the empty string, run the following steps: | 223 // 3.12. If robustness is not the empty string, run the following steps: |
210 if (!capability.robustness.isEmpty()) { | 224 if (!capability.robustness.isEmpty()) { |
211 // 3.12.1. If robustness is an unrecognized value or not supported by | 225 // 3.12.1. If robustness is an unrecognized value or not supported by |
212 // implementation, continue to the next iteration. String | 226 // implementation, continue to the next iteration. String |
213 // comparison is case-sensitive. | 227 // comparison is case-sensitive. |
214 EmeConfigRule robustness_rule = GetRobustnessConfigRule( | 228 EmeConfigRule robustness_rule = key_systems.GetRobustnessConfigRule( |
215 key_system, media_type, ConvertRobustness(capability.robustness)); | 229 key_system, media_type, ConvertRobustness(capability.robustness)); |
216 if (!config_state->IsRuleSupported(robustness_rule)) | 230 if (!config_state->IsRuleSupported(robustness_rule)) |
217 continue; | 231 continue; |
218 config_state->AddRule(robustness_rule); | 232 config_state->AddRule(robustness_rule); |
219 // 3.12.2. Add robustness to configuration. | 233 // 3.12.2. Add robustness to configuration. |
220 // (It's already added, we use capability as the configuration.) | 234 // (It's already added, we use capability as the configuration.) |
221 } | 235 } |
222 // 3.13. If the user agent and implementation do not support playback of | 236 // 3.13. If the user agent and implementation do not support playback of |
223 // encrypted media data as specified by configuration, including all | 237 // encrypted media data as specified by configuration, including all |
224 // media types, in combination with accumulated capabilities, | 238 // media types, in combination with accumulated capabilities, |
(...skipping 27 matching lines...) Expand all Loading... | |
252 return EME_FEATURE_OPTIONAL; | 266 return EME_FEATURE_OPTIONAL; |
253 case blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed: | 267 case blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed: |
254 return EME_FEATURE_NOT_ALLOWED; | 268 return EME_FEATURE_NOT_ALLOWED; |
255 } | 269 } |
256 | 270 |
257 NOTREACHED(); | 271 NOTREACHED(); |
258 return EME_FEATURE_NOT_ALLOWED; | 272 return EME_FEATURE_NOT_ALLOWED; |
259 } | 273 } |
260 | 274 |
261 static ConfigurationSupport GetSupportedConfiguration( | 275 static ConfigurationSupport GetSupportedConfiguration( |
276 const KeySystems& key_systems, | |
262 const std::string& key_system, | 277 const std::string& key_system, |
263 const blink::WebMediaKeySystemConfiguration& candidate, | 278 const blink::WebMediaKeySystemConfiguration& candidate, |
264 bool was_permission_requested, | 279 bool was_permission_requested, |
265 bool is_permission_granted, | 280 bool is_permission_granted, |
266 blink::WebMediaKeySystemConfiguration* accumulated_configuration) { | 281 blink::WebMediaKeySystemConfiguration* accumulated_configuration) { |
267 ConfigState config_state(was_permission_requested, is_permission_granted); | 282 ConfigState config_state(was_permission_requested, is_permission_granted); |
268 | 283 |
269 // From https://w3c.github.io/encrypted-media/#get-supported-configuration | 284 // From https://w3c.github.io/encrypted-media/#get-supported-configuration |
270 // 1. Let accumulated configuration be empty. (Done by caller.) | 285 // 1. Let accumulated configuration be empty. (Done by caller.) |
271 // 2. If candidate configuration's initDataTypes attribute is not empty, run | 286 // 2. If candidate configuration's initDataTypes attribute is not empty, run |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 // distinctiveIdentifier attribute from the following list: | 338 // distinctiveIdentifier attribute from the following list: |
324 // - "required": If the implementation does not support a persistent | 339 // - "required": If the implementation does not support a persistent |
325 // Distinctive Identifier in combination with accumulated configuration, | 340 // Distinctive Identifier in combination with accumulated configuration, |
326 // return null. | 341 // return null. |
327 // - "optional": Continue. | 342 // - "optional": Continue. |
328 // - "not-allowed": If the implementation requires a Distinctive | 343 // - "not-allowed": If the implementation requires a Distinctive |
329 // Identifier in combination with accumulated configuration, return | 344 // Identifier in combination with accumulated configuration, return |
330 // null. | 345 // null. |
331 // We also reject OPTIONAL when distinctive identifiers are ALWAYS_ENABLED and | 346 // We also reject OPTIONAL when distinctive identifiers are ALWAYS_ENABLED and |
332 // permission has already been denied. This would happen anyway at step 11. | 347 // permission has already been denied. This would happen anyway at step 11. |
333 EmeConfigRule di_rule = GetDistinctiveIdentifierConfigRule( | 348 EmeConfigRule di_rule = key_systems.GetDistinctiveIdentifierConfigRule( |
334 key_system, ConvertRequirement(candidate.distinctiveIdentifier)); | 349 key_system, ConvertRequirement(candidate.distinctiveIdentifier)); |
335 if (!config_state.IsRuleSupported(di_rule)) { | 350 if (!config_state.IsRuleSupported(di_rule)) { |
336 DVLOG(2) << "Rejecting requested configuration because " | 351 DVLOG(2) << "Rejecting requested configuration because " |
337 << "the distinctiveIdentifier requirement was not supported."; | 352 << "the distinctiveIdentifier requirement was not supported."; |
338 return CONFIGURATION_NOT_SUPPORTED; | 353 return CONFIGURATION_NOT_SUPPORTED; |
339 } | 354 } |
340 config_state.AddRule(di_rule); | 355 config_state.AddRule(di_rule); |
341 | 356 |
342 // 4. Add the value of the candidate configuration's distinctiveIdentifier | 357 // 4. Add the value of the candidate configuration's distinctiveIdentifier |
343 // attribute to accumulated configuration. | 358 // attribute to accumulated configuration. |
344 accumulated_configuration->distinctiveIdentifier = | 359 accumulated_configuration->distinctiveIdentifier = |
345 candidate.distinctiveIdentifier; | 360 candidate.distinctiveIdentifier; |
346 | 361 |
347 // 5. Follow the steps for the value of candidate configuration's | 362 // 5. Follow the steps for the value of candidate configuration's |
348 // persistentState attribute from the following list: | 363 // persistentState attribute from the following list: |
349 // - "required": If the implementation does not support persisting state | 364 // - "required": If the implementation does not support persisting state |
350 // in combination with accumulated configuration, return null. | 365 // in combination with accumulated configuration, return null. |
351 // - "optional": Continue. | 366 // - "optional": Continue. |
352 // - "not-allowed": If the implementation requires persisting state in | 367 // - "not-allowed": If the implementation requires persisting state in |
353 // combination with accumulated configuration, return null. | 368 // combination with accumulated configuration, return null. |
354 EmeConfigRule ps_rule = GetPersistentStateConfigRule( | 369 EmeConfigRule ps_rule = key_systems.GetPersistentStateConfigRule( |
355 key_system, ConvertRequirement(candidate.persistentState)); | 370 key_system, ConvertRequirement(candidate.persistentState)); |
356 if (!config_state.IsRuleSupported(ps_rule)) { | 371 if (!config_state.IsRuleSupported(ps_rule)) { |
357 DVLOG(2) << "Rejecting requested configuration because " | 372 DVLOG(2) << "Rejecting requested configuration because " |
358 << "the persistentState requirement was not supported."; | 373 << "the persistentState requirement was not supported."; |
359 return CONFIGURATION_NOT_SUPPORTED; | 374 return CONFIGURATION_NOT_SUPPORTED; |
360 } | 375 } |
361 config_state.AddRule(ps_rule); | 376 config_state.AddRule(ps_rule); |
362 | 377 |
363 // 6. Add the value of the candidate configuration's persistentState | 378 // 6. Add the value of the candidate configuration's persistentState |
364 // attribute to accumulated configuration. | 379 // attribute to accumulated configuration. |
365 accumulated_configuration->persistentState = candidate.persistentState; | 380 accumulated_configuration->persistentState = candidate.persistentState; |
366 | 381 |
367 // 7. If candidate configuration's videoCapabilities attribute is not empty, | 382 // 7. If candidate configuration's videoCapabilities attribute is not empty, |
368 // run the following steps: | 383 // run the following steps: |
369 if (!candidate.videoCapabilities.isEmpty()) { | 384 if (!candidate.videoCapabilities.isEmpty()) { |
370 // 7.1. Let video capabilities be the result of executing the Get Supported | 385 // 7.1. Let video capabilities be the result of executing the Get Supported |
371 // Capabilities for Media Type algorithm on Video, candidate | 386 // Capabilities for Media Type algorithm on Video, candidate |
372 // configuration's videoCapabilities attribute, and accumulated | 387 // configuration's videoCapabilities attribute, and accumulated |
373 // configuration. | 388 // configuration. |
374 // 7.2. If video capabilities is null, return null. | 389 // 7.2. If video capabilities is null, return null. |
375 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities; | 390 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities; |
376 if (!GetSupportedCapabilities(key_system, candidate.videoCapabilities, | 391 if (!GetSupportedCapabilities(key_systems, key_system, EmeMediaType::VIDEO, |
377 EmeMediaType::VIDEO, &video_capabilities, | 392 candidate.videoCapabilities, |
378 &config_state)) { | 393 &config_state, &video_capabilities)) { |
379 return CONFIGURATION_NOT_SUPPORTED; | 394 return CONFIGURATION_NOT_SUPPORTED; |
380 } | 395 } |
381 | 396 |
382 // 7.3. Add video capabilities to accumulated configuration. | 397 // 7.3. Add video capabilities to accumulated configuration. |
383 accumulated_configuration->videoCapabilities = video_capabilities; | 398 accumulated_configuration->videoCapabilities = video_capabilities; |
384 } | 399 } |
385 | 400 |
386 // 8. If candidate configuration's audioCapabilities attribute is not empty, | 401 // 8. If candidate configuration's audioCapabilities attribute is not empty, |
387 // run the following steps: | 402 // run the following steps: |
388 if (!candidate.audioCapabilities.isEmpty()) { | 403 if (!candidate.audioCapabilities.isEmpty()) { |
389 // 8.1. Let audio capabilities be the result of executing the Get Supported | 404 // 8.1. Let audio capabilities be the result of executing the Get Supported |
390 // Capabilities for Media Type algorithm on Audio, candidate | 405 // Capabilities for Media Type algorithm on Audio, candidate |
391 // configuration's audioCapabilities attribute, and accumulated | 406 // configuration's audioCapabilities attribute, and accumulated |
392 // configuration. | 407 // configuration. |
393 // 8.2. If audio capabilities is null, return null. | 408 // 8.2. If audio capabilities is null, return null. |
394 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities; | 409 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities; |
395 if (!GetSupportedCapabilities(key_system, candidate.audioCapabilities, | 410 if (!GetSupportedCapabilities(key_systems, key_system, EmeMediaType::AUDIO, |
396 EmeMediaType::AUDIO, &audio_capabilities, | 411 candidate.audioCapabilities, |
397 &config_state)) { | 412 &config_state, &audio_capabilities)) { |
398 return CONFIGURATION_NOT_SUPPORTED; | 413 return CONFIGURATION_NOT_SUPPORTED; |
399 } | 414 } |
400 | 415 |
401 // 8.3. Add audio capabilities to accumulated configuration. | 416 // 8.3. Add audio capabilities to accumulated configuration. |
402 accumulated_configuration->audioCapabilities = audio_capabilities; | 417 accumulated_configuration->audioCapabilities = audio_capabilities; |
403 } | 418 } |
404 | 419 |
405 // 9. If accumulated configuration's distinctiveIdentifier value is | 420 // 9. If accumulated configuration's distinctiveIdentifier value is |
406 // "optional", follow the steps for the first matching condition from the | 421 // "optional", follow the steps for the first matching condition from the |
407 // following list: | 422 // following list: |
408 // - If the implementation requires a Distinctive Identifier for any of | 423 // - If the implementation requires a Distinctive Identifier for any of |
409 // the combinations in accumulated configuration, change accumulated | 424 // the combinations in accumulated configuration, change accumulated |
410 // configuration's distinctiveIdentifier value to "required". | 425 // configuration's distinctiveIdentifier value to "required". |
411 // - Otherwise, change accumulated configuration's distinctiveIdentifier | 426 // - Otherwise, change accumulated configuration's distinctiveIdentifier |
412 // value to "not-allowed". | 427 // value to "not-allowed". |
413 if (accumulated_configuration->distinctiveIdentifier == | 428 if (accumulated_configuration->distinctiveIdentifier == |
414 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { | 429 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { |
415 EmeConfigRule not_allowed_rule = | 430 EmeConfigRule not_allowed_rule = |
416 GetDistinctiveIdentifierConfigRule(key_system, EME_FEATURE_NOT_ALLOWED); | 431 key_systems.GetDistinctiveIdentifierConfigRule( |
432 key_system, EME_FEATURE_NOT_ALLOWED); | |
417 EmeConfigRule required_rule = | 433 EmeConfigRule required_rule = |
418 GetDistinctiveIdentifierConfigRule(key_system, EME_FEATURE_REQUIRED); | 434 key_systems.GetDistinctiveIdentifierConfigRule( |
435 key_system, EME_FEATURE_REQUIRED); | |
419 bool not_allowed_supported = config_state.IsRuleSupported(not_allowed_rule); | 436 bool not_allowed_supported = config_state.IsRuleSupported(not_allowed_rule); |
420 bool required_supported = config_state.IsRuleSupported(required_rule); | 437 bool required_supported = config_state.IsRuleSupported(required_rule); |
421 if (not_allowed_supported) { | 438 if (not_allowed_supported) { |
422 bool prefer_required = config_state.IsIdentifierRequired() || | 439 bool prefer_required = config_state.IsIdentifierRequired() || |
423 (config_state.IsIdentifierRecommended() && | 440 (config_state.IsIdentifierRecommended() && |
424 config_state.IsPermissionPossible()); | 441 config_state.IsPermissionPossible()); |
425 if (required_supported && prefer_required) { | 442 if (required_supported && prefer_required) { |
426 accumulated_configuration->distinctiveIdentifier = | 443 accumulated_configuration->distinctiveIdentifier = |
427 blink::WebMediaKeySystemConfiguration::Requirement::Required; | 444 blink::WebMediaKeySystemConfiguration::Requirement::Required; |
428 config_state.AddRule(required_rule); | 445 config_state.AddRule(required_rule); |
(...skipping 29 matching lines...) Expand all Loading... | |
458 // follow the steps for the first matching condition from the following | 475 // follow the steps for the first matching condition from the following |
459 // list: | 476 // list: |
460 // - If the implementation requires persisting state for any of the | 477 // - If the implementation requires persisting state for any of the |
461 // combinations in accumulated configuration, change accumulated | 478 // combinations in accumulated configuration, change accumulated |
462 // configuration's persistentState value to "required". | 479 // configuration's persistentState value to "required". |
463 // - Otherwise, change accumulated configuration's persistentState value | 480 // - Otherwise, change accumulated configuration's persistentState value |
464 // to "not-allowed". | 481 // to "not-allowed". |
465 if (accumulated_configuration->persistentState == | 482 if (accumulated_configuration->persistentState == |
466 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { | 483 blink::WebMediaKeySystemConfiguration::Requirement::Optional) { |
467 EmeConfigRule not_allowed_rule = | 484 EmeConfigRule not_allowed_rule = |
468 GetPersistentStateConfigRule(key_system, EME_FEATURE_NOT_ALLOWED); | 485 key_systems.GetPersistentStateConfigRule( |
486 key_system, EME_FEATURE_NOT_ALLOWED); | |
469 EmeConfigRule required_rule = | 487 EmeConfigRule required_rule = |
470 GetPersistentStateConfigRule(key_system, EME_FEATURE_REQUIRED); | 488 key_systems.GetPersistentStateConfigRule( |
489 key_system, EME_FEATURE_REQUIRED); | |
471 // Now that distinctiveIdentifier has been resolved, it is too late to allow | 490 // Now that distinctiveIdentifier has been resolved, it is too late to allow |
472 // persistentState to affect the configuration. | 491 // persistentState to affect the configuration. |
473 bool not_allowed_supported = | 492 bool not_allowed_supported = |
474 config_state.IsRuleSupportedWithCurrentState(not_allowed_rule); | 493 config_state.IsRuleSupportedWithCurrentState(not_allowed_rule); |
475 bool required_supported = | 494 bool required_supported = |
476 config_state.IsRuleSupportedWithCurrentState(required_rule); | 495 config_state.IsRuleSupportedWithCurrentState(required_rule); |
477 if (not_allowed_supported) { | 496 if (not_allowed_supported) { |
478 accumulated_configuration->persistentState = | 497 accumulated_configuration->persistentState = |
479 blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed; | 498 blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed; |
480 } else if (required_supported) { | 499 } else if (required_supported) { |
(...skipping 22 matching lines...) Expand all Loading... | |
503 | 522 |
504 // 12. Return accumulated configuration. | 523 // 12. Return accumulated configuration. |
505 // | 524 // |
506 // We also record the available session types so that createSession() can be | 525 // We also record the available session types so that createSession() can be |
507 // synchronous. | 526 // synchronous. |
508 std::vector<blink::WebEncryptedMediaSessionType> session_types; | 527 std::vector<blink::WebEncryptedMediaSessionType> session_types; |
509 session_types.push_back(blink::WebEncryptedMediaSessionType::Temporary); | 528 session_types.push_back(blink::WebEncryptedMediaSessionType::Temporary); |
510 if (accumulated_configuration->persistentState == | 529 if (accumulated_configuration->persistentState == |
511 blink::WebMediaKeySystemConfiguration::Requirement::Required) { | 530 blink::WebMediaKeySystemConfiguration::Requirement::Required) { |
512 if (config_state.IsRuleSupportedWithCurrentState( | 531 if (config_state.IsRuleSupportedWithCurrentState( |
513 GetPersistentLicenseSessionConfigRule(key_system))) { | 532 key_systems.GetPersistentLicenseSessionConfigRule(key_system))) { |
514 session_types.push_back( | 533 session_types.push_back( |
515 blink::WebEncryptedMediaSessionType::PersistentLicense); | 534 blink::WebEncryptedMediaSessionType::PersistentLicense); |
516 } | 535 } |
517 if (config_state.IsRuleSupportedWithCurrentState( | 536 if (config_state.IsRuleSupportedWithCurrentState( |
518 GetPersistentReleaseMessageSessionConfigRule(key_system))) { | 537 key_systems.GetPersistentReleaseMessageSessionConfigRule( |
538 key_system))) { | |
519 session_types.push_back( | 539 session_types.push_back( |
520 blink::WebEncryptedMediaSessionType::PersistentReleaseMessage); | 540 blink::WebEncryptedMediaSessionType::PersistentReleaseMessage); |
521 } | 541 } |
522 } | 542 } |
523 accumulated_configuration->sessionTypes = session_types; | 543 accumulated_configuration->sessionTypes = session_types; |
524 | 544 |
525 return CONFIGURATION_SUPPORTED; | 545 return CONFIGURATION_SUPPORTED; |
526 } | 546 } |
527 | 547 |
528 // Report usage of key system to UMA. There are 2 different counts logged: | 548 // Report usage of key system to UMA. There are 2 different counts logged: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 KEY_SYSTEM_SUPPORT_STATUS_COUNT + 1, | 589 KEY_SYSTEM_SUPPORT_STATUS_COUNT + 1, |
570 base::Histogram::kUmaTargetedHistogramFlag)->Add(status); | 590 base::Histogram::kUmaTargetedHistogramFlag)->Add(status); |
571 } | 591 } |
572 | 592 |
573 const std::string uma_name_; | 593 const std::string uma_name_; |
574 bool is_request_reported_; | 594 bool is_request_reported_; |
575 bool is_support_reported_; | 595 bool is_support_reported_; |
576 }; | 596 }; |
577 | 597 |
578 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl( | 598 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl( |
599 const KeySystems& key_systems, | |
579 scoped_ptr<CdmFactory> cdm_factory, | 600 scoped_ptr<CdmFactory> cdm_factory, |
580 MediaPermission* media_permission) | 601 MediaPermission* media_permission) |
581 : cdm_factory_(cdm_factory.Pass()), media_permission_(media_permission), | 602 : key_systems_(key_systems), |
603 cdm_factory_(cdm_factory.Pass()), | |
604 media_permission_(media_permission), | |
582 weak_factory_(this) { | 605 weak_factory_(this) { |
583 DCHECK(media_permission); | 606 DCHECK(media_permission); |
584 } | 607 } |
585 | 608 |
586 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { | 609 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { |
587 } | 610 } |
588 | 611 |
589 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( | 612 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( |
590 blink::WebEncryptedMediaRequest request) { | 613 blink::WebEncryptedMediaRequest request) { |
591 // TODO(jrummell): This should be asynchronous, ideally not on the main | 614 // TODO(jrummell): This should be asynchronous, ideally not on the main |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 // 7.3.1. Let candidate configuration be the value. | 655 // 7.3.1. Let candidate configuration be the value. |
633 const blink::WebMediaKeySystemConfiguration& candidate_configuration = | 656 const blink::WebMediaKeySystemConfiguration& candidate_configuration = |
634 configurations[i]; | 657 configurations[i]; |
635 // 7.3.2. Let supported configuration be the result of executing the Get | 658 // 7.3.2. Let supported configuration be the result of executing the Get |
636 // Supported Configuration algorithm on implementation, candidate | 659 // Supported Configuration algorithm on implementation, candidate |
637 // configuration, and origin. | 660 // configuration, and origin. |
638 // 7.3.3. If supported configuration is not null, [initialize and return a | 661 // 7.3.3. If supported configuration is not null, [initialize and return a |
639 // new MediaKeySystemAccess object.] | 662 // new MediaKeySystemAccess object.] |
640 blink::WebMediaKeySystemConfiguration accumulated_configuration; | 663 blink::WebMediaKeySystemConfiguration accumulated_configuration; |
641 ConfigurationSupport supported = GetSupportedConfiguration( | 664 ConfigurationSupport supported = GetSupportedConfiguration( |
642 key_system, candidate_configuration, was_permission_requested, | 665 key_systems_, key_system, candidate_configuration, |
643 is_permission_granted, &accumulated_configuration); | 666 was_permission_requested, is_permission_granted, |
667 &accumulated_configuration); | |
644 switch (supported) { | 668 switch (supported) { |
645 case CONFIGURATION_NOT_SUPPORTED: | 669 case CONFIGURATION_NOT_SUPPORTED: |
646 continue; | 670 continue; |
647 case CONFIGURATION_REQUIRES_PERMISSION: | 671 case CONFIGURATION_REQUIRES_PERMISSION: |
648 if (was_permission_requested) { | 672 if (was_permission_requested) { |
649 DVLOG(2) << "Rejecting requested configuration because " | 673 DVLOG(2) << "Rejecting requested configuration because " |
650 << "permission was denied."; | 674 << "permission was denied."; |
651 continue; | 675 continue; |
652 } | 676 } |
653 media_permission_->RequestPermission( | 677 media_permission_->RequestPermission( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
696 return reporter; | 720 return reporter; |
697 | 721 |
698 // Reporter not found, so create one. | 722 // Reporter not found, so create one. |
699 auto result = | 723 auto result = |
700 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); | 724 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); |
701 DCHECK(result.second); | 725 DCHECK(result.second); |
702 return result.first->second; | 726 return result.first->second; |
703 } | 727 } |
704 | 728 |
705 } // namespace media | 729 } // namespace media |
OLD | NEW |