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
3 // found in the LICENSE file.
5 #include "media/base/key_systems.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h"
11 #include "base/logging.h"
12 #include "base/strings/string_util.h"
13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h"
15 #include "media/base/eme_constants.h"
16 #include "media/base/key_system_info.h"
17 #include "media/base/key_systems_support_uma.h"
18 #include "media/base/media_client.h"
22 const char kClearKeyKeySystem
[] = "org.w3.clearkey";
23 const char kPrefixedClearKeyKeySystem
[] = "webkit-org.w3.clearkey";
24 const char kUnsupportedClearKeyKeySystem
[] = "unsupported-org.w3.clearkey";
26 // These names are used by UMA. Do not change them!
27 const char kClearKeyKeySystemNameForUMA
[] = "ClearKey";
28 const char kUnknownKeySystemNameForUMA
[] = "Unknown";
30 struct NamedInitDataType
{
35 // Mapping between initialization data types names and enum values. When adding
36 // entries, make sure to update IsSaneInitDataTypeWithContainer().
37 static NamedInitDataType kInitDataTypeNames
[] = {
38 {"webm", EME_INIT_DATA_TYPE_WEBM
},
39 #if defined(USE_PROPRIETARY_CODECS)
40 {"cenc", EME_INIT_DATA_TYPE_CENC
}
41 #endif // defined(USE_PROPRIETARY_CODECS)
49 // Mapping between containers and their codecs.
50 // Only audio codec can belong to a "audio/*" container. Both audio and video
51 // codecs can belong to a "video/*" container.
52 static NamedCodec kContainerToCodecMasks
[] = {
53 {"audio/webm", EME_CODEC_WEBM_AUDIO_ALL
},
54 {"video/webm", EME_CODEC_WEBM_ALL
},
55 #if defined(USE_PROPRIETARY_CODECS)
56 {"audio/mp4", EME_CODEC_MP4_AUDIO_ALL
},
57 {"video/mp4", EME_CODEC_MP4_ALL
}
58 #endif // defined(USE_PROPRIETARY_CODECS)
61 // Mapping between codec names and enum values.
62 static NamedCodec kCodecStrings
[] = {
63 {"opus", EME_CODEC_WEBM_OPUS
},
64 {"vorbis", EME_CODEC_WEBM_VORBIS
},
65 {"vp8", EME_CODEC_WEBM_VP8
},
66 {"vp8.0", EME_CODEC_WEBM_VP8
},
67 {"vp9", EME_CODEC_WEBM_VP9
},
68 {"vp9.0", EME_CODEC_WEBM_VP9
},
69 #if defined(USE_PROPRIETARY_CODECS)
70 {"mp4a", EME_CODEC_MP4_AAC
},
71 {"avc1", EME_CODEC_MP4_AVC1
},
72 {"avc3", EME_CODEC_MP4_AVC1
}
73 #endif // defined(USE_PROPRIETARY_CODECS)
76 static void AddClearKey(std::vector
<KeySystemInfo
>* concrete_key_systems
) {
77 KeySystemInfo
info(kClearKeyKeySystem
);
79 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec:
80 // http://developer.android.com/guide/appendix/media-formats.html
81 // VP9 support is device dependent.
83 info
.supported_init_data_types
= EME_INIT_DATA_TYPE_WEBM
;
84 info
.supported_codecs
= EME_CODEC_WEBM_ALL
;
86 #if defined(OS_ANDROID)
87 // Temporarily disable VP9 support for Android.
88 // TODO(xhwang): Use mime_util.h to query VP9 support on Android.
89 info
.supported_codecs
&= ~EME_CODEC_WEBM_VP9
;
91 // Opus is not supported on Android yet. http://crbug.com/318436.
92 // TODO(sandersd): Check for platform support to set this bit.
93 info
.supported_codecs
&= ~EME_CODEC_WEBM_OPUS
;
94 #endif // defined(OS_ANDROID)
96 #if defined(USE_PROPRIETARY_CODECS)
97 info
.supported_init_data_types
|= EME_INIT_DATA_TYPE_CENC
;
98 info
.supported_codecs
|= EME_CODEC_MP4_ALL
;
99 #endif // defined(USE_PROPRIETARY_CODECS)
101 info
.use_aes_decryptor
= true;
103 concrete_key_systems
->push_back(info
);
108 static KeySystems
& GetInstance();
110 void UpdateIfNeeded();
112 bool IsConcreteSupportedKeySystem(const std::string
& key_system
);
114 bool IsSupportedKeySystem(const std::string
& key_system
);
116 bool IsSupportedKeySystemWithInitDataType(
117 const std::string
& key_system
,
118 const std::string
& init_data_type
);
120 bool IsSupportedKeySystemWithMediaMimeType(
121 const std::string
& mime_type
,
122 const std::vector
<std::string
>& codecs
,
123 const std::string
& key_system
,
126 std::string
GetKeySystemNameForUMA(const std::string
& key_system
) const;
128 bool UseAesDecryptor(const std::string
& concrete_key_system
);
130 #if defined(ENABLE_PEPPER_CDMS)
131 std::string
GetPepperType(const std::string
& concrete_key_system
);
134 void AddContainerMask(const std::string
& container
, uint32 mask
);
135 void AddCodecMask(const std::string
& codec
, uint32 mask
);
138 void InitializeUMAInfo();
140 void UpdateSupportedKeySystems();
142 void AddConcreteSupportedKeySystems(
143 const std::vector
<KeySystemInfo
>& concrete_key_systems
);
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
,
151 SupportedInitDataTypes supported_init_data_types
,
152 SupportedCodecs supported_codecs
,
153 const std::string
& parent_key_system
);
155 friend struct base::DefaultLazyInstanceTraits
<KeySystems
>;
157 struct KeySystemProperties
{
158 KeySystemProperties()
159 : use_aes_decryptor(false), supported_codecs(EME_CODEC_NONE
) {}
161 bool use_aes_decryptor
;
162 #if defined(ENABLE_PEPPER_CDMS)
163 std::string pepper_type
;
165 SupportedInitDataTypes supported_init_data_types
;
166 SupportedCodecs supported_codecs
;
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
, SupportedCodecs
> ContainerCodecsMap
;
173 typedef base::hash_map
<std::string
, EmeCodec
> CodecsMap
;
174 typedef base::hash_map
<std::string
, EmeInitDataType
> InitDataTypesMap
;
175 typedef base::hash_map
<std::string
, std::string
> KeySystemNameForUMAMap
;
180 EmeInitDataType
GetInitDataTypeForName(
181 const std::string
& init_data_type
) const;
182 // TODO(sandersd): Separate container enum from codec mask value.
183 // http://crbug.com/417440
184 SupportedCodecs
GetCodecMaskForContainer(
185 const std::string
& container
) const;
186 EmeCodec
GetCodecForString(const std::string
& codec
) const;
188 const std::string
& GetConcreteKeySystemName(
189 const std::string
& key_system
) const;
191 // Returns whether a |container| type is supported by checking
192 // |key_system_supported_codecs|.
193 // TODO(xhwang): Update this to actually check initDataType support.
194 bool IsSupportedContainer(const std::string
& container
,
195 SupportedCodecs key_system_supported_codecs
) const;
197 // Returns true if all |codecs| are supported in |container| by checking
198 // |key_system_supported_codecs|.
199 bool IsSupportedContainerAndCodecs(
200 const std::string
& container
,
201 const std::vector
<std::string
>& codecs
,
202 SupportedCodecs key_system_supported_codecs
) const;
204 // Map from key system string to capabilities.
205 KeySystemPropertiesMap concrete_key_system_map_
;
207 // Map from parent key system to the concrete key system that should be used
208 // to represent its capabilities.
209 ParentKeySystemMap parent_key_system_map_
;
211 KeySystemsSupportUMA key_systems_support_uma_
;
213 InitDataTypesMap init_data_type_name_map_
;
214 ContainerCodecsMap container_to_codec_mask_map_
;
215 CodecsMap codec_string_map_
;
216 KeySystemNameForUMAMap key_system_name_for_uma_map_
;
218 // Makes sure all methods are called from the same thread.
219 base::ThreadChecker thread_checker_
;
221 DISALLOW_COPY_AND_ASSIGN(KeySystems
);
224 static base::LazyInstance
<KeySystems
> g_key_systems
= LAZY_INSTANCE_INITIALIZER
;
226 KeySystems
& KeySystems::GetInstance() {
227 KeySystems
& key_systems
= g_key_systems
.Get();
228 key_systems
.UpdateIfNeeded();
232 // Because we use a LazyInstance, the key systems info must be populated when
233 // the instance is lazily initiated.
234 KeySystems::KeySystems() {
235 for (size_t i
= 0; i
< arraysize(kInitDataTypeNames
); ++i
) {
236 const std::string
& name
= kInitDataTypeNames
[i
].name
;
237 DCHECK(!init_data_type_name_map_
.count(name
));
238 init_data_type_name_map_
[name
] = kInitDataTypeNames
[i
].type
;
240 for (size_t i
= 0; i
< arraysize(kContainerToCodecMasks
); ++i
) {
241 const std::string
& name
= kContainerToCodecMasks
[i
].name
;
242 DCHECK(!container_to_codec_mask_map_
.count(name
));
243 container_to_codec_mask_map_
[name
] = kContainerToCodecMasks
[i
].type
;
245 for (size_t i
= 0; i
< arraysize(kCodecStrings
); ++i
) {
246 const std::string
& name
= kCodecStrings
[i
].name
;
247 DCHECK(!codec_string_map_
.count(name
));
248 codec_string_map_
[name
] = kCodecStrings
[i
].type
;
253 // Always update supported key systems during construction.
254 UpdateSupportedKeySystems();
257 EmeInitDataType
KeySystems::GetInitDataTypeForName(
258 const std::string
& init_data_type
) const {
259 InitDataTypesMap::const_iterator iter
=
260 init_data_type_name_map_
.find(init_data_type
);
261 if (iter
!= init_data_type_name_map_
.end())
263 return EME_INIT_DATA_TYPE_NONE
;
266 SupportedCodecs
KeySystems::GetCodecMaskForContainer(
267 const std::string
& container
) const {
268 ContainerCodecsMap::const_iterator iter
=
269 container_to_codec_mask_map_
.find(container
);
270 if (iter
!= container_to_codec_mask_map_
.end())
272 return EME_CODEC_NONE
;
275 EmeCodec
KeySystems::GetCodecForString(const std::string
& codec
) const {
276 CodecsMap::const_iterator iter
= codec_string_map_
.find(codec
);
277 if (iter
!= codec_string_map_
.end())
279 return EME_CODEC_NONE
;
282 const std::string
& KeySystems::GetConcreteKeySystemName(
283 const std::string
& key_system
) const {
284 ParentKeySystemMap::const_iterator iter
=
285 parent_key_system_map_
.find(key_system
);
286 if (iter
!= parent_key_system_map_
.end())
291 void KeySystems::InitializeUMAInfo() {
292 DCHECK(thread_checker_
.CalledOnValidThread());
293 DCHECK(key_system_name_for_uma_map_
.empty());
295 std::vector
<KeySystemInfoForUMA
> key_systems_info_for_uma
;
296 if (GetMediaClient())
297 GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma
);
299 for (const KeySystemInfoForUMA
& info
: key_systems_info_for_uma
) {
300 key_system_name_for_uma_map_
[info
.key_system
] =
301 info
.key_system_name_for_uma
;
302 if (info
.reports_key_system_support_to_uma
)
303 key_systems_support_uma_
.AddKeySystemToReport(info
.key_system
);
306 // Clear Key is always supported.
307 key_system_name_for_uma_map_
[kClearKeyKeySystem
] =
308 kClearKeyKeySystemNameForUMA
;
311 void KeySystems::UpdateIfNeeded() {
312 if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded())
313 UpdateSupportedKeySystems();
316 void KeySystems::UpdateSupportedKeySystems() {
317 DCHECK(thread_checker_
.CalledOnValidThread());
318 concrete_key_system_map_
.clear();
319 parent_key_system_map_
.clear();
321 // Build KeySystemInfo.
322 std::vector
<KeySystemInfo
> key_systems_info
;
324 // Add key systems supported by the MediaClient implementation.
325 if (GetMediaClient())
326 GetMediaClient()->AddSupportedKeySystems(&key_systems_info
);
328 // Clear Key is always supported.
329 AddClearKey(&key_systems_info
);
331 AddConcreteSupportedKeySystems(key_systems_info
);
334 void KeySystems::AddConcreteSupportedKeySystems(
335 const std::vector
<KeySystemInfo
>& concrete_key_systems
) {
336 DCHECK(thread_checker_
.CalledOnValidThread());
337 DCHECK(concrete_key_system_map_
.empty());
338 DCHECK(parent_key_system_map_
.empty());
340 for (size_t i
= 0; i
< concrete_key_systems
.size(); ++i
) {
341 const KeySystemInfo
& key_system_info
= concrete_key_systems
[i
];
342 AddConcreteSupportedKeySystem(key_system_info
.key_system
,
343 key_system_info
.use_aes_decryptor
,
344 #if defined(ENABLE_PEPPER_CDMS)
345 key_system_info
.pepper_type
,
347 key_system_info
.supported_init_data_types
,
348 key_system_info
.supported_codecs
,
349 key_system_info
.parent_key_system
);
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
,
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";
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
;
375 properties
.supported_init_data_types
= supported_init_data_types
;
376 properties
.supported_codecs
= supported_codecs
;
378 concrete_key_system_map_
[concrete_key_system
] = properties
;
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
;
389 bool KeySystems::IsConcreteSupportedKeySystem(const std::string
& key_system
) {
390 DCHECK(thread_checker_
.CalledOnValidThread());
391 return concrete_key_system_map_
.count(key_system
) != 0;
394 bool KeySystems::IsSupportedContainer(
395 const std::string
& container
,
396 SupportedCodecs key_system_supported_codecs
) const {
397 DCHECK(thread_checker_
.CalledOnValidThread());
398 DCHECK(!container
.empty());
400 // When checking container support for EME, "audio/foo" should be treated the
401 // same as "video/foo". Convert the |container| to achieve this.
402 // TODO(xhwang): Replace this with real checks against supported initDataTypes
403 // combined with supported demuxers.
404 std::string canonical_container
= container
;
405 if (container
.find("audio/") == 0)
406 canonical_container
.replace(0, 6, "video/");
408 // A container is supported iif at least one codec in that container is
410 SupportedCodecs supported_codecs
=
411 GetCodecMaskForContainer(canonical_container
);
412 return (supported_codecs
& key_system_supported_codecs
) != 0;
415 bool KeySystems::IsSupportedContainerAndCodecs(
416 const std::string
& container
,
417 const std::vector
<std::string
>& codecs
,
418 SupportedCodecs key_system_supported_codecs
) const {
419 DCHECK(thread_checker_
.CalledOnValidThread());
420 DCHECK(!container
.empty());
421 DCHECK(!codecs
.empty());
422 DCHECK(IsSupportedContainer(container
, key_system_supported_codecs
));
424 SupportedCodecs container_supported_codecs
=
425 GetCodecMaskForContainer(container
);
427 for (size_t i
= 0; i
< codecs
.size(); ++i
) {
428 // TODO(sandersd): This should fail for isTypeSupported().
429 // http://crbug.com/417461
430 if (codecs
[i
].empty())
433 EmeCodec codec
= GetCodecForString(codecs
[i
]);
435 // Unsupported codec.
436 if (!(codec
& key_system_supported_codecs
))
439 // Unsupported codec/container combination, e.g. "video/webm" and "avc1".
440 if (!(codec
& container_supported_codecs
))
447 bool KeySystems::IsSupportedKeySystem(const std::string
& key_system
) {
448 DCHECK(thread_checker_
.CalledOnValidThread());
449 return (concrete_key_system_map_
.count(key_system
) ||
450 parent_key_system_map_
.count(key_system
));
453 bool KeySystems::IsSupportedKeySystemWithInitDataType(
454 const std::string
& key_system
,
455 const std::string
& init_data_type
) {
456 DCHECK(thread_checker_
.CalledOnValidThread());
458 // If |key_system| is a parent key system, use its concrete child.
459 const std::string
& concrete_key_system
= GetConcreteKeySystemName(key_system
);
461 // Locate |concrete_key_system|.
462 KeySystemPropertiesMap::const_iterator key_system_iter
=
463 concrete_key_system_map_
.find(concrete_key_system
);
464 if (key_system_iter
== concrete_key_system_map_
.end())
467 // Check |init_data_type| and |key_system| x |init_data_type|.
468 const KeySystemProperties
& properties
= key_system_iter
->second
;
469 EmeInitDataType eme_init_data_type
= GetInitDataTypeForName(init_data_type
);
470 return (properties
.supported_init_data_types
& eme_init_data_type
) != 0;
473 // TODO(sandersd): Reorganize to be more similar to
474 // IsKeySystemSupportedWithInitDataType(). Note that a fork may still be
475 // required; http://crbug.com/417461.
476 bool KeySystems::IsSupportedKeySystemWithMediaMimeType(
477 const std::string
& mime_type
,
478 const std::vector
<std::string
>& codecs
,
479 const std::string
& key_system
,
481 DCHECK(thread_checker_
.CalledOnValidThread());
483 // If |key_system| is a parent key system, use its concrete child.
484 const std::string
& concrete_key_system
= GetConcreteKeySystemName(key_system
);
486 bool has_type
= !mime_type
.empty();
489 key_systems_support_uma_
.ReportKeySystemQuery(key_system
, has_type
);
491 // Check key system support.
492 KeySystemPropertiesMap::const_iterator key_system_iter
=
493 concrete_key_system_map_
.find(concrete_key_system
);
494 if (key_system_iter
== concrete_key_system_map_
.end())
498 key_systems_support_uma_
.ReportKeySystemSupport(key_system
, false);
501 DCHECK(codecs
.empty());
505 SupportedCodecs key_system_supported_codecs
=
506 key_system_iter
->second
.supported_codecs
;
508 if (!IsSupportedContainer(mime_type
, key_system_supported_codecs
))
511 if (!codecs
.empty() &&
512 !IsSupportedContainerAndCodecs(
513 mime_type
, codecs
, key_system_supported_codecs
)) {
518 key_systems_support_uma_
.ReportKeySystemSupport(key_system
, true);
522 std::string
KeySystems::GetKeySystemNameForUMA(
523 const std::string
& key_system
) const {
524 DCHECK(thread_checker_
.CalledOnValidThread());
526 KeySystemNameForUMAMap::const_iterator iter
=
527 key_system_name_for_uma_map_
.find(key_system
);
528 if (iter
== key_system_name_for_uma_map_
.end())
529 return kUnknownKeySystemNameForUMA
;
534 bool KeySystems::UseAesDecryptor(const std::string
& concrete_key_system
) {
535 DCHECK(thread_checker_
.CalledOnValidThread());
537 KeySystemPropertiesMap::const_iterator key_system_iter
=
538 concrete_key_system_map_
.find(concrete_key_system
);
539 if (key_system_iter
== concrete_key_system_map_
.end()) {
540 DLOG(FATAL
) << concrete_key_system
<< " is not a known concrete system";
544 return key_system_iter
->second
.use_aes_decryptor
;
547 #if defined(ENABLE_PEPPER_CDMS)
548 std::string
KeySystems::GetPepperType(const std::string
& concrete_key_system
) {
549 DCHECK(thread_checker_
.CalledOnValidThread());
551 KeySystemPropertiesMap::const_iterator key_system_iter
=
552 concrete_key_system_map_
.find(concrete_key_system
);
553 if (key_system_iter
== concrete_key_system_map_
.end()) {
554 DLOG(FATAL
) << concrete_key_system
<< " is not a known concrete system";
555 return std::string();
558 const std::string
& type
= key_system_iter
->second
.pepper_type
;
559 DLOG_IF(FATAL
, type
.empty()) << concrete_key_system
<< " is not Pepper-based";
564 void KeySystems::AddContainerMask(const std::string
& container
, uint32 mask
) {
565 DCHECK(thread_checker_
.CalledOnValidThread());
566 DCHECK(!container_to_codec_mask_map_
.count(container
));
567 container_to_codec_mask_map_
[container
] = static_cast<EmeCodec
>(mask
);
570 void KeySystems::AddCodecMask(const std::string
& codec
, uint32 mask
) {
571 DCHECK(thread_checker_
.CalledOnValidThread());
572 DCHECK(!codec_string_map_
.count(codec
));
573 codec_string_map_
[codec
] = static_cast<EmeCodec
>(mask
);
576 //------------------------------------------------------------------------------
578 std::string
GetUnprefixedKeySystemName(const std::string
& key_system
) {
579 if (key_system
== kClearKeyKeySystem
)
580 return kUnsupportedClearKeyKeySystem
;
582 if (key_system
== kPrefixedClearKeyKeySystem
)
583 return kClearKeyKeySystem
;
588 std::string
GetPrefixedKeySystemName(const std::string
& key_system
) {
589 DCHECK_NE(key_system
, kPrefixedClearKeyKeySystem
);
591 if (key_system
== kClearKeyKeySystem
)
592 return kPrefixedClearKeyKeySystem
;
597 bool IsSaneInitDataTypeWithContainer(
598 const std::string
& init_data_type
,
599 const std::string
& container
) {
600 if (init_data_type
== "cenc") {
601 return container
== "audio/mp4" || container
== "video/mp4";
602 } else if (init_data_type
== "webm") {
603 return container
== "audio/webm" || container
== "video/webm";
609 bool IsConcreteSupportedKeySystem(const std::string
& key_system
) {
610 return KeySystems::GetInstance().IsConcreteSupportedKeySystem(key_system
);
613 bool IsSupportedKeySystem(const std::string
& key_system
) {
614 return KeySystems::GetInstance().IsSupportedKeySystem(key_system
);
617 bool IsSupportedKeySystemWithInitDataType(
618 const std::string
& key_system
,
619 const std::string
& init_data_type
) {
620 return KeySystems::GetInstance().IsSupportedKeySystemWithInitDataType(
621 key_system
, init_data_type
);
624 bool IsSupportedKeySystemWithMediaMimeType(
625 const std::string
& mime_type
,
626 const std::vector
<std::string
>& codecs
,
627 const std::string
& key_system
) {
628 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType(
629 mime_type
, codecs
, key_system
, false);
632 bool PrefixedIsSupportedKeySystemWithMediaMimeType(
633 const std::string
& mime_type
,
634 const std::vector
<std::string
>& codecs
,
635 const std::string
& key_system
) {
636 return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType(
637 mime_type
, codecs
, key_system
, true);
640 std::string
GetKeySystemNameForUMA(const std::string
& key_system
) {
641 return KeySystems::GetInstance().GetKeySystemNameForUMA(key_system
);
644 bool CanUseAesDecryptor(const std::string
& concrete_key_system
) {
645 return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system
);
648 #if defined(ENABLE_PEPPER_CDMS)
649 std::string
GetPepperType(const std::string
& concrete_key_system
) {
650 return KeySystems::GetInstance().GetPepperType(concrete_key_system
);
654 // These two functions are for testing purpose only. The declaration in the
655 // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used
656 // by tests but not non-test code. However, this .cc file is compiled as part of
657 // "media" where "UNIT_TEST" is not defined. So we need to specify
658 // "MEDIA_EXPORT" here again so that they are visible to tests.
660 MEDIA_EXPORT
void AddContainerMask(const std::string
& container
,
662 KeySystems::GetInstance().AddContainerMask(container
, mask
);
665 MEDIA_EXPORT
void AddCodecMask(const std::string
& codec
, uint32 mask
) {
666 KeySystems::GetInstance().AddCodecMask(codec
, mask
);