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 <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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 // REQUESTABLE and REQUESTABLE_WITH_PERMISSION are not available until we |
| 347 // can block access/ per-CDM-instance. http://crbug.com/457482 |
| 348 // Note: Even once that is fixed, distinctive identifiers should never be |
| 349 // REQUESTABLE, since user permission is always required. |
| 350 DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED || |
| 351 info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED); |
| 352 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || |
| 353 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); |
| 354 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { |
| 355 DCHECK_EQ(info.persistent_license_support, |
| 356 EME_SESSION_TYPE_NOT_SUPPORTED); |
| 357 DCHECK_EQ(info.persistent_release_message_support, |
| 358 EME_SESSION_TYPE_NOT_SUPPORTED); |
| 359 } |
| 360 DCHECK(!IsSupportedKeySystem(info.key_system)) |
| 361 << "Key system '" << info.key_system << "' already registered"; |
| 362 DCHECK(!parent_key_system_map_.count(info.key_system)) |
| 363 << "'" << info.key_system << "' is already registered as a parent"; |
344 #if defined(ENABLE_PEPPER_CDMS) | 364 #if defined(ENABLE_PEPPER_CDMS) |
345 key_system_info.pepper_type, | 365 DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); |
346 #endif | 366 #endif |
347 key_system_info.supported_init_data_types, | 367 |
348 key_system_info.supported_codecs, | 368 concrete_key_system_map_[info.key_system] = info; |
349 key_system_info.parent_key_system); | 369 |
| 370 if (!info.parent_key_system.empty()) { |
| 371 DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
| 372 << "Parent '" << info.parent_key_system << "' " |
| 373 << "already registered concrete"; |
| 374 DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
| 375 << "Parent '" << info.parent_key_system << "' already registered"; |
| 376 parent_key_system_map_[info.parent_key_system] = info.key_system; |
| 377 } |
350 } | 378 } |
351 } | 379 } |
352 | 380 |
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) { | 381 bool KeySystems::IsConcreteSupportedKeySystem(const std::string& key_system) { |
390 DCHECK(thread_checker_.CalledOnValidThread()); | 382 DCHECK(thread_checker_.CalledOnValidThread()); |
391 return concrete_key_system_map_.count(key_system) != 0; | 383 return concrete_key_system_map_.count(key_system) != 0; |
392 } | 384 } |
393 | 385 |
394 bool KeySystems::IsSupportedContainer( | 386 bool KeySystems::IsSupportedContainer( |
395 const std::string& container, | 387 const std::string& container, |
396 SupportedCodecs key_system_supported_codecs) const { | 388 SupportedCodecs key_system_supported_codecs) const { |
397 DCHECK(thread_checker_.CalledOnValidThread()); | 389 DCHECK(thread_checker_.CalledOnValidThread()); |
398 DCHECK(!container.empty()); | 390 DCHECK(!container.empty()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // Unprefixed EME only supports concrete key systems. | 441 // Unprefixed EME only supports concrete key systems. |
450 return concrete_key_system_map_.count(key_system) != 0; | 442 return concrete_key_system_map_.count(key_system) != 0; |
451 } | 443 } |
452 | 444 |
453 bool KeySystems::IsSupportedKeySystemWithInitDataType( | 445 bool KeySystems::IsSupportedKeySystemWithInitDataType( |
454 const std::string& key_system, | 446 const std::string& key_system, |
455 const std::string& init_data_type) { | 447 const std::string& init_data_type) { |
456 DCHECK(thread_checker_.CalledOnValidThread()); | 448 DCHECK(thread_checker_.CalledOnValidThread()); |
457 | 449 |
458 // Locate |key_system|. Only concrete key systems are supported in unprefixed. | 450 // Locate |key_system|. Only concrete key systems are supported in unprefixed. |
459 KeySystemPropertiesMap::const_iterator key_system_iter = | 451 KeySystemInfoMap::const_iterator key_system_iter = |
460 concrete_key_system_map_.find(key_system); | 452 concrete_key_system_map_.find(key_system); |
461 if (key_system_iter == concrete_key_system_map_.end()) | 453 if (key_system_iter == concrete_key_system_map_.end()) |
462 return false; | 454 return false; |
463 | 455 |
464 // Check |init_data_type| and |key_system| x |init_data_type|. | 456 // Check |init_data_type| and |key_system| x |init_data_type|. |
465 const KeySystemProperties& properties = key_system_iter->second; | 457 const KeySystemInfo& info = key_system_iter->second; |
466 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); | 458 EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
467 return (properties.supported_init_data_types & eme_init_data_type) != 0; | 459 return (info.supported_init_data_types & eme_init_data_type) != 0; |
468 } | 460 } |
469 | 461 |
470 // TODO(sandersd): Reorganize to be more similar to | 462 // TODO(sandersd): Reorganize to be more similar to |
471 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be | 463 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be |
472 // required; http://crbug.com/417461. | 464 // required; http://crbug.com/417461. |
473 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( | 465 bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
474 const std::string& mime_type, | 466 const std::string& mime_type, |
475 const std::vector<std::string>& codecs, | 467 const std::vector<std::string>& codecs, |
476 const std::string& key_system, | 468 const std::string& key_system, |
477 bool is_prefixed) { | 469 bool is_prefixed) { |
478 DCHECK(thread_checker_.CalledOnValidThread()); | 470 DCHECK(thread_checker_.CalledOnValidThread()); |
479 const bool report_to_uma = is_prefixed; | 471 const bool report_to_uma = is_prefixed; |
480 | 472 |
481 // If |is_prefixed| and |key_system| is a parent key system, use its concrete | 473 // If |is_prefixed| and |key_system| is a parent key system, use its concrete |
482 // child. | 474 // child. |
483 const std::string& concrete_key_system = is_prefixed ? | 475 const std::string& concrete_key_system = is_prefixed ? |
484 PrefixedGetConcreteKeySystemNameFor(key_system) : | 476 PrefixedGetConcreteKeySystemNameFor(key_system) : |
485 key_system; | 477 key_system; |
486 | 478 |
487 bool has_type = !mime_type.empty(); | 479 bool has_type = !mime_type.empty(); |
488 | 480 |
489 if (report_to_uma) | 481 if (report_to_uma) |
490 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); | 482 key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
491 | 483 |
492 // Check key system support. | 484 // Check key system support. |
493 KeySystemPropertiesMap::const_iterator key_system_iter = | 485 KeySystemInfoMap::const_iterator key_system_iter = |
494 concrete_key_system_map_.find(concrete_key_system); | 486 concrete_key_system_map_.find(concrete_key_system); |
495 if (key_system_iter == concrete_key_system_map_.end()) | 487 if (key_system_iter == concrete_key_system_map_.end()) |
496 return false; | 488 return false; |
497 | 489 |
498 if (report_to_uma) | 490 if (report_to_uma) |
499 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); | 491 key_systems_support_uma_.ReportKeySystemSupport(key_system, false); |
500 | 492 |
501 if (!has_type) { | 493 if (!has_type) { |
502 DCHECK(codecs.empty()); | 494 DCHECK(codecs.empty()); |
503 return true; | 495 return true; |
(...skipping 24 matching lines...) Expand all Loading... |
528 key_system_name_for_uma_map_.find(key_system); | 520 key_system_name_for_uma_map_.find(key_system); |
529 if (iter == key_system_name_for_uma_map_.end()) | 521 if (iter == key_system_name_for_uma_map_.end()) |
530 return kUnknownKeySystemNameForUMA; | 522 return kUnknownKeySystemNameForUMA; |
531 | 523 |
532 return iter->second; | 524 return iter->second; |
533 } | 525 } |
534 | 526 |
535 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { | 527 bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { |
536 DCHECK(thread_checker_.CalledOnValidThread()); | 528 DCHECK(thread_checker_.CalledOnValidThread()); |
537 | 529 |
538 KeySystemPropertiesMap::const_iterator key_system_iter = | 530 KeySystemInfoMap::const_iterator key_system_iter = |
539 concrete_key_system_map_.find(concrete_key_system); | 531 concrete_key_system_map_.find(concrete_key_system); |
540 if (key_system_iter == concrete_key_system_map_.end()) { | 532 if (key_system_iter == concrete_key_system_map_.end()) { |
541 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 533 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
542 return false; | 534 return false; |
543 } | 535 } |
544 | 536 |
545 return key_system_iter->second.use_aes_decryptor; | 537 return key_system_iter->second.use_aes_decryptor; |
546 } | 538 } |
547 | 539 |
548 #if defined(ENABLE_PEPPER_CDMS) | 540 #if defined(ENABLE_PEPPER_CDMS) |
549 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { | 541 std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { |
550 DCHECK(thread_checker_.CalledOnValidThread()); | 542 DCHECK(thread_checker_.CalledOnValidThread()); |
551 | 543 |
552 KeySystemPropertiesMap::const_iterator key_system_iter = | 544 KeySystemInfoMap::const_iterator key_system_iter = |
553 concrete_key_system_map_.find(concrete_key_system); | 545 concrete_key_system_map_.find(concrete_key_system); |
554 if (key_system_iter == concrete_key_system_map_.end()) { | 546 if (key_system_iter == concrete_key_system_map_.end()) { |
555 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; | 547 DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
556 return std::string(); | 548 return std::string(); |
557 } | 549 } |
558 | 550 |
559 const std::string& type = key_system_iter->second.pepper_type; | 551 const std::string& type = key_system_iter->second.pepper_type; |
560 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; | 552 DLOG_IF(FATAL, type.empty()) << concrete_key_system << " is not Pepper-based"; |
561 return type; | 553 return type; |
562 } | 554 } |
563 #endif | 555 #endif |
564 | 556 |
| 557 bool KeySystems::IsPersistentLicenseSessionSupported( |
| 558 const std::string& key_system, |
| 559 bool is_permission_granted) { |
| 560 DCHECK(thread_checker_.CalledOnValidThread()); |
| 561 |
| 562 KeySystemInfoMap::const_iterator key_system_iter = |
| 563 concrete_key_system_map_.find(key_system); |
| 564 if (key_system_iter == concrete_key_system_map_.end()) { |
| 565 NOTREACHED(); |
| 566 return false; |
| 567 } |
| 568 |
| 569 switch (key_system_iter->second.persistent_license_support) { |
| 570 case EME_SESSION_TYPE_INVALID: |
| 571 NOTREACHED(); |
| 572 return false; |
| 573 case EME_SESSION_TYPE_NOT_SUPPORTED: |
| 574 return false; |
| 575 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION: |
| 576 return is_permission_granted; |
| 577 case EME_SESSION_TYPE_SUPPORTED: |
| 578 return true; |
| 579 } |
| 580 |
| 581 NOTREACHED(); |
| 582 return false; |
| 583 } |
| 584 |
| 585 bool KeySystems::IsPersistentReleaseMessageSessionSupported( |
| 586 const std::string& key_system, |
| 587 bool is_permission_granted) { |
| 588 DCHECK(thread_checker_.CalledOnValidThread()); |
| 589 |
| 590 KeySystemInfoMap::const_iterator key_system_iter = |
| 591 concrete_key_system_map_.find(key_system); |
| 592 if (key_system_iter == concrete_key_system_map_.end()) { |
| 593 NOTREACHED(); |
| 594 return false; |
| 595 } |
| 596 |
| 597 switch (key_system_iter->second.persistent_release_message_support) { |
| 598 case EME_SESSION_TYPE_INVALID: |
| 599 NOTREACHED(); |
| 600 return false; |
| 601 case EME_SESSION_TYPE_NOT_SUPPORTED: |
| 602 return false; |
| 603 case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION: |
| 604 return is_permission_granted; |
| 605 case EME_SESSION_TYPE_SUPPORTED: |
| 606 return true; |
| 607 } |
| 608 |
| 609 NOTREACHED(); |
| 610 return false; |
| 611 } |
| 612 |
| 613 bool KeySystems::IsPersistentStateRequirementSupported( |
| 614 const std::string& key_system, |
| 615 EmeFeatureRequirement requirement, |
| 616 bool is_permission_granted) { |
| 617 DCHECK(thread_checker_.CalledOnValidThread()); |
| 618 |
| 619 KeySystemInfoMap::const_iterator key_system_iter = |
| 620 concrete_key_system_map_.find(key_system); |
| 621 if (key_system_iter == concrete_key_system_map_.end()) { |
| 622 NOTREACHED(); |
| 623 return false; |
| 624 } |
| 625 |
| 626 switch (key_system_iter->second.persistent_state_support) { |
| 627 case EME_FEATURE_INVALID: |
| 628 NOTREACHED(); |
| 629 return false; |
| 630 case EME_FEATURE_NOT_SUPPORTED: |
| 631 return requirement != EME_FEATURE_REQUIRED; |
| 632 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: |
| 633 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; |
| 634 case EME_FEATURE_REQUESTABLE: |
| 635 return true; |
| 636 case EME_FEATURE_ALWAYS_ENABLED: |
| 637 // Persistent state does not require user permission, but the session |
| 638 // types that use it might. |
| 639 return requirement != EME_FEATURE_NOT_ALLOWED; |
| 640 } |
| 641 |
| 642 NOTREACHED(); |
| 643 return false; |
| 644 } |
| 645 |
| 646 bool KeySystems::IsDistinctiveIdentifierRequirementSupported( |
| 647 const std::string& key_system, |
| 648 EmeFeatureRequirement requirement, |
| 649 bool is_permission_granted) { |
| 650 DCHECK(thread_checker_.CalledOnValidThread()); |
| 651 |
| 652 KeySystemInfoMap::const_iterator key_system_iter = |
| 653 concrete_key_system_map_.find(key_system); |
| 654 if (key_system_iter == concrete_key_system_map_.end()) { |
| 655 NOTREACHED(); |
| 656 return false; |
| 657 } |
| 658 |
| 659 switch (key_system_iter->second.distinctive_identifier_support) { |
| 660 case EME_FEATURE_INVALID: |
| 661 NOTREACHED(); |
| 662 return false; |
| 663 case EME_FEATURE_NOT_SUPPORTED: |
| 664 return requirement != EME_FEATURE_REQUIRED; |
| 665 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: |
| 666 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; |
| 667 case EME_FEATURE_REQUESTABLE: |
| 668 NOTREACHED(); |
| 669 return true; |
| 670 case EME_FEATURE_ALWAYS_ENABLED: |
| 671 // Distinctive identifiers always require user permission. |
| 672 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted; |
| 673 } |
| 674 |
| 675 NOTREACHED(); |
| 676 return false; |
| 677 } |
| 678 |
565 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { | 679 void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
566 DCHECK(thread_checker_.CalledOnValidThread()); | 680 DCHECK(thread_checker_.CalledOnValidThread()); |
567 DCHECK(!container_to_codec_mask_map_.count(container)); | 681 DCHECK(!container_to_codec_mask_map_.count(container)); |
568 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); | 682 container_to_codec_mask_map_[container] = static_cast<EmeCodec>(mask); |
569 } | 683 } |
570 | 684 |
571 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { | 685 void KeySystems::AddCodecMask(const std::string& codec, uint32 mask) { |
572 DCHECK(thread_checker_.CalledOnValidThread()); | 686 DCHECK(thread_checker_.CalledOnValidThread()); |
573 DCHECK(!codec_string_map_.count(codec)); | 687 DCHECK(!codec_string_map_.count(codec)); |
574 codec_string_map_[codec] = static_cast<EmeCodec>(mask); | 688 codec_string_map_[codec] = static_cast<EmeCodec>(mask); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 bool CanUseAesDecryptor(const std::string& concrete_key_system) { | 759 bool CanUseAesDecryptor(const std::string& concrete_key_system) { |
646 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); | 760 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system); |
647 } | 761 } |
648 | 762 |
649 #if defined(ENABLE_PEPPER_CDMS) | 763 #if defined(ENABLE_PEPPER_CDMS) |
650 std::string GetPepperType(const std::string& concrete_key_system) { | 764 std::string GetPepperType(const std::string& concrete_key_system) { |
651 return KeySystems::GetInstance().GetPepperType(concrete_key_system); | 765 return KeySystems::GetInstance().GetPepperType(concrete_key_system); |
652 } | 766 } |
653 #endif | 767 #endif |
654 | 768 |
| 769 bool IsPersistentLicenseSessionSupported( |
| 770 const std::string& key_system, |
| 771 bool is_permission_granted) { |
| 772 return KeySystems::GetInstance().IsPersistentLicenseSessionSupported( |
| 773 key_system, is_permission_granted); |
| 774 } |
| 775 |
| 776 bool IsPersistentReleaseMessageSessionSupported( |
| 777 const std::string& key_system, |
| 778 bool is_permission_granted) { |
| 779 return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported( |
| 780 key_system, is_permission_granted); |
| 781 } |
| 782 |
| 783 bool IsPersistentStateRequirementSupported( |
| 784 const std::string& key_system, |
| 785 EmeFeatureRequirement requirement, |
| 786 bool is_permission_granted) { |
| 787 return KeySystems::GetInstance().IsPersistentStateRequirementSupported( |
| 788 key_system, requirement, is_permission_granted); |
| 789 } |
| 790 |
| 791 bool IsDistinctiveIdentifierRequirementSupported( |
| 792 const std::string& key_system, |
| 793 EmeFeatureRequirement requirement, |
| 794 bool is_permission_granted) { |
| 795 return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported( |
| 796 key_system, requirement, is_permission_granted); |
| 797 } |
| 798 |
655 // These two functions are for testing purpose only. The declaration in the | 799 // 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 | 800 // 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 | 801 // 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 | 802 // "media" where "UNIT_TEST" is not defined. So we need to specify |
659 // "MEDIA_EXPORT" here again so that they are visible to tests. | 803 // "MEDIA_EXPORT" here again so that they are visible to tests. |
660 | 804 |
661 MEDIA_EXPORT void AddContainerMask(const std::string& container, | 805 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
662 uint32 mask) { | |
663 KeySystems::GetInstance().AddContainerMask(container, mask); | 806 KeySystems::GetInstance().AddContainerMask(container, mask); |
664 } | 807 } |
665 | 808 |
666 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 809 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
667 KeySystems::GetInstance().AddCodecMask(codec, mask); | 810 KeySystems::GetInstance().AddCodecMask(codec, mask); |
668 } | 811 } |
669 | 812 |
670 } // namespace media | 813 } // namespace media |
OLD | NEW |