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

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

Issue 2686133002: EME: Require codecs parameter for audio/videoCapabilities (Closed)
Patch Set: Created 3 years, 10 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 const std::string& codecs, 299 const std::string& codecs,
300 bool use_aes_decryptor) { 300 bool use_aes_decryptor) {
301 std::vector<std::string> codec_vector; 301 std::vector<std::string> codec_vector;
302 ParseCodecString(codecs, &codec_vector, false); 302 ParseCodecString(codecs, &codec_vector, false);
303 // AesDecryptor decrypts the stream in the demuxer before it reaches the 303 // AesDecryptor decrypts the stream in the demuxer before it reaches the
304 // decoder so check whether the media format is supported when clear. 304 // decoder so check whether the media format is supported when clear.
305 SupportsType support_result = 305 SupportsType support_result =
306 use_aes_decryptor 306 use_aes_decryptor
307 ? IsSupportedMediaFormat(container_mime_type, codec_vector) 307 ? IsSupportedMediaFormat(container_mime_type, codec_vector)
308 : IsSupportedEncryptedMediaFormat(container_mime_type, codec_vector); 308 : IsSupportedEncryptedMediaFormat(container_mime_type, codec_vector);
309 switch (support_result) { 309 return (support_result == IsSupported);
310 case IsSupported:
311 return true;
312 case MayBeSupported:
313 // If no codecs were specified, the best possible result is
314 // MayBeSupported, indicating support for the container.
315 return codec_vector.empty();
316 case IsNotSupported:
317 return false;
318 }
319 NOTREACHED();
320 return false;
321 } 310 }
322 311
323 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid 312 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid
324 // parameters can be rejected. http://crbug.com/417561 313 // parameters can be rejected. http://crbug.com/417561
xhwang 2017/02/09 20:07:55 The link is wrong. Does this TODO still make sens
jrummell 2017/02/09 23:36:08 Updated link(s). The debate continues on what to d
325 bool KeySystemConfigSelector::IsSupportedContentType( 314 bool KeySystemConfigSelector::IsSupportedContentType(
326 const std::string& key_system, 315 const std::string& key_system,
327 EmeMediaType media_type, 316 EmeMediaType media_type,
328 const std::string& container_mime_type, 317 const std::string& container_mime_type,
329 const std::string& codecs, 318 const std::string& codecs,
330 KeySystemConfigSelector::ConfigState* config_state) { 319 KeySystemConfigSelector::ConfigState* config_state) {
331 // From RFC6838: "Both top-level type and subtype names are case-insensitive." 320 // From RFC6838: "Both top-level type and subtype names are case-insensitive."
332 std::string container_lower = base::ToLowerASCII(container_mime_type); 321 std::string container_lower = base::ToLowerASCII(container_mime_type);
333 322
334 // contentTypes must provide a codec string unless the container implies a 323 // contentTypes must provide a codec string unless the container implies a
335 // particular codec. For EME, none of the currently supported containers 324 // particular codec. For EME, none of the currently supported containers
336 // imply a codec, so |codecs| must be provided. 325 // imply a codec, so |codecs| must be provided.
337 if (codecs.empty()) { 326 if (codecs.empty())
338 // Since the spec didn't initially require this, add an exemption for 327 return false;
339 // some existing containers to give clients time to adapt.
340 // TODO(jrummell): Remove this exemption once the number of contentTypes
341 // without codecs drops low enough (UMA added in the blink code).
342 // http://crbug.com/605661.
343 if (container_lower != "audio/webm" && container_lower != "video/webm" &&
344 container_lower != "audio/mp4" && container_lower != "video/mp4") {
345 return false;
346 }
347 }
348 328
349 // Check that |container_mime_type| and |codecs| are supported by Chrome. This 329 // Check that |container_mime_type| and |codecs| are supported by Chrome. This
350 // is done primarily to validate extended codecs, but it also ensures that the 330 // is done primarily to validate extended codecs, but it also ensures that the
351 // CDM cannot support codecs that Chrome does not (which could complicate the 331 // CDM cannot support codecs that Chrome does not (which could complicate the
352 // robustness algorithm). 332 // robustness algorithm).
353 if (!IsSupportedMediaFormat(container_lower, codecs, 333 if (!IsSupportedMediaFormat(container_lower, codecs,
354 CanUseAesDecryptor(key_system))) { 334 CanUseAesDecryptor(key_system))) {
355 return false; 335 return false;
356 } 336 }
357 337
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 928
949 void KeySystemConfigSelector::OnPermissionResult( 929 void KeySystemConfigSelector::OnPermissionResult(
950 std::unique_ptr<SelectionRequest> request, 930 std::unique_ptr<SelectionRequest> request,
951 bool is_permission_granted) { 931 bool is_permission_granted) {
952 request->was_permission_requested = true; 932 request->was_permission_requested = true;
953 request->is_permission_granted = is_permission_granted; 933 request->is_permission_granted = is_permission_granted;
954 SelectConfigInternal(std::move(request)); 934 SelectConfigInternal(std::move(request));
955 } 935 }
956 936
957 } // namespace media 937 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/key_system_config_selector_unittest.cc » ('j') | media/blink/key_system_config_selector_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698