Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/key_systems.h" | 5 #include "media/base/key_systems.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "media/base/key_system_names.h" | 19 #include "media/base/key_system_names.h" |
| 20 #include "media/base/key_system_properties.h" | 20 #include "media/base/key_system_properties.h" |
| 21 #include "media/base/media.h" | 21 #include "media/base/media.h" |
| 22 #include "media/base/media_switches.h" | |
| 22 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
| 23 #include "media/base/media_client.h" | 24 #include "media/base/media_client.h" |
| 24 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 25 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
| 25 | 26 |
| 26 namespace media { | 27 namespace media { |
| 27 | 28 |
| 28 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 29 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 29 | 30 |
| 30 // These names are used by UMA. Do not change them! | 31 // These names are used by UMA. Do not change them! |
| 31 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; | 32 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 // If distinctive identifiers are not supported, then no other features can | 393 // If distinctive identifiers are not supported, then no other features can |
| 393 // require them. | 394 // require them. |
| 394 if (properties->GetDistinctiveIdentifierSupport() == | 395 if (properties->GetDistinctiveIdentifierSupport() == |
| 395 EmeFeatureSupport::NOT_SUPPORTED) { | 396 EmeFeatureSupport::NOT_SUPPORTED) { |
| 396 DCHECK(properties->GetPersistentLicenseSessionSupport() != | 397 DCHECK(properties->GetPersistentLicenseSessionSupport() != |
| 397 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER); | 398 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER); |
| 398 DCHECK(properties->GetPersistentReleaseMessageSessionSupport() != | 399 DCHECK(properties->GetPersistentReleaseMessageSessionSupport() != |
| 399 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER); | 400 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER); |
| 400 } | 401 } |
| 401 | 402 |
| 402 // Distinctive identifiers and persistent state can only be reliably blocked | 403 // Distinctive identifiers and persistent state can only be reliably blocked |
|
ddorwin
2016/11/10 01:24:29
I wonder if we should move this to a CanBlock() he
xhwang
2016/11/10 07:11:28
Good point. I like it. Done.
| |
| 403 // (and therefore be safely configurable) for Pepper-hosted key systems. For | 404 // (and therefore be safely configurable) for Pepper-hosted key systems. For |
| 404 // other platforms assume the CDM can and will do anything, except for the | 405 // other platforms assume the CDM can and will do anything, except for the |
| 405 // following two cases: | 406 // following two cases: |
| 406 // 1) AES decryptor, and | 407 // 1) AES decryptor, and |
| 407 // 2) External Clear Key key system on Android, only enabled for testing. | 408 // 2) External Clear Key key system when MojoCdm is used, only enabled for |
| 409 // testing. | |
| 408 bool can_block = properties->UseAesDecryptor(); | 410 bool can_block = properties->UseAesDecryptor(); |
| 409 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 411 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 410 DCHECK_EQ(properties->UseAesDecryptor(), | 412 DCHECK_EQ(properties->UseAesDecryptor(), |
| 411 properties->GetPepperType().empty()); | 413 properties->GetPepperType().empty()); |
| 412 if (!properties->GetPepperType().empty()) | 414 if (!properties->GetPepperType().empty()) |
| 413 can_block = true; | 415 can_block = true; |
| 414 #elif defined(OS_ANDROID) | 416 #endif |
| 415 if (IsExternalClearKey(properties->GetKeySystemName())) | 417 if (base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting) && |
|
ddorwin
2016/10/28 19:03:47
Does this work with ENABLE_PEPPER_CDMS? Do we expe
xhwang
2016/11/03 07:14:44
In browser_tests we do set kExternalClearKeyForTes
ddorwin
2016/11/10 01:24:29
The code is inconsistent with the comment, which s
xhwang
2016/11/10 07:11:28
Done.
| |
| 418 IsExternalClearKey(properties->GetKeySystemName())) | |
| 416 can_block = true; | 419 can_block = true; |
| 417 #endif | 420 |
| 418 if (!can_block) { | 421 if (!can_block) { |
| 419 DCHECK(properties->GetDistinctiveIdentifierSupport() == | 422 DCHECK(properties->GetDistinctiveIdentifierSupport() == |
| 420 EmeFeatureSupport::ALWAYS_ENABLED); | 423 EmeFeatureSupport::ALWAYS_ENABLED); |
| 421 DCHECK(properties->GetPersistentStateSupport() == | 424 DCHECK(properties->GetPersistentStateSupport() == |
| 422 EmeFeatureSupport::ALWAYS_ENABLED); | 425 EmeFeatureSupport::ALWAYS_ENABLED); |
| 423 } | 426 } |
| 424 | 427 |
| 425 DCHECK_EQ(key_system_properties_map_.count(properties->GetKeySystemName()), | 428 DCHECK_EQ(key_system_properties_map_.count(properties->GetKeySystemName()), |
| 426 0u) | 429 0u) |
| 427 << "Key system '" << properties->GetKeySystemName() | 430 << "Key system '" << properties->GetKeySystemName() |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 uint32_t mask) { | 726 uint32_t mask) { |
| 724 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); | 727 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); |
| 725 } | 728 } |
| 726 | 729 |
| 727 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, | 730 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, |
| 728 uint32_t mask) { | 731 uint32_t mask) { |
| 729 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); | 732 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); |
| 730 } | 733 } |
| 731 | 734 |
| 732 } // namespace media | 735 } // namespace media |
| OLD | NEW |