Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: media/blink/key_system_config_selector.cc

Issue 1911953003: EME: Correctly handle container-only contentType strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-requestmediakeysystemaccess.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 304
305 // 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
306 // parameters can be rejected. http://crbug.com/417561 306 // parameters can be rejected. http://crbug.com/417561
307 bool KeySystemConfigSelector::IsSupportedContentType( 307 bool KeySystemConfigSelector::IsSupportedContentType(
308 const std::string& key_system, 308 const std::string& key_system,
309 EmeMediaType media_type, 309 EmeMediaType media_type,
310 const std::string& container_mime_type, 310 const std::string& container_mime_type,
311 const std::string& codecs, 311 const std::string& codecs,
312 KeySystemConfigSelector::ConfigState* config_state) { 312 KeySystemConfigSelector::ConfigState* config_state) {
313 // From RFC6838: "Both top-level type and subtype names are case-insensitive."
314 std::string container_lower = base::ToLowerASCII(container_mime_type);
315
316 // contentTypes must provide a codec string unless the container implies a
317 // particular codec. For EME, none of the currently supported containers
318 // imply a codec, so |codecs| must be provided.
319 if (codecs.empty()) {
320 // Since the spec didn't initially require this, add an exemption for
321 // some existing containers to give clients time to adapt.
322 // TODO(jrummell): Remove this exemption once the number of contentTypes
323 // without codecs drops low enough (UMA added in the blink code).
324 // http://crbug.com/605661.
325 if (container_lower != "audio/webm" && container_lower != "video/webm" &&
326 container_lower != "audio/mp4" && container_lower != "video/mp4") {
327 return false;
328 }
329 }
330
313 // Check that |container_mime_type| and |codecs| are supported by Chrome. This 331 // Check that |container_mime_type| and |codecs| are supported by Chrome. This
314 // is done primarily to validate extended codecs, but it also ensures that the 332 // is done primarily to validate extended codecs, but it also ensures that the
315 // CDM cannot support codecs that Chrome does not (which could complicate the 333 // CDM cannot support codecs that Chrome does not (which could complicate the
316 // robustness algorithm). 334 // robustness algorithm).
317 if (!IsSupportedMediaFormat(container_mime_type, codecs, 335 if (!IsSupportedMediaFormat(container_lower, codecs,
318 CanUseAesDecryptor(key_system))) { 336 CanUseAesDecryptor(key_system))) {
319 return false; 337 return false;
320 } 338 }
321 339
322 // TODO(servolk): Converting |container_mime_type| to lower-case could be
323 // moved to KeySystemsImpl::GetContentTypeConfigRule, plus we could add some
324 // upper-case container name test cases in media/base/key_systems_unittest.cc.
325 std::string container_lower = base::ToLowerASCII(container_mime_type);
326
327 // Check that |container_mime_type| and |codecs| are supported by the CDM. 340 // Check that |container_mime_type| and |codecs| are supported by the CDM.
328 // This check does not handle extended codecs, so extended codec information 341 // This check does not handle extended codecs, so extended codec information
329 // is stripped (extended codec information was checked above). 342 // is stripped (extended codec information was checked above).
330 std::vector<std::string> stripped_codec_vector; 343 std::vector<std::string> stripped_codec_vector;
331 ParseCodecString(codecs, &stripped_codec_vector, true); 344 ParseCodecString(codecs, &stripped_codec_vector, true);
332 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( 345 EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule(
333 key_system, media_type, container_lower, stripped_codec_vector); 346 key_system, media_type, container_lower, stripped_codec_vector);
334 if (!config_state->IsRuleSupported(codecs_rule)) 347 if (!config_state->IsRuleSupported(codecs_rule))
335 return false; 348 return false;
336 config_state->AddRule(codecs_rule); 349 config_state->AddRule(codecs_rule);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // configuration. 580 // configuration.
568 // 10.2. If video capabilities is null, return null. 581 // 10.2. If video capabilities is null, return null.
569 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities; 582 std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities;
570 if (!GetSupportedCapabilities(key_system, EmeMediaType::VIDEO, 583 if (!GetSupportedCapabilities(key_system, EmeMediaType::VIDEO,
571 candidate.videoCapabilities, config_state, 584 candidate.videoCapabilities, config_state,
572 &video_capabilities)) { 585 &video_capabilities)) {
573 return CONFIGURATION_NOT_SUPPORTED; 586 return CONFIGURATION_NOT_SUPPORTED;
574 } 587 }
575 588
576 // 10.3. Add video capabilities to accumulated configuration. 589 // 10.3. Add video capabilities to accumulated configuration.
590 accumulated_configuration->hasVideoCapabilities = true;
577 accumulated_configuration->videoCapabilities = video_capabilities; 591 accumulated_configuration->videoCapabilities = video_capabilities;
578 } 592 }
579 593
580 // 11. If the audioCapabilities member is present in candidate configuration: 594 // 11. If the audioCapabilities member is present in candidate configuration:
581 if (candidate.hasAudioCapabilities) { 595 if (candidate.hasAudioCapabilities) {
582 // 11.1. Let audio capabilities be the result of executing the Get Supported 596 // 11.1. Let audio capabilities be the result of executing the Get Supported
583 // Capabilities for Media Type algorithm on Audio, candidate 597 // Capabilities for Media Type algorithm on Audio, candidate
584 // configuration's audioCapabilities member, and accumulated 598 // configuration's audioCapabilities member, and accumulated
585 // configuration. 599 // configuration.
586 // 11.2. If audio capabilities is null, return null. 600 // 11.2. If audio capabilities is null, return null.
587 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities; 601 std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities;
588 if (!GetSupportedCapabilities(key_system, EmeMediaType::AUDIO, 602 if (!GetSupportedCapabilities(key_system, EmeMediaType::AUDIO,
589 candidate.audioCapabilities, config_state, 603 candidate.audioCapabilities, config_state,
590 &audio_capabilities)) { 604 &audio_capabilities)) {
591 return CONFIGURATION_NOT_SUPPORTED; 605 return CONFIGURATION_NOT_SUPPORTED;
592 } 606 }
593 607
594 // 11.3. Add audio capabilities to accumulated configuration. 608 // 11.3. Add audio capabilities to accumulated configuration.
609 accumulated_configuration->hasAudioCapabilities = true;
595 accumulated_configuration->audioCapabilities = audio_capabilities; 610 accumulated_configuration->audioCapabilities = audio_capabilities;
596 } 611 }
597 612
598 // 12. If accumulated configuration's distinctiveIdentifier value is 613 // 12. If accumulated configuration's distinctiveIdentifier value is
599 // "optional", follow the steps for the first matching condition from the 614 // "optional", follow the steps for the first matching condition from the
600 // following list: 615 // following list:
601 // - If the implementation requires a Distinctive Identifier for any of 616 // - If the implementation requires a Distinctive Identifier for any of
602 // the combinations in accumulated configuration, change accumulated 617 // the combinations in accumulated configuration, change accumulated
603 // configuration's distinctiveIdentifier value to "required". 618 // configuration's distinctiveIdentifier value to "required".
604 // - Otherwise, change accumulated configuration's distinctiveIdentifier 619 // - Otherwise, change accumulated configuration's distinctiveIdentifier
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 818
804 void KeySystemConfigSelector::OnPermissionResult( 819 void KeySystemConfigSelector::OnPermissionResult(
805 std::unique_ptr<SelectionRequest> request, 820 std::unique_ptr<SelectionRequest> request,
806 bool is_permission_granted) { 821 bool is_permission_granted) {
807 request->was_permission_requested = true; 822 request->was_permission_requested = true;
808 request->is_permission_granted = is_permission_granted; 823 request->is_permission_granted = is_permission_granted;
809 SelectConfigInternal(std::move(request)); 824 SelectConfigInternal(std::move(request));
810 } 825 }
811 826
812 } // namespace media 827 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-requestmediakeysystemaccess.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698