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

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

Issue 923283002: Implement checks for distinctiveIdentifier and persistentState in requestMediaKeySystemAccess(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected permissions. Created 5 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
« 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 <string> 7 #include <string>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 {"vp9", EME_CODEC_WEBM_VP9}, 67 {"vp9", EME_CODEC_WEBM_VP9},
68 {"vp9.0", EME_CODEC_WEBM_VP9}, 68 {"vp9.0", EME_CODEC_WEBM_VP9},
69 #if defined(USE_PROPRIETARY_CODECS) 69 #if defined(USE_PROPRIETARY_CODECS)
70 {"mp4a", EME_CODEC_MP4_AAC}, 70 {"mp4a", EME_CODEC_MP4_AAC},
71 {"avc1", EME_CODEC_MP4_AVC1}, 71 {"avc1", EME_CODEC_MP4_AVC1},
72 {"avc3", EME_CODEC_MP4_AVC1} 72 {"avc3", EME_CODEC_MP4_AVC1}
73 #endif // defined(USE_PROPRIETARY_CODECS) 73 #endif // defined(USE_PROPRIETARY_CODECS)
74 }; 74 };
75 75
76 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { 76 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
77 KeySystemInfo info(kClearKeyKeySystem); 77 KeySystemInfo info;
78 info.key_system = kClearKeyKeySystem;
78 79
79 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: 80 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec:
80 // http://developer.android.com/guide/appendix/media-formats.html 81 // http://developer.android.com/guide/appendix/media-formats.html
81 // VP9 support is device dependent. 82 // VP9 support is device dependent.
82 83
83 info.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM; 84 info.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM;
84 info.supported_codecs = EME_CODEC_WEBM_ALL; 85 info.supported_codecs = EME_CODEC_WEBM_ALL;
85 86
86 #if defined(OS_ANDROID) 87 #if defined(OS_ANDROID)
87 // Temporarily disable VP9 support for Android. 88 // Temporarily disable VP9 support for Android.
88 // TODO(xhwang): Use mime_util.h to query VP9 support on Android. 89 // TODO(xhwang): Use mime_util.h to query VP9 support on Android.
89 info.supported_codecs &= ~EME_CODEC_WEBM_VP9; 90 info.supported_codecs &= ~EME_CODEC_WEBM_VP9;
90 91
91 // Opus is not supported on Android yet. http://crbug.com/318436. 92 // Opus is not supported on Android yet. http://crbug.com/318436.
92 // TODO(sandersd): Check for platform support to set this bit. 93 // TODO(sandersd): Check for platform support to set this bit.
93 info.supported_codecs &= ~EME_CODEC_WEBM_OPUS; 94 info.supported_codecs &= ~EME_CODEC_WEBM_OPUS;
94 #endif // defined(OS_ANDROID) 95 #endif // defined(OS_ANDROID)
95 96
96 #if defined(USE_PROPRIETARY_CODECS) 97 #if defined(USE_PROPRIETARY_CODECS)
97 info.supported_init_data_types |= EME_INIT_DATA_TYPE_CENC; 98 info.supported_init_data_types |= EME_INIT_DATA_TYPE_CENC;
98 info.supported_codecs |= EME_CODEC_MP4_ALL; 99 info.supported_codecs |= EME_CODEC_MP4_ALL;
99 #endif // defined(USE_PROPRIETARY_CODECS) 100 #endif // defined(USE_PROPRIETARY_CODECS)
100 101
102 info.persistent_license_support = EME_SESSION_TYPE_NOT_SUPPORTED;
103 info.persistent_release_message_support = EME_SESSION_TYPE_NOT_SUPPORTED;
104 info.persistent_state_support = EME_FEATURE_NOT_SUPPORTED;
105 info.distinctive_identifier_support = EME_FEATURE_NOT_SUPPORTED;
106
101 info.use_aes_decryptor = true; 107 info.use_aes_decryptor = true;
102 108
103 concrete_key_systems->push_back(info); 109 concrete_key_systems->push_back(info);
104 } 110 }
105 111
106 class KeySystems { 112 class KeySystems {
107 public: 113 public:
108 static KeySystems& GetInstance(); 114 static KeySystems& GetInstance();
109 115
110 void UpdateIfNeeded(); 116 void UpdateIfNeeded();
(...skipping 13 matching lines...) Expand all
124 bool is_prefixed); 130 bool is_prefixed);
125 131
126 std::string GetKeySystemNameForUMA(const std::string& key_system) const; 132 std::string GetKeySystemNameForUMA(const std::string& key_system) const;
127 133
128 bool UseAesDecryptor(const std::string& concrete_key_system); 134 bool UseAesDecryptor(const std::string& concrete_key_system);
129 135
130 #if defined(ENABLE_PEPPER_CDMS) 136 #if defined(ENABLE_PEPPER_CDMS)
131 std::string GetPepperType(const std::string& concrete_key_system); 137 std::string GetPepperType(const std::string& concrete_key_system);
132 #endif 138 #endif
133 139
140 bool IsPersistentLicenseSessionSupported(
141 const std::string& key_system,
142 bool is_permission_granted);
143
144 bool IsPersistentReleaseMessageSessionSupported(
145 const std::string& key_system,
146 bool is_permission_granted);
147
148 bool IsPersistentStateRequirementSupported(
149 const std::string& key_system,
150 EmeFeatureRequirement requirement,
151 bool is_permission_granted);
152
153 bool IsDistinctiveIdentifierRequirementSupported(
154 const std::string& key_system,
155 EmeFeatureRequirement requirement,
156 bool is_permission_granted);
157
134 void AddContainerMask(const std::string& container, uint32 mask); 158 void AddContainerMask(const std::string& container, uint32 mask);
135 void AddCodecMask(const std::string& codec, uint32 mask); 159 void AddCodecMask(const std::string& codec, uint32 mask);
136 160
137 private: 161 private:
138 void InitializeUMAInfo(); 162 void InitializeUMAInfo();
139 163
140 void UpdateSupportedKeySystems(); 164 void UpdateSupportedKeySystems();
141 165
142 void AddConcreteSupportedKeySystems( 166 void AddConcreteSupportedKeySystems(
143 const std::vector<KeySystemInfo>& concrete_key_systems); 167 const std::vector<KeySystemInfo>& concrete_key_systems);
144 168
145 void AddConcreteSupportedKeySystem(
146 const std::string& key_system,
147 bool use_aes_decryptor,
148 #if defined(ENABLE_PEPPER_CDMS)
149 const std::string& pepper_type,
150 #endif
151 SupportedInitDataTypes supported_init_data_types,
152 SupportedCodecs supported_codecs,
153 const std::string& parent_key_system);
154
155 friend struct base::DefaultLazyInstanceTraits<KeySystems>; 169 friend struct base::DefaultLazyInstanceTraits<KeySystems>;
156 170
157 struct KeySystemProperties { 171 typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap;
158 KeySystemProperties()
159 : use_aes_decryptor(false), supported_codecs(EME_CODEC_NONE) {}
160
161 bool use_aes_decryptor;
162 #if defined(ENABLE_PEPPER_CDMS)
163 std::string pepper_type;
164 #endif
165 SupportedInitDataTypes supported_init_data_types;
166 SupportedCodecs supported_codecs;
167 };
168
169 typedef base::hash_map<std::string, KeySystemProperties>
170 KeySystemPropertiesMap;
171 typedef base::hash_map<std::string, std::string> ParentKeySystemMap; 172 typedef base::hash_map<std::string, std::string> ParentKeySystemMap;
172 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; 173 typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap;
173 typedef base::hash_map<std::string, EmeCodec> CodecsMap; 174 typedef base::hash_map<std::string, EmeCodec> CodecsMap;
174 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap; 175 typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap;
175 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap; 176 typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap;
176 177
177 KeySystems(); 178 KeySystems();
178 ~KeySystems() {} 179 ~KeySystems() {}
179 180
180 EmeInitDataType GetInitDataTypeForName( 181 EmeInitDataType GetInitDataTypeForName(
(...skipping 14 matching lines...) Expand all
195 SupportedCodecs key_system_supported_codecs) const; 196 SupportedCodecs key_system_supported_codecs) const;
196 197
197 // Returns true if all |codecs| are supported in |container| by checking 198 // Returns true if all |codecs| are supported in |container| by checking
198 // |key_system_supported_codecs|. 199 // |key_system_supported_codecs|.
199 bool IsSupportedContainerAndCodecs( 200 bool IsSupportedContainerAndCodecs(
200 const std::string& container, 201 const std::string& container,
201 const std::vector<std::string>& codecs, 202 const std::vector<std::string>& codecs,
202 SupportedCodecs key_system_supported_codecs) const; 203 SupportedCodecs key_system_supported_codecs) const;
203 204
204 // Map from key system string to capabilities. 205 // Map from key system string to capabilities.
205 KeySystemPropertiesMap concrete_key_system_map_; 206 KeySystemInfoMap concrete_key_system_map_;
206 207
207 // Map from parent key system to the concrete key system that should be used 208 // Map from parent key system to the concrete key system that should be used
208 // to represent its capabilities. 209 // to represent its capabilities.
209 ParentKeySystemMap parent_key_system_map_; 210 ParentKeySystemMap parent_key_system_map_;
210 211
211 KeySystemsSupportUMA key_systems_support_uma_; 212 KeySystemsSupportUMA key_systems_support_uma_;
212 213
213 InitDataTypesMap init_data_type_name_map_; 214 InitDataTypesMap init_data_type_name_map_;
214 ContainerCodecsMap container_to_codec_mask_map_; 215 ContainerCodecsMap container_to_codec_mask_map_;
215 CodecsMap codec_string_map_; 216 CodecsMap codec_string_map_;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 331
331 AddConcreteSupportedKeySystems(key_systems_info); 332 AddConcreteSupportedKeySystems(key_systems_info);
332 } 333 }
333 334
334 void KeySystems::AddConcreteSupportedKeySystems( 335 void KeySystems::AddConcreteSupportedKeySystems(
335 const std::vector<KeySystemInfo>& concrete_key_systems) { 336 const std::vector<KeySystemInfo>& concrete_key_systems) {
336 DCHECK(thread_checker_.CalledOnValidThread()); 337 DCHECK(thread_checker_.CalledOnValidThread());
337 DCHECK(concrete_key_system_map_.empty()); 338 DCHECK(concrete_key_system_map_.empty());
338 DCHECK(parent_key_system_map_.empty()); 339 DCHECK(parent_key_system_map_.empty());
339 340
340 for (size_t i = 0; i < concrete_key_systems.size(); ++i) { 341 for (const KeySystemInfo& info : concrete_key_systems) {
341 const KeySystemInfo& key_system_info = concrete_key_systems[i]; 342 DCHECK(!info.key_system.empty());
342 AddConcreteSupportedKeySystem(key_system_info.key_system, 343 DCHECK_NE(info.persistent_license_support, EME_SESSION_TYPE_INVALID);
343 key_system_info.use_aes_decryptor, 344 DCHECK_NE(info.persistent_release_message_support,
345 EME_SESSION_TYPE_INVALID);
346 DCHECK_NE(info.persistent_state_support, EME_FEATURE_INVALID);
ddorwin 2015/02/20 01:39:49 We need the same checks for persistent state as we
sandersd (OOO until July 31) 2015/02/20 01:46:26 Done.
347 DCHECK_NE(info.distinctive_identifier_support, EME_FEATURE_INVALID);
348 // Never use REQUESTABLE for distinctive identifiers, use
349 // REQUESTABLE_WITH_PERMISSION instead.
350 DCHECK_NE(info.distinctive_identifier_support,
351 EME_FEATURE_REQUESTABLE) << "Use REQUESTABLE_WITH_PERMISSION";
352 // But actually for now we only support NOT_SUPPORTED or ALWAYS_ENABLED,
ddorwin 2015/02/20 01:39:49 With all the complexity, a whitelist instead of a
sandersd (OOO until July 31) 2015/02/20 01:46:26 Done.
353 // since there are no CDMs that implement REQUESTABLE_WITH_PERMISSION
354 // correctly. http://crbug.com/457482
355 DCHECK_NE(info.distinctive_identifier_support,
356 EME_FEATURE_REQUESTABLE_WITH_PERMISSION);
357 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) {
358 DCHECK_EQ(info.persistent_license_support,
359 EME_SESSION_TYPE_NOT_SUPPORTED);
360 DCHECK_EQ(info.persistent_release_message_support,
361 EME_SESSION_TYPE_NOT_SUPPORTED);
362 }
363 DCHECK(!IsSupportedKeySystem(info.key_system))
364 << "Key system '" << info.key_system << "' already registered";
365 DCHECK(!parent_key_system_map_.count(info.key_system))
366 << "'" << info.key_system << "' is already registered as a parent";
344 #if defined(ENABLE_PEPPER_CDMS) 367 #if defined(ENABLE_PEPPER_CDMS)
345 key_system_info.pepper_type, 368 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty());
346 #endif 369 #endif
347 key_system_info.supported_init_data_types, 370
348 key_system_info.supported_codecs, 371 concrete_key_system_map_[info.key_system] = info;
349 key_system_info.parent_key_system); 372
373 if (!info.parent_key_system.empty()) {
374 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system))
375 << "Parent '" << info.parent_key_system << "' "
376 << "already registered concrete";
377 DCHECK(!parent_key_system_map_.count(info.parent_key_system))
378 << "Parent '" << info.parent_key_system << "' already registered";
379 parent_key_system_map_[info.parent_key_system] = info.key_system;
380 }
350 } 381 }
351 } 382 }
352 383
353 void KeySystems::AddConcreteSupportedKeySystem(
354 const std::string& concrete_key_system,
355 bool use_aes_decryptor,
356 #if defined(ENABLE_PEPPER_CDMS)
357 const std::string& pepper_type,
358 #endif
359 SupportedInitDataTypes supported_init_data_types,
360 SupportedCodecs supported_codecs,
361 const std::string& parent_key_system) {
362 DCHECK(thread_checker_.CalledOnValidThread());
363 DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system))
364 << "Key system '" << concrete_key_system << "' already registered";
365 DCHECK(!parent_key_system_map_.count(concrete_key_system))
366 << "'" << concrete_key_system << " is already registered as a parent";
367
368 KeySystemProperties properties;
369 properties.use_aes_decryptor = use_aes_decryptor;
370 #if defined(ENABLE_PEPPER_CDMS)
371 DCHECK_EQ(use_aes_decryptor, pepper_type.empty());
372 properties.pepper_type = pepper_type;
373 #endif
374
375 properties.supported_init_data_types = supported_init_data_types;
376 properties.supported_codecs = supported_codecs;
377
378 concrete_key_system_map_[concrete_key_system] = properties;
379
380 if (!parent_key_system.empty()) {
381 DCHECK(!IsConcreteSupportedKeySystem(parent_key_system))
382 << "Parent '" << parent_key_system << "' already registered concrete";
383 DCHECK(!parent_key_system_map_.count(parent_key_system))
384 << "Parent '" << parent_key_system << "' already registered";
385 parent_key_system_map_[parent_key_system] = concrete_key_system;
386 }
387 }
388
389 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { 384 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) {
390 DCHECK(thread_checker_.CalledOnValidThread()); 385 DCHECK(thread_checker_.CalledOnValidThread());
391 return concrete_key_system_map_.count(key_system) != 0; 386 return concrete_key_system_map_.count(key_system) != 0;
392 } 387 }
393 388
394 bool KeySystems::IsSupportedContainer( 389 bool KeySystems::IsSupportedContainer(
395 const std::string& container, 390 const std::string& container,
396 SupportedCodecs key_system_supported_codecs) const { 391 SupportedCodecs key_system_supported_codecs) const {
397 DCHECK(thread_checker_.CalledOnValidThread()); 392 DCHECK(thread_checker_.CalledOnValidThread());
398 DCHECK(!container.empty()); 393 DCHECK(!container.empty());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // Unprefixed EME only supports concrete key systems. 444 // Unprefixed EME only supports concrete key systems.
450 return concrete_key_system_map_.count(key_system) != 0; 445 return concrete_key_system_map_.count(key_system) != 0;
451 } 446 }
452 447
453 bool KeySystems::IsSupportedKeySystemWithInitDataType( 448 bool KeySystems::IsSupportedKeySystemWithInitDataType(
454 const std::string& key_system, 449 const std::string& key_system,
455 const std::string& init_data_type) { 450 const std::string& init_data_type) {
456 DCHECK(thread_checker_.CalledOnValidThread()); 451 DCHECK(thread_checker_.CalledOnValidThread());
457 452
458 // Locate |key_system|. Only concrete key systems are supported in unprefixed. 453 // Locate |key_system|. Only concrete key systems are supported in unprefixed.
459 KeySystemPropertiesMap::const_iterator key_system_iter = 454 KeySystemInfoMap::const_iterator key_system_iter =
460 concrete_key_system_map_.find(key_system); 455 concrete_key_system_map_.find(key_system);
461 if (key_system_iter == concrete_key_system_map_.end()) 456 if (key_system_iter == concrete_key_system_map_.end())
462 return false; 457 return false;
463 458
464 // Check |init_data_type| and |key_system| x |init_data_type|. 459 // Check |init_data_type| and |key_system| x |init_data_type|.
465 const KeySystemProperties& properties = key_system_iter->second; 460 const KeySystemInfo& info = key_system_iter->second;
466 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); 461 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type);
467 return (properties.supported_init_data_types & eme_init_data_type) != 0; 462 return (info.supported_init_data_types & eme_init_data_type) != 0;
468 } 463 }
469 464
470 // TODO(sandersd): Reorganize to be more similar to 465 // TODO(sandersd): Reorganize to be more similar to
471 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be 466 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be
472 // required; http://crbug.com/417461. 467 // required; http://crbug.com/417461.
473 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( 468 bool KeySystems::IsSupportedKeySystemWithMediaMimeType(
474 const std::string& mime_type, 469 const std::string& mime_type,
475 const std::vector<std::string>& codecs, 470 const std::vector<std::string>& codecs,
476 const std::string& key_system, 471 const std::string& key_system,
477 bool is_prefixed) { 472 bool is_prefixed) {
478 DCHECK(thread_checker_.CalledOnValidThread()); 473 DCHECK(thread_checker_.CalledOnValidThread());
479 const bool report_to_uma = is_prefixed; 474 const bool report_to_uma = is_prefixed;
480 475
481 // If |is_prefixed| and |key_system| is a parent key system, use its concrete 476 // If |is_prefixed| and |key_system| is a parent key system, use its concrete
482 // child. 477 // child.
483 const std::string& concrete_key_system = is_prefixed ? 478 const std::string& concrete_key_system = is_prefixed ?
484 PrefixedGetConcreteKeySystemNameFor(key_system) : 479 PrefixedGetConcreteKeySystemNameFor(key_system) :
485 key_system; 480 key_system;
486 481
487 bool has_type = !mime_type.empty(); 482 bool has_type = !mime_type.empty();
488 483
489 if (report_to_uma) 484 if (report_to_uma)
490 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); 485 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type);
491 486
492 // Check key system support. 487 // Check key system support.
493 KeySystemPropertiesMap::const_iterator key_system_iter = 488 KeySystemInfoMap::const_iterator key_system_iter =
494 concrete_key_system_map_.find(concrete_key_system); 489 concrete_key_system_map_.find(concrete_key_system);
495 if (key_system_iter == concrete_key_system_map_.end()) 490 if (key_system_iter == concrete_key_system_map_.end())
496 return false; 491 return false;
497 492
498 if (report_to_uma) 493 if (report_to_uma)
499 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); 494 key_systems_support_uma_.ReportKeySystemSupport(key_system, false);
500 495
501 if (!has_type) { 496 if (!has_type) {
502 DCHECK(codecs.empty()); 497 DCHECK(codecs.empty());
503 return true; 498 return true;
(...skipping 24 matching lines...) Expand all
528 key_system_name_for_uma_map_.find(key_system); 523 key_system_name_for_uma_map_.find(key_system);
529 if (iter == key_system_name_for_uma_map_.end()) 524 if (iter == key_system_name_for_uma_map_.end())
530 return kUnknownKeySystemNameForUMA; 525 return kUnknownKeySystemNameForUMA;
531 526
532 return iter->second; 527 return iter->second;
533 } 528 }
534 529
535 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { 530 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) {
536 DCHECK(thread_checker_.CalledOnValidThread()); 531 DCHECK(thread_checker_.CalledOnValidThread());
537 532
538 KeySystemPropertiesMap::const_iterator key_system_iter = 533 KeySystemInfoMap::const_iterator key_system_iter =
539 concrete_key_system_map_.find(concrete_key_system); 534 concrete_key_system_map_.find(concrete_key_system);
540 if (key_system_iter == concrete_key_system_map_.end()) { 535 if (key_system_iter == concrete_key_system_map_.end()) {
541 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 536 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
542 return false; 537 return false;
543 } 538 }
544 539
545 return key_system_iter->second.use_aes_decryptor; 540 return key_system_iter->second.use_aes_decryptor;
546 } 541 }
547 542
548 #if defined(ENABLE_PEPPER_CDMS) 543 #if defined(ENABLE_PEPPER_CDMS)
549 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { 544 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) {
550 DCHECK(thread_checker_.CalledOnValidThread()); 545 DCHECK(thread_checker_.CalledOnValidThread());
551 546
552 KeySystemPropertiesMap::const_iterator key_system_iter = 547 KeySystemInfoMap::const_iterator key_system_iter =
553 concrete_key_system_map_.find(concrete_key_system); 548 concrete_key_system_map_.find(concrete_key_system);
554 if (key_system_iter == concrete_key_system_map_.end()) { 549 if (key_system_iter == concrete_key_system_map_.end()) {
555 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 550 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
556 return std::string(); 551 return std::string();
557 } 552 }
558 553
559 const std::string& type = key_system_iter->second.pepper_type; 554 const std::string& type = key_system_iter->second.pepper_type;
560 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; 555 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based";
561 return type; 556 return type;
562 } 557 }
563 #endif 558 #endif
564 559
560 bool KeySystems::IsPersistentLicenseSessionSupported(
561 const std::string& key_system,
562 bool is_permission_granted) {
563 DCHECK(thread_checker_.CalledOnValidThread());
564
565 KeySystemInfoMap::const_iterator key_system_iter =
566 concrete_key_system_map_.find(key_system);
567 if (key_system_iter == concrete_key_system_map_.end()) {
568 NOTREACHED();
569 return false;
570 }
571
572 switch (key_system_iter->second.persistent_license_support) {
573 case EME_SESSION_TYPE_INVALID:
574 NOTREACHED();
575 return false;
576 case EME_SESSION_TYPE_NOT_SUPPORTED:
577 return false;
578 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION:
579 return is_permission_granted;
580 case EME_SESSION_TYPE_SUPPORTED:
581 return true;
582 }
583
584 NOTREACHED();
585 return false;
586 }
587
588 bool KeySystems::IsPersistentReleaseMessageSessionSupported(
589 const std::string& key_system,
590 bool is_permission_granted) {
591 DCHECK(thread_checker_.CalledOnValidThread());
592
593 KeySystemInfoMap::const_iterator key_system_iter =
594 concrete_key_system_map_.find(key_system);
595 if (key_system_iter == concrete_key_system_map_.end()) {
596 NOTREACHED();
597 return false;
598 }
599
600 switch (key_system_iter->second.persistent_release_message_support) {
601 case EME_SESSION_TYPE_INVALID:
602 NOTREACHED();
603 return false;
604 case EME_SESSION_TYPE_NOT_SUPPORTED:
605 return false;
606 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION:
607 return is_permission_granted;
608 case EME_SESSION_TYPE_SUPPORTED:
609 return true;
610 }
611
612 NOTREACHED();
613 return false;
614 }
615
616 bool KeySystems::IsPersistentStateRequirementSupported(
617 const std::string& key_system,
618 EmeFeatureRequirement requirement,
619 bool is_permission_granted) {
620 DCHECK(thread_checker_.CalledOnValidThread());
621
622 KeySystemInfoMap::const_iterator key_system_iter =
623 concrete_key_system_map_.find(key_system);
624 if (key_system_iter == concrete_key_system_map_.end()) {
625 NOTREACHED();
626 return false;
627 }
628
629 switch (key_system_iter->second.persistent_state_support) {
630 case EME_FEATURE_INVALID:
631 NOTREACHED();
632 return false;
633 case EME_FEATURE_NOT_SUPPORTED:
634 return requirement != EME_FEATURE_REQUIRED;
635 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION:
636 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted;
637 case EME_FEATURE_REQUESTABLE:
638 return true;
639 case EME_FEATURE_ALWAYS_ENABLED:
640 // Persistent state does not require user permission, but the session
641 // types thet use it might.
642 return requirement != EME_FEATURE_NOT_ALLOWED;
643 }
644
645 NOTREACHED();
646 return false;
647 }
648
649 bool KeySystems::IsDistinctiveIdentifierRequirementSupported(
650 const std::string& key_system,
651 EmeFeatureRequirement requirement,
652 bool is_permission_granted) {
653 DCHECK(thread_checker_.CalledOnValidThread());
654
655 KeySystemInfoMap::const_iterator key_system_iter =
656 concrete_key_system_map_.find(key_system);
657 if (key_system_iter == concrete_key_system_map_.end()) {
658 NOTREACHED();
659 return false;
660 }
661
662 switch (key_system_iter->second.distinctive_identifier_support) {
663 case EME_FEATURE_INVALID:
664 NOTREACHED();
665 return false;
666 case EME_FEATURE_NOT_SUPPORTED:
667 return requirement != EME_FEATURE_REQUIRED;
668 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION:
669 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted;
670 case EME_FEATURE_REQUESTABLE:
671 NOTREACHED();
672 return true;
673 case EME_FEATURE_ALWAYS_ENABLED:
674 // Distinctive identifiers always require user permission.
675 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted;
676 }
677
678 NOTREACHED();
679 return false;
680 }
681
565 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { 682 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) {
566 DCHECK(thread_checker_.CalledOnValidThread()); 683 DCHECK(thread_checker_.CalledOnValidThread());
567 DCHECK(!container_to_codec_mask_map_.count(container)); 684 DCHECK(!container_to_codec_mask_map_.count(container));
568 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); 685 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask);
569 } 686 }
570 687
571 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { 688 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) {
572 DCHECK(thread_checker_.CalledOnValidThread()); 689 DCHECK(thread_checker_.CalledOnValidThread());
573 DCHECK(!codec_string_map_.count(codec)); 690 DCHECK(!codec_string_map_.count(codec));
574 codec_string_map_[codec] = static_cast<EmeCodec>(mask); 691 codec_string_map_[codec] = static_cast<EmeCodec>(mask);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 bool CanUseAesDecryptor(const std::string& concrete_key_system) { 762 bool CanUseAesDecryptor(const std::string& concrete_key_system) {
646 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); 763 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system);
647 } 764 }
648 765
649 #if defined(ENABLE_PEPPER_CDMS) 766 #if defined(ENABLE_PEPPER_CDMS)
650 std::string GetPepperType(const std::string& concrete_key_system) { 767 std::string GetPepperType(const std::string& concrete_key_system) {
651 return KeySystems::GetInstance().GetPepperType(concrete_key_system); 768 return KeySystems::GetInstance().GetPepperType(concrete_key_system);
652 } 769 }
653 #endif 770 #endif
654 771
772 bool IsPersistentLicenseSessionSupported(
773 const std::string& key_system,
774 bool is_permission_granted) {
775 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported(
776 key_system, is_permission_granted);
777 }
778
779 bool IsPersistentReleaseMessageSessionSupported(
780 const std::string& key_system,
781 bool is_permission_granted) {
782 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported(
783 key_system, is_permission_granted);
784 }
785
786 bool IsPersistentStateRequirementSupported(
787 const std::string& key_system,
788 EmeFeatureRequirement requirement,
789 bool is_permission_granted) {
790 return KeySystems::GetInstance().IsPersistentStateRequirementSupported(
791 key_system, requirement, is_permission_granted);
792 }
793
794 bool IsDistinctiveIdentifierRequirementSupported(
795 const std::string& key_system,
796 EmeFeatureRequirement requirement,
797 bool is_permission_granted) {
798 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported(
799 key_system, requirement, is_permission_granted);
800 }
801
655 // These two functions are for testing purpose only. The declaration in the 802 // These two functions are for testing purpose only. The declaration in the
656 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used 803 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used
657 // by tests but not non-test code. However, this .cc file is compiled as part of 804 // by tests but not non-test code. However, this .cc file is compiled as part of
658 // "media" where "UNIT_TEST" is not defined. So we need to specify 805 // "media" where "UNIT_TEST" is not defined. So we need to specify
659 // "MEDIA_EXPORT" here again so that they are visible to tests. 806 // "MEDIA_EXPORT" here again so that they are visible to tests.
660 807
661 MEDIA_EXPORT void AddContainerMask(const std::string& container, 808 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) {
662 uint32 mask) {
663 KeySystems::GetInstance().AddContainerMask(container, mask); 809 KeySystems::GetInstance().AddContainerMask(container, mask);
664 } 810 }
665 811
666 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { 812 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) {
667 KeySystems::GetInstance().AddCodecMask(codec, mask); 813 KeySystems::GetInstance().AddCodecMask(codec, mask);
668 } 814 }
669 815
670 } // namespace media 816 } // 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