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

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: Cast Widevine config 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
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 IsPersistentLicenseSupported(
ddorwin 2015/02/19 01:41:34 ditto from the .h file.
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
141 const std::string& key_system,
142 bool permission_granted);
143
144 bool IsPersistentReleaseMessageSupported(
145 const std::string& key_system,
146 bool permission_granted);
147
148 bool IsPersistentStateSupported(
149 const std::string& key_system,
150 EmeFeatureRequirement requirement,
151 bool permission_granted);
152
153 bool IsDistinctiveIdentifierSupported(
154 const std::string& key_system,
155 EmeFeatureRequirement requirement,
156 bool 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,
343 key_system_info.use_aes_decryptor, 344 EME_SESSION_TYPE_SUPPORT_NOT_DECLARED);
345 DCHECK_NE(info.persistent_release_message_support,
346 EME_SESSION_TYPE_SUPPORT_NOT_DECLARED);
347 DCHECK_NE(info.persistent_state_support,
348 EME_FEATURE_SUPPORT_NOT_DECLARED);
349 DCHECK_NE(info.distinctive_identifier_support,
350 EME_FEATURE_SUPPORT_NOT_DECLARED);
351 DCHECK_NE(info.distinctive_identifier_support,
352 EME_FEATURE_SUPPORTED);
ddorwin 2015/02/19 01:41:33 also != EME_FEATURE_ALWAYS_AVAILABLE. That would n
sandersd (OOO until July 31) 2015/02/19 21:08:34 I've just added a comment for now.
353 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) {
354 DCHECK_EQ(info.persistent_license_support,
355 EME_SESSION_TYPE_NOT_SUPPORTED);
356 DCHECK_EQ(info.persistent_release_message_support,
357 EME_SESSION_TYPE_NOT_SUPPORTED);
358 }
359 DCHECK(!IsConcreteSupportedKeySystem(info.key_system))
ddorwin 2015/02/19 01:41:34 IsSupportedKeySystem
sandersd (OOO until July 31) 2015/02/19 21:08:34 Why do we have both? They are identical.
ddorwin 2015/02/19 23:03:57 Once prefixed is removed, "concrete" won't be a th
sandersd (OOO until July 31) 2015/02/20 00:17:12 Acknowledged.
360 << "Key system '" << info.key_system << "' already registered";
361 DCHECK(!parent_key_system_map_.count(info.key_system))
362 << "'" << info.key_system << "' is already registered as a parent";
344 #if defined(ENABLE_PEPPER_CDMS) 363 #if defined(ENABLE_PEPPER_CDMS)
345 key_system_info.pepper_type, 364 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty());
346 #endif 365 #endif
347 key_system_info.supported_init_data_types, 366
348 key_system_info.supported_codecs, 367 concrete_key_system_map_[info.key_system] = info;
349 key_system_info.parent_key_system); 368
369 if (!info.parent_key_system.empty()) {
370 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system))
371 << "Parent '" << info.parent_key_system << "' "
372 << "already registered concrete";
373 DCHECK(!parent_key_system_map_.count(info.parent_key_system))
374 << "Parent '" << info.parent_key_system << "' already registered";
375 parent_key_system_map_[info.parent_key_system] = info.key_system;
376 }
350 } 377 }
351 } 378 }
352 379
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) { 380 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) {
390 DCHECK(thread_checker_.CalledOnValidThread()); 381 DCHECK(thread_checker_.CalledOnValidThread());
391 return concrete_key_system_map_.count(key_system) != 0; 382 return concrete_key_system_map_.count(key_system) != 0;
392 } 383 }
393 384
394 bool KeySystems::IsSupportedContainer( 385 bool KeySystems::IsSupportedContainer(
395 const std::string& container, 386 const std::string& container,
396 SupportedCodecs key_system_supported_codecs) const { 387 SupportedCodecs key_system_supported_codecs) const {
397 DCHECK(thread_checker_.CalledOnValidThread()); 388 DCHECK(thread_checker_.CalledOnValidThread());
398 DCHECK(!container.empty()); 389 DCHECK(!container.empty());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // Unprefixed EME only supports concrete key systems. 440 // Unprefixed EME only supports concrete key systems.
450 return concrete_key_system_map_.count(key_system) != 0; 441 return concrete_key_system_map_.count(key_system) != 0;
451 } 442 }
452 443
453 bool KeySystems::IsSupportedKeySystemWithInitDataType( 444 bool KeySystems::IsSupportedKeySystemWithInitDataType(
454 const std::string& key_system, 445 const std::string& key_system,
455 const std::string& init_data_type) { 446 const std::string& init_data_type) {
456 DCHECK(thread_checker_.CalledOnValidThread()); 447 DCHECK(thread_checker_.CalledOnValidThread());
457 448
458 // Locate |key_system|. Only concrete key systems are supported in unprefixed. 449 // Locate |key_system|. Only concrete key systems are supported in unprefixed.
459 KeySystemPropertiesMap::const_iterator key_system_iter = 450 KeySystemInfoMap::const_iterator key_system_iter =
460 concrete_key_system_map_.find(key_system); 451 concrete_key_system_map_.find(key_system);
461 if (key_system_iter == concrete_key_system_map_.end()) 452 if (key_system_iter == concrete_key_system_map_.end())
462 return false; 453 return false;
463 454
464 // Check |init_data_type| and |key_system| x |init_data_type|. 455 // Check |init_data_type| and |key_system| x |init_data_type|.
465 const KeySystemProperties& properties = key_system_iter->second; 456 const KeySystemInfo& info = key_system_iter->second;
466 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); 457 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type);
467 return (properties.supported_init_data_types & eme_init_data_type) != 0; 458 return (info.supported_init_data_types & eme_init_data_type) != 0;
468 } 459 }
469 460
470 // TODO(sandersd): Reorganize to be more similar to 461 // TODO(sandersd): Reorganize to be more similar to
471 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be 462 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be
472 // required; http://crbug.com/417461. 463 // required; http://crbug.com/417461.
473 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( 464 bool KeySystems::IsSupportedKeySystemWithMediaMimeType(
474 const std::string& mime_type, 465 const std::string& mime_type,
475 const std::vector<std::string>& codecs, 466 const std::vector<std::string>& codecs,
476 const std::string& key_system, 467 const std::string& key_system,
477 bool is_prefixed) { 468 bool is_prefixed) {
478 DCHECK(thread_checker_.CalledOnValidThread()); 469 DCHECK(thread_checker_.CalledOnValidThread());
479 const bool report_to_uma = is_prefixed; 470 const bool report_to_uma = is_prefixed;
480 471
481 // If |is_prefixed| and |key_system| is a parent key system, use its concrete 472 // If |is_prefixed| and |key_system| is a parent key system, use its concrete
482 // child. 473 // child.
483 const std::string& concrete_key_system = is_prefixed ? 474 const std::string& concrete_key_system = is_prefixed ?
484 PrefixedGetConcreteKeySystemNameFor(key_system) : 475 PrefixedGetConcreteKeySystemNameFor(key_system) :
485 key_system; 476 key_system;
486 477
487 bool has_type = !mime_type.empty(); 478 bool has_type = !mime_type.empty();
488 479
489 if (report_to_uma) 480 if (report_to_uma)
490 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); 481 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type);
491 482
492 // Check key system support. 483 // Check key system support.
493 KeySystemPropertiesMap::const_iterator key_system_iter = 484 KeySystemInfoMap::const_iterator key_system_iter =
494 concrete_key_system_map_.find(concrete_key_system); 485 concrete_key_system_map_.find(concrete_key_system);
495 if (key_system_iter == concrete_key_system_map_.end()) 486 if (key_system_iter == concrete_key_system_map_.end())
496 return false; 487 return false;
497 488
498 if (report_to_uma) 489 if (report_to_uma)
499 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); 490 key_systems_support_uma_.ReportKeySystemSupport(key_system, false);
500 491
501 if (!has_type) { 492 if (!has_type) {
502 DCHECK(codecs.empty()); 493 DCHECK(codecs.empty());
503 return true; 494 return true;
(...skipping 24 matching lines...) Expand all
528 key_system_name_for_uma_map_.find(key_system); 519 key_system_name_for_uma_map_.find(key_system);
529 if (iter == key_system_name_for_uma_map_.end()) 520 if (iter == key_system_name_for_uma_map_.end())
530 return kUnknownKeySystemNameForUMA; 521 return kUnknownKeySystemNameForUMA;
531 522
532 return iter->second; 523 return iter->second;
533 } 524 }
534 525
535 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { 526 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) {
536 DCHECK(thread_checker_.CalledOnValidThread()); 527 DCHECK(thread_checker_.CalledOnValidThread());
537 528
538 KeySystemPropertiesMap::const_iterator key_system_iter = 529 KeySystemInfoMap::const_iterator key_system_iter =
539 concrete_key_system_map_.find(concrete_key_system); 530 concrete_key_system_map_.find(concrete_key_system);
540 if (key_system_iter == concrete_key_system_map_.end()) { 531 if (key_system_iter == concrete_key_system_map_.end()) {
541 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 532 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
542 return false; 533 return false;
543 } 534 }
544 535
545 return key_system_iter->second.use_aes_decryptor; 536 return key_system_iter->second.use_aes_decryptor;
546 } 537 }
547 538
548 #if defined(ENABLE_PEPPER_CDMS) 539 #if defined(ENABLE_PEPPER_CDMS)
549 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { 540 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) {
550 DCHECK(thread_checker_.CalledOnValidThread()); 541 DCHECK(thread_checker_.CalledOnValidThread());
551 542
552 KeySystemPropertiesMap::const_iterator key_system_iter = 543 KeySystemInfoMap::const_iterator key_system_iter =
553 concrete_key_system_map_.find(concrete_key_system); 544 concrete_key_system_map_.find(concrete_key_system);
554 if (key_system_iter == concrete_key_system_map_.end()) { 545 if (key_system_iter == concrete_key_system_map_.end()) {
555 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; 546 DLOG(FATAL) << concrete_key_system << " is not a known concrete system";
556 return std::string(); 547 return std::string();
557 } 548 }
558 549
559 const std::string& type = key_system_iter->second.pepper_type; 550 const std::string& type = key_system_iter->second.pepper_type;
560 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; 551 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based";
561 return type; 552 return type;
562 } 553 }
563 #endif 554 #endif
564 555
556 bool KeySystems::IsPersistentLicenseSupported(
557 const std::string& key_system,
558 bool permission_granted) {
559 DCHECK(thread_checker_.CalledOnValidThread());
560
561 KeySystemInfoMap::const_iterator key_system_iter =
562 concrete_key_system_map_.find(key_system);
563 if (key_system_iter == concrete_key_system_map_.end())
ddorwin 2015/02/19 01:41:33 Should this be a DCHECK instead? Should these be c
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
564 return false;
565 EmeSessionTypeSupport support =
566 key_system_iter->second.persistent_license_support;
567
568 EmeSessionTypeSupport requirement =
569 permission_granted ? EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION
570 : EME_SESSION_TYPE_SUPPORTED;
571 return support >= requirement;
ddorwin 2015/02/19 01:41:33 It's not obvious from the enum definitions that th
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
572 }
573
574 bool KeySystems::IsPersistentReleaseMessageSupported(
575 const std::string& key_system,
576 bool permission_granted) {
577 DCHECK(thread_checker_.CalledOnValidThread());
578
579 KeySystemInfoMap::const_iterator key_system_iter =
580 concrete_key_system_map_.find(key_system);
581 if (key_system_iter == concrete_key_system_map_.end())
582 return false;
583 EmeSessionTypeSupport support =
584 key_system_iter->second.persistent_release_message_support;
585
586 EmeSessionTypeSupport permission_requirement =
587 permission_granted ? EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION
588 : EME_SESSION_TYPE_SUPPORTED;
589 return support >= permission_requirement;
590 }
591
592 bool KeySystems::IsPersistentStateSupported(
593 const std::string& key_system,
594 EmeFeatureRequirement requirement,
595 bool permission_granted) {
596 DCHECK(thread_checker_.CalledOnValidThread());
597
598 KeySystemInfoMap::const_iterator key_system_iter =
599 concrete_key_system_map_.find(key_system);
600 if (key_system_iter == concrete_key_system_map_.end())
601 return false;
602 EmeFeatureSupport support = key_system_iter->second.persistent_state_support;
603
604 EmeFeatureSupport permission_requirement =
ddorwin 2015/02/19 04:23:41 This should only be in the specific case at line 6
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
605 permission_granted ? EME_FEATURE_SUPPORTED_WITH_PERMISSION
606 : EME_FEATURE_SUPPORTED;
607
608 switch (requirement) {
609 case EME_FEATURE_NOT_ALLOWED:
610 return support < EME_FEATURE_ALWAYS_AVAILABLE;
ddorwin 2015/02/19 01:41:34 USED makes more sense here (see earlier comment)
ddorwin 2015/02/19 04:23:41 This logic is only valid if we can enforce that CD
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
611 case EME_FEATURE_OPTIONAL:
612 return true;
613 case EME_FEATURE_REQUIRED:
614 return support >= permission_requirement;
ddorwin 2015/02/19 04:23:41 ditto with line 571, though this case would end up
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
615 }
616
617 NOTREACHED();
618 return false;
619 }
620
621 bool KeySystems::IsDistinctiveIdentifierSupported(
622 const std::string& key_system,
623 EmeFeatureRequirement requirement,
624 bool permission_granted) {
625 DCHECK(thread_checker_.CalledOnValidThread());
626
627 KeySystemInfoMap::const_iterator key_system_iter =
628 concrete_key_system_map_.find(key_system);
629 if (key_system_iter == concrete_key_system_map_.end())
630 return false;
631 EmeFeatureSupport support =
632 key_system_iter->second.distinctive_identifier_support;
633
634 EmeFeatureSupport permission_requirement =
635 permission_granted ? EME_FEATURE_SUPPORTED_WITH_PERMISSION
ddorwin 2015/02/19 04:23:41 See below.
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
636 : EME_FEATURE_SUPPORTED;
637
638 switch (requirement) {
639 case EME_FEATURE_NOT_ALLOWED:
640 return support < EME_FEATURE_ALWAYS_AVAILABLE;
ddorwin 2015/02/19 04:23:41 ditto with line 610 (and especially important here
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
641 case EME_FEATURE_OPTIONAL:
642 return true;
643 case EME_FEATURE_REQUIRED:
644 return support >= permission_requirement;
ddorwin 2015/02/19 04:23:42 Per the comment at line 352, some of the values ar
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
645 }
646
647 NOTREACHED();
648 return false;
649 }
650
565 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { 651 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) {
566 DCHECK(thread_checker_.CalledOnValidThread()); 652 DCHECK(thread_checker_.CalledOnValidThread());
567 DCHECK(!container_to_codec_mask_map_.count(container)); 653 DCHECK(!container_to_codec_mask_map_.count(container));
568 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); 654 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask);
569 } 655 }
570 656
571 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { 657 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) {
572 DCHECK(thread_checker_.CalledOnValidThread()); 658 DCHECK(thread_checker_.CalledOnValidThread());
573 DCHECK(!codec_string_map_.count(codec)); 659 DCHECK(!codec_string_map_.count(codec));
574 codec_string_map_[codec] = static_cast<EmeCodec>(mask); 660 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) { 731 bool CanUseAesDecryptor(const std::string& concrete_key_system) {
646 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); 732 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system);
647 } 733 }
648 734
649 #if defined(ENABLE_PEPPER_CDMS) 735 #if defined(ENABLE_PEPPER_CDMS)
650 std::string GetPepperType(const std::string& concrete_key_system) { 736 std::string GetPepperType(const std::string& concrete_key_system) {
651 return KeySystems::GetInstance().GetPepperType(concrete_key_system); 737 return KeySystems::GetInstance().GetPepperType(concrete_key_system);
652 } 738 }
653 #endif 739 #endif
654 740
741 bool IsPersistentLicenseSupported(
742 const std::string& key_system,
743 bool permission_granted) {
744 return KeySystems::GetInstance().IsPersistentLicenseSupported(
745 key_system, permission_granted);
746 }
747
748 bool IsPersistentReleaseMessageSupported(
749 const std::string& key_system,
750 bool permission_granted) {
751 return KeySystems::GetInstance().IsPersistentReleaseMessageSupported(
752 key_system, permission_granted);
753 }
754
755 bool IsPersistentStateSupported(
756 const std::string& key_system,
757 EmeFeatureRequirement requirement,
758 bool permission_granted) {
759 return KeySystems::GetInstance().IsPersistentStateSupported(
760 key_system, requirement, permission_granted);
761 }
762
763 bool IsDistinctiveIdentifierSupported(
764 const std::string& key_system,
765 EmeFeatureRequirement requirement,
766 bool permission_granted) {
767 return KeySystems::GetInstance().IsDistinctiveIdentifierSupported(
768 key_system, requirement, permission_granted);
769 }
770
655 // These two functions are for testing purpose only. The declaration in the 771 // 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 772 // 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 773 // 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 774 // "media" where "UNIT_TEST" is not defined. So we need to specify
659 // "MEDIA_EXPORT" here again so that they are visible to tests. 775 // "MEDIA_EXPORT" here again so that they are visible to tests.
660 776
661 MEDIA_EXPORT void AddContainerMask(const std::string& container, 777 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) {
662 uint32 mask) {
663 KeySystems::GetInstance().AddContainerMask(container, mask); 778 KeySystems::GetInstance().AddContainerMask(container, mask);
664 } 779 }
665 780
666 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { 781 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) {
667 KeySystems::GetInstance().AddCodecMask(codec, mask); 782 KeySystems::GetInstance().AddCodecMask(codec, mask);
668 } 783 }
669 784
670 } // namespace media 785 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698