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 #ifndef MEDIA_BASE_KEY_SYSTEMS_H_
6 #define MEDIA_BASE_KEY_SYSTEMS_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/eme_constants.h"
13 #include "media/base/media_export.h"
17 // Provides an interface for querying registered key systems. The exposed API is
18 // only intended to support unprefixed EME.
20 // Many of the original static methods are still available, they should be
21 // migrated into this interface over time (or removed).
23 // TODO(sandersd): Provide GetKeySystem() so that it is not necessary to pass
24 // |key_system| to every method. http://crbug.com/457438
25 class MEDIA_EXPORT KeySystems
{
27 static KeySystems
* GetInstance();
29 // Returns whether |key_system| is a supported key system.
30 virtual bool IsSupportedKeySystem(const std::string
& key_system
) const = 0;
32 // Returns whether |init_data_type| is supported by |key_system|.
33 virtual bool IsSupportedInitDataType(
34 const std::string
& key_system
,
35 EmeInitDataType init_data_type
) const = 0;
37 // Returns the configuration rule for supporting a container and list of
39 virtual EmeConfigRule
GetContentTypeConfigRule(
40 const std::string
& key_system
,
41 EmeMediaType media_type
,
42 const std::string
& container_mime_type
,
43 const std::vector
<std::string
>& codecs
) const = 0;
45 // Returns the configuration rule for supporting a robustness requirement.
46 virtual EmeConfigRule
GetRobustnessConfigRule(
47 const std::string
& key_system
,
48 EmeMediaType media_type
,
49 const std::string
& requested_robustness
) const = 0;
51 // Returns the support |key_system| provides for persistent-license sessions.
52 virtual EmeSessionTypeSupport
GetPersistentLicenseSessionSupport(
53 const std::string
& key_system
) const = 0;
55 // Returns the support |key_system| provides for persistent-release-message
57 virtual EmeSessionTypeSupport
GetPersistentReleaseMessageSessionSupport(
58 const std::string
& key_system
) const = 0;
60 // Returns the support |key_system| provides for persistent state.
61 virtual EmeFeatureSupport
GetPersistentStateSupport(
62 const std::string
& key_system
) const = 0;
64 // Returns the support |key_system| provides for distinctive identifiers.
65 virtual EmeFeatureSupport
GetDistinctiveIdentifierSupport(
66 const std::string
& key_system
) const = 0;
69 virtual ~KeySystems() {};
72 // Prefixed EME API only supports prefixed (webkit-) key system name for
73 // certain key systems. But internally only unprefixed key systems are
74 // supported. The following two functions help convert between prefixed and
75 // unprefixed key system names.
77 // Gets the unprefixed key system name for |key_system|.
78 MEDIA_EXPORT
std::string
GetUnprefixedKeySystemName(
79 const std::string
& key_system
);
81 // Gets the prefixed key system name for |key_system|.
82 MEDIA_EXPORT
std::string
GetPrefixedKeySystemName(
83 const std::string
& key_system
);
85 // Use for unprefixed EME only!
86 // Returns whether |key_system| is a supported key system.
87 // Note: Shouldn't be used for prefixed API as the original
88 MEDIA_EXPORT
bool IsSupportedKeySystem(const std::string
& key_system
);
90 // Use for prefixed EME only!
91 MEDIA_EXPORT
bool IsSupportedKeySystemWithInitDataType(
92 const std::string
& key_system
,
93 EmeInitDataType init_data_type
);
95 // Use for prefixed EME only!
96 // Returns whether |key_system| is a real supported key system that can be
98 // Abstract parent |key_system| strings will return false.
99 MEDIA_EXPORT
bool PrefixedIsSupportedConcreteKeySystem(
100 const std::string
& key_system
);
102 // Use for prefixed EME only!
103 // Returns whether |key_system| supports the specified media type and codec(s).
104 // To be used with prefixed EME only as it generates UMAs based on the query.
105 MEDIA_EXPORT
bool PrefixedIsSupportedKeySystemWithMediaMimeType(
106 const std::string
& mime_type
,
107 const std::vector
<std::string
>& codecs
,
108 const std::string
& key_system
);
110 // Returns a name for |key_system| suitable to UMA logging.
111 MEDIA_EXPORT
std::string
GetKeySystemNameForUMA(const std::string
& key_system
);
113 // Returns whether AesDecryptor can be used for the given |concrete_key_system|.
114 MEDIA_EXPORT
bool CanUseAesDecryptor(const std::string
& concrete_key_system
);
116 #if defined(ENABLE_PEPPER_CDMS)
117 // Returns the Pepper MIME type for |concrete_key_system|.
118 // Returns empty string if |concrete_key_system| is unknown or not Pepper-based.
119 MEDIA_EXPORT
std::string
GetPepperType(
120 const std::string
& concrete_key_system
);
123 #if defined(UNIT_TEST)
124 // Helper functions to add container/codec types for testing purposes.
125 MEDIA_EXPORT
void AddContainerMask(const std::string
& container
, uint32 mask
);
126 MEDIA_EXPORT
void AddCodecMask(
127 EmeMediaType media_type
,
128 const std::string
& codec
,
130 #endif // defined(UNIT_TEST)
134 #endif // MEDIA_BASE_KEY_SYSTEMS_H_