Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / media / base / key_systems.h
blob064e2cf02c3bc78dec9b5be27c85260d0af84f63
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_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/eme_constants.h"
13 #include "media/base/media_export.h"
15 namespace media {
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 {
26 public:
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 support |key_system| provides for persistent-license sessions.
53 virtual EmeSessionTypeSupport GetPersistentLicenseSessionSupport(
54 const std::string& key_system) const = 0;
56 // Returns the support |key_system| provides for persistent-release-message
57 // sessions.
58 virtual EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport(
59 const std::string& key_system) const = 0;
61 // Returns the support |key_system| provides for persistent state.
62 virtual EmeFeatureSupport GetPersistentStateSupport(
63 const std::string& key_system) const = 0;
65 // Returns the support |key_system| provides for distinctive identifiers.
66 virtual EmeFeatureSupport GetDistinctiveIdentifierSupport(
67 const std::string& key_system) const = 0;
69 protected:
70 virtual ~KeySystems() {};
73 // Prefixed EME API only supports prefixed (webkit-) key system name for
74 // certain key systems. But internally only unprefixed key systems are
75 // supported. The following two functions help convert between prefixed and
76 // unprefixed key system names.
78 // Gets the unprefixed key system name for |key_system|.
79 MEDIA_EXPORT std::string GetUnprefixedKeySystemName(
80 const std::string& key_system);
82 // Gets the prefixed key system name for |key_system|.
83 MEDIA_EXPORT std::string GetPrefixedKeySystemName(
84 const std::string& key_system);
86 // Use for unprefixed EME only!
87 // Returns whether |key_system| is a supported key system.
88 // Note: Shouldn't be used for prefixed API as the original
89 MEDIA_EXPORT bool IsSupportedKeySystem(const std::string& key_system);
91 // Use for prefixed EME only!
92 MEDIA_EXPORT bool IsSupportedKeySystemWithInitDataType(
93 const std::string& key_system,
94 EmeInitDataType init_data_type);
96 // Use for prefixed EME only!
97 // Returns whether |key_system| is a real supported key system that can be
98 // instantiated.
99 // Abstract parent |key_system| strings will return false.
100 MEDIA_EXPORT bool PrefixedIsSupportedConcreteKeySystem(
101 const std::string& key_system);
103 // Use for prefixed EME only!
104 // Returns whether |key_system| supports the specified media type and codec(s).
105 // To be used with prefixed EME only as it generates UMAs based on the query.
106 MEDIA_EXPORT bool PrefixedIsSupportedKeySystemWithMediaMimeType(
107 const std::string& mime_type,
108 const std::vector<std::string>& codecs,
109 const std::string& key_system);
111 // Returns a name for |key_system| suitable to UMA logging.
112 MEDIA_EXPORT std::string GetKeySystemNameForUMA(const std::string& key_system);
114 // Returns whether AesDecryptor can be used for the given |concrete_key_system|.
115 MEDIA_EXPORT bool CanUseAesDecryptor(const std::string& concrete_key_system);
117 #if defined(ENABLE_PEPPER_CDMS)
118 // Returns the Pepper MIME type for |concrete_key_system|.
119 // Returns empty string if |concrete_key_system| is unknown or not Pepper-based.
120 MEDIA_EXPORT std::string GetPepperType(
121 const std::string& concrete_key_system);
122 #endif
124 #if defined(UNIT_TEST)
125 // Helper functions to add container/codec types for testing purposes.
126 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask);
127 MEDIA_EXPORT void AddCodecMask(
128 EmeMediaType media_type,
129 const std::string& codec,
130 uint32 mask);
131 #endif // defined(UNIT_TEST)
133 } // namespace media
135 #endif // MEDIA_BASE_KEY_SYSTEMS_H_