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 whether the list of codecs are supported together by |key_system|.
38 // TODO(sandersd): Return a rule instead of a bool so that codec selection can
39 // affect other configuration options (namely robustness).
40 virtual bool IsSupportedCodecCombination(
41 const std::string
& key_system
,
42 EmeMediaType media_type
,
43 const std::string
& container_mime_type
,
44 const std::vector
<std::string
>& codecs
) const = 0;
46 // Returns the configuration rule for supporting a robustness requirement.
47 virtual EmeConfigRule
GetRobustnessConfigRule(
48 const std::string
& key_system
,
49 EmeMediaType media_type
,
50 const std::string
& requested_robustness
) const = 0;
52 // Returns the configuration rule for supporting persistent-license sessions.
53 virtual EmeConfigRule
GetPersistentLicenseSessionConfigRule(
54 const std::string
& key_system
) const = 0;
56 // Returns the configuration rule for supporting persistent-release-message
58 virtual EmeConfigRule
GetPersistentReleaseMessageSessionConfigRule(
59 const std::string
& key_system
) const = 0;
61 // Returns the configuration rule for supporting a persistent state
63 virtual EmeConfigRule
GetPersistentStateConfigRule(
64 const std::string
& key_system
,
65 EmeFeatureRequirement requirement
) const = 0;
67 // Returns the configuration rule for supporting a distinctive identifier
69 virtual EmeConfigRule
GetDistinctiveIdentifierConfigRule(
70 const std::string
& key_system
,
71 EmeFeatureRequirement requirement
) const = 0;
74 // Prefixed EME API only supports prefixed (webkit-) key system name for
75 // certain key systems. But internally only unprefixed key systems are
76 // supported. The following two functions help convert between prefixed and
77 // unprefixed key system names.
79 // Gets the unprefixed key system name for |key_system|.
80 MEDIA_EXPORT
std::string
GetUnprefixedKeySystemName(
81 const std::string
& key_system
);
83 // Gets the prefixed key system name for |key_system|.
84 MEDIA_EXPORT
std::string
GetPrefixedKeySystemName(
85 const std::string
& key_system
);
87 // Use for unprefixed EME only!
88 // Returns whether |key_system| is a supported key system.
89 // Note: Shouldn't be used for prefixed API as the original
90 MEDIA_EXPORT
bool IsSupportedKeySystem(const std::string
& key_system
);
92 // Use for prefixed EME only!
93 MEDIA_EXPORT
bool IsSupportedKeySystemWithInitDataType(
94 const std::string
& key_system
,
95 EmeInitDataType init_data_type
);
97 // Use for prefixed EME only!
98 // Returns whether |key_system| is a real supported key system that can be
100 // Abstract parent |key_system| strings will return false.
101 MEDIA_EXPORT
bool PrefixedIsSupportedConcreteKeySystem(
102 const std::string
& key_system
);
104 // Use for prefixed EME only!
105 // Returns whether |key_system| supports the specified media type and codec(s).
106 // To be used with prefixed EME only as it generates UMAs based on the query.
107 MEDIA_EXPORT
bool PrefixedIsSupportedKeySystemWithMediaMimeType(
108 const std::string
& mime_type
,
109 const std::vector
<std::string
>& codecs
,
110 const std::string
& key_system
);
112 // Returns a name for |key_system| suitable to UMA logging.
113 MEDIA_EXPORT
std::string
GetKeySystemNameForUMA(const std::string
& key_system
);
115 // Returns whether AesDecryptor can be used for the given |concrete_key_system|.
116 MEDIA_EXPORT
bool CanUseAesDecryptor(const std::string
& concrete_key_system
);
118 #if defined(ENABLE_PEPPER_CDMS)
119 // Returns the Pepper MIME type for |concrete_key_system|.
120 // Returns empty string if |concrete_key_system| is unknown or not Pepper-based.
121 MEDIA_EXPORT
std::string
GetPepperType(
122 const std::string
& concrete_key_system
);
125 #if defined(UNIT_TEST)
126 // Helper functions to add container/codec types for testing purposes.
127 MEDIA_EXPORT
void AddContainerMask(const std::string
& container
, uint32 mask
);
128 MEDIA_EXPORT
void AddCodecMask(
129 EmeMediaType media_type
,
130 const std::string
& codec
,
132 #endif // defined(UNIT_TEST)
136 #endif // MEDIA_BASE_KEY_SYSTEMS_H_