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

Side by Side Diff: media/base/key_systems.cc

Issue 2412493003: Revert of Move ENABLE_PEPPER_CDMS to a buildflag header. (Closed)
Patch Set: Created 4 years, 2 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 | « media/base/key_systems.h ('k') | media/base/key_systems_unittest.cc » ('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 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 "ppapi/features/features.h"
23 #include "media/base/media_client.h" 22 #include "media/base/media_client.h"
24 #include "third_party/widevine/cdm/widevine_cdm_common.h" 23 #include "third_party/widevine/cdm/widevine_cdm_common.h"
25 24
26 namespace media { 25 namespace media {
27 26
28 const char kClearKeyKeySystem[] = "org.w3.clearkey"; 27 const char kClearKeyKeySystem[] = "org.w3.clearkey";
29 28
30 // These names are used by UMA. Do not change them! 29 // These names are used by UMA. Do not change them!
31 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; 30 const char kClearKeyKeySystemNameForUMA[] = "ClearKey";
32 const char kUnknownKeySystemNameForUMA[] = "Unknown"; 31 const char kUnknownKeySystemNameForUMA[] = "Unknown";
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 class KeySystemsImpl : public KeySystems { 166 class KeySystemsImpl : public KeySystems {
168 public: 167 public:
169 static KeySystemsImpl* GetInstance(); 168 static KeySystemsImpl* GetInstance();
170 169
171 void UpdateIfNeeded(); 170 void UpdateIfNeeded();
172 171
173 std::string GetKeySystemNameForUMA(const std::string& key_system) const; 172 std::string GetKeySystemNameForUMA(const std::string& key_system) const;
174 173
175 bool UseAesDecryptor(const std::string& key_system) const; 174 bool UseAesDecryptor(const std::string& key_system) const;
176 175
177 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 176 #if defined(ENABLE_PEPPER_CDMS)
178 std::string GetPepperType(const std::string& key_system) const; 177 std::string GetPepperType(const std::string& key_system) const;
179 #endif 178 #endif
180 179
181 // These two functions are for testing purpose only. 180 // These two functions are for testing purpose only.
182 void AddCodecMask(EmeMediaType media_type, 181 void AddCodecMask(EmeMediaType media_type,
183 const std::string& codec, 182 const std::string& codec,
184 uint32_t mask); 183 uint32_t mask);
185 void AddMimeTypeCodecMask(const std::string& mime_type, uint32_t mask); 184 void AddMimeTypeCodecMask(const std::string& mime_type, uint32_t mask);
186 185
187 // Implementation of KeySystems interface. 186 // Implementation of KeySystems interface.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER); 398 EmeSessionTypeSupport::SUPPORTED_WITH_IDENTIFIER);
400 } 399 }
401 400
402 // Distinctive identifiers and persistent state can only be reliably blocked 401 // Distinctive identifiers and persistent state can only be reliably blocked
403 // (and therefore be safely configurable) for Pepper-hosted key systems. For 402 // (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 403 // other platforms assume the CDM can and will do anything, except for the
405 // following two cases: 404 // following two cases:
406 // 1) AES decryptor, and 405 // 1) AES decryptor, and
407 // 2) External Clear Key key system on Android, only enabled for testing. 406 // 2) External Clear Key key system on Android, only enabled for testing.
408 bool can_block = properties->UseAesDecryptor(); 407 bool can_block = properties->UseAesDecryptor();
409 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 408 #if defined(ENABLE_PEPPER_CDMS)
410 DCHECK_EQ(properties->UseAesDecryptor(), 409 DCHECK_EQ(properties->UseAesDecryptor(),
411 properties->GetPepperType().empty()); 410 properties->GetPepperType().empty());
412 if (!properties->GetPepperType().empty()) 411 if (!properties->GetPepperType().empty())
413 can_block = true; 412 can_block = true;
414 #elif defined(OS_ANDROID) 413 #elif defined(OS_ANDROID)
415 if (IsExternalClearKey(properties->GetKeySystemName())) 414 if (IsExternalClearKey(properties->GetKeySystemName()))
416 can_block = true; 415 can_block = true;
417 #endif 416 #endif
418 if (!can_block) { 417 if (!can_block) {
419 DCHECK(properties->GetDistinctiveIdentifierSupport() == 418 DCHECK(properties->GetDistinctiveIdentifierSupport() ==
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 499
501 KeySystemPropertiesMap::const_iterator key_system_iter = 500 KeySystemPropertiesMap::const_iterator key_system_iter =
502 key_system_properties_map_.find(key_system); 501 key_system_properties_map_.find(key_system);
503 if (key_system_iter == key_system_properties_map_.end()) { 502 if (key_system_iter == key_system_properties_map_.end()) {
504 DLOG(ERROR) << key_system << " is not a known system"; 503 DLOG(ERROR) << key_system << " is not a known system";
505 return false; 504 return false;
506 } 505 }
507 return key_system_iter->second->UseAesDecryptor(); 506 return key_system_iter->second->UseAesDecryptor();
508 } 507 }
509 508
510 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 509 #if defined(ENABLE_PEPPER_CDMS)
511 std::string KeySystemsImpl::GetPepperType(const std::string& key_system) const { 510 std::string KeySystemsImpl::GetPepperType(const std::string& key_system) const {
512 DCHECK(thread_checker_.CalledOnValidThread()); 511 DCHECK(thread_checker_.CalledOnValidThread());
513 512
514 KeySystemPropertiesMap::const_iterator key_system_iter = 513 KeySystemPropertiesMap::const_iterator key_system_iter =
515 key_system_properties_map_.find(key_system); 514 key_system_properties_map_.find(key_system);
516 if (key_system_iter == key_system_properties_map_.end()) { 515 if (key_system_iter == key_system_properties_map_.end()) {
517 DLOG(FATAL) << key_system << " is not a known system"; 516 DLOG(FATAL) << key_system << " is not a known system";
518 return std::string(); 517 return std::string();
519 } 518 }
520 const std::string& type = key_system_iter->second->GetPepperType(); 519 const std::string& type = key_system_iter->second->GetPepperType();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 698 }
700 699
701 std::string GetKeySystemNameForUMA(const std::string& key_system) { 700 std::string GetKeySystemNameForUMA(const std::string& key_system) {
702 return KeySystemsImpl::GetInstance()->GetKeySystemNameForUMA(key_system); 701 return KeySystemsImpl::GetInstance()->GetKeySystemNameForUMA(key_system);
703 } 702 }
704 703
705 bool CanUseAesDecryptor(const std::string& key_system) { 704 bool CanUseAesDecryptor(const std::string& key_system) {
706 return KeySystemsImpl::GetInstance()->UseAesDecryptor(key_system); 705 return KeySystemsImpl::GetInstance()->UseAesDecryptor(key_system);
707 } 706 }
708 707
709 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 708 #if defined(ENABLE_PEPPER_CDMS)
710 std::string GetPepperType(const std::string& key_system) { 709 std::string GetPepperType(const std::string& key_system) {
711 return KeySystemsImpl::GetInstance()->GetPepperType(key_system); 710 return KeySystemsImpl::GetInstance()->GetPepperType(key_system);
712 } 711 }
713 #endif 712 #endif
714 713
715 // These two functions are for testing purpose only. The declaration in the 714 // These two functions are for testing purpose only. The declaration in the
716 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used 715 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used
717 // by tests but not non-test code. However, this .cc file is compiled as part of 716 // by tests but not non-test code. However, this .cc file is compiled as part of
718 // "media" where "UNIT_TEST" is not defined. So we need to specify 717 // "media" where "UNIT_TEST" is not defined. So we need to specify
719 // "MEDIA_EXPORT" here again so that they are visible to tests. 718 // "MEDIA_EXPORT" here again so that they are visible to tests.
720 719
721 MEDIA_EXPORT void AddCodecMask(EmeMediaType media_type, 720 MEDIA_EXPORT void AddCodecMask(EmeMediaType media_type,
722 const std::string& codec, 721 const std::string& codec,
723 uint32_t mask) { 722 uint32_t mask) {
724 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); 723 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask);
725 } 724 }
726 725
727 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, 726 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type,
728 uint32_t mask) { 727 uint32_t mask) {
729 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); 728 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask);
730 } 729 }
731 730
732 } // namespace media 731 } // namespace media
OLDNEW
« no previous file with comments | « media/base/key_systems.h ('k') | media/base/key_systems_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698