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

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: changes 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
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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 816
804 void KeySystemConfigSelector::OnPermissionResult( 817 void KeySystemConfigSelector::OnPermissionResult(
805 scoped_ptr<SelectionRequest> request, 818 scoped_ptr<SelectionRequest> request,
806 bool is_permission_granted) { 819 bool is_permission_granted) {
807 request->was_permission_requested = true; 820 request->was_permission_requested = true;
808 request->is_permission_granted = is_permission_granted; 821 request->is_permission_granted = is_permission_granted;
809 SelectConfigInternal(std::move(request)); 822 SelectConfigInternal(std::move(request));
810 } 823 }
811 824
812 } // namespace media 825 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698