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

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

Issue 1747073003: EME on Android: Improve accuracy of Key System availability. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 : key_systems_(key_systems), 270 : key_systems_(key_systems),
271 media_permission_(media_permission), 271 media_permission_(media_permission),
272 weak_factory_(this) { 272 weak_factory_(this) {
273 DCHECK(key_systems_); 273 DCHECK(key_systems_);
274 DCHECK(media_permission_); 274 DCHECK(media_permission_);
275 } 275 }
276 276
277 KeySystemConfigSelector::~KeySystemConfigSelector() { 277 KeySystemConfigSelector::~KeySystemConfigSelector() {
278 } 278 }
279 279
280 bool IsSupportedClearMediaFormat(const std::string& container_mime_type, 280 bool IsSupportedMediaFormat(const std::string& container_mime_type,
281 const std::string& codecs) { 281 const std::string& codecs,
282 bool use_aes_decryptor) {
282 std::vector<std::string> codec_vector; 283 std::vector<std::string> codec_vector;
283 media::ParseCodecString(codecs, &codec_vector, false); 284 media::ParseCodecString(codecs, &codec_vector, false);
285 // AesDecryptor decrypts the stream in the demuxer before it reaches the
286 // decoder so check whether the media format is supported when clear.
284 media::SupportsType support_result = 287 media::SupportsType support_result =
285 media::IsSupportedEncryptedMediaFormat(container_mime_type, codec_vector); 288 use_aes_decryptor
289 ? media::IsSupportedMediaFormat(container_mime_type, codec_vector)
290 : media::IsSupportedEncryptedMediaFormat(container_mime_type,
291 codec_vector);
xhwang 2016/03/02 06:57:08 drop media:: here and everywhere else since we are
ddorwin 2016/03/02 21:11:53 Done.
286 switch (support_result) { 292 switch (support_result) {
287 case media::IsSupported: 293 case media::IsSupported:
288 return true; 294 return true;
289 case media::MayBeSupported: 295 case media::MayBeSupported:
290 // If no codecs were specified, the best possible result is 296 // If no codecs were specified, the best possible result is
291 // MayBeSupported, indicating support for the container. 297 // MayBeSupported, indicating support for the container.
292 return codec_vector.empty(); 298 return codec_vector.empty();
293 case media::IsNotSupported: 299 case media::IsNotSupported:
294 return false; 300 return false;
295 } 301 }
296 NOTREACHED(); 302 NOTREACHED();
297 return false; 303 return false;
298 } 304 }
299 305
300 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid 306 // TODO(sandersd): Move contentType parsing from Blink to here so that invalid
301 // parameters can be rejected. http://crbug.com/417561 307 // parameters can be rejected. http://crbug.com/417561
302 bool KeySystemConfigSelector::IsSupportedContentType( 308 bool KeySystemConfigSelector::IsSupportedContentType(
303 const std::string& key_system, 309 const std::string& key_system,
304 EmeMediaType media_type, 310 EmeMediaType media_type,
305 const std::string& container_mime_type, 311 const std::string& container_mime_type,
306 const std::string& codecs, 312 const std::string& codecs,
307 KeySystemConfigSelector::ConfigState* config_state) { 313 KeySystemConfigSelector::ConfigState* config_state) {
308 // Check that |container_mime_type| and |codecs| are supported by Chrome. This 314 // Check that |container_mime_type| and |codecs| are supported by Chrome. This
309 // is done primarily to validate extended codecs, but it also ensures that the 315 // is done primarily to validate extended codecs, but it also ensures that the
310 // CDM cannot support codecs that Chrome does not (which could complicate the 316 // CDM cannot support codecs that Chrome does not (which could complicate the
311 // robustness algorithm). 317 // robustness algorithm).
312 if (!IsSupportedClearMediaFormat(container_mime_type, codecs)) 318 if (!IsSupportedMediaFormat(container_mime_type, codecs,
319 CanUseAesDecryptor(key_system))) {
313 return false; 320 return false;
321 }
314 322
315 // TODO(servolk): Converting |container_mime_type| to lower-case could be 323 // TODO(servolk): Converting |container_mime_type| to lower-case could be
316 // moved to KeySystemsImpl::GetContentTypeConfigRule, plus we could add some 324 // moved to KeySystemsImpl::GetContentTypeConfigRule, plus we could add some
317 // upper-case container name test cases in media/base/key_systems_unittest.cc. 325 // upper-case container name test cases in media/base/key_systems_unittest.cc.
318 std::string container_lower = base::ToLowerASCII(container_mime_type); 326 std::string container_lower = base::ToLowerASCII(container_mime_type);
319 327
320 // Check that |container_mime_type| and |codecs| are supported by the CDM. 328 // Check that |container_mime_type| and |codecs| are supported by the CDM.
321 // This check does not handle extended codecs, so extended codec information 329 // This check does not handle extended codecs, so extended codec information
322 // is stripped (extended codec information was checked above). 330 // is stripped (extended codec information was checked above).
323 std::vector<std::string> stripped_codec_vector; 331 std::vector<std::string> stripped_codec_vector;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 804
797 void KeySystemConfigSelector::OnPermissionResult( 805 void KeySystemConfigSelector::OnPermissionResult(
798 scoped_ptr<SelectionRequest> request, 806 scoped_ptr<SelectionRequest> request,
799 bool is_permission_granted) { 807 bool is_permission_granted) {
800 request->was_permission_requested = true; 808 request->was_permission_requested = true;
801 request->is_permission_granted = is_permission_granted; 809 request->is_permission_granted = is_permission_granted;
802 SelectConfigInternal(std::move(request)); 810 SelectConfigInternal(std::move(request));
803 } 811 }
804 812
805 } // namespace media 813 } // namespace media
OLDNEW
« media/base/android/media_drm_bridge.cc ('K') | « media/base/mime_util_internal.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698