• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <media/stagefright/foundation/ABase.h>
18 #include <media/drm/DrmAPI.h>
19 #include <mediadrm/DrmStatus.h>
20 #include <mediadrm/IDrmClient.h>
21 #include <mediadrm/IDrmMetricsConsumer.h>
22 
23 #ifndef ANDROID_IDRM_H_
24 
25 #define ANDROID_IDRM_H_
26 
27 #define IDRM_UUID_SIZE (16)
28 
29 namespace android {
30 namespace hardware {
31 namespace drm {
32 namespace V1_4 {
33 struct LogMessage;
34 }  // namespace V1_4
35 }  // namespace drm
36 }  // namespace hardware
37 
38 enum IDrmFrontend : int32_t {
39     IDRM_UNKNOWN = 0,
40     IDRM_JNI = 1,
41     IDRM_NDK = 2,
42     IDRM_NUPLAYER = 3,
43 };
44 
45 namespace drm = ::android::hardware::drm;
46 
47 struct AString;
48 
49 struct IDrm : public virtual RefBase {
50 
~IDrmIDrm51     virtual ~IDrm() {}
52 
53     virtual DrmStatus initCheck() const = 0;
54 
55     virtual DrmStatus isCryptoSchemeSupported(const uint8_t uuid[16], const String8& mimeType,
56                                               DrmPlugin::SecurityLevel securityLevel,
57                                               bool* result) = 0;
58 
59     virtual DrmStatus createPlugin(const uint8_t uuid[16],
60                                    const String8 &appPackageName) = 0;
61 
62     virtual DrmStatus destroyPlugin() = 0;
63 
64     virtual DrmStatus openSession(DrmPlugin::SecurityLevel securityLevel,
65             Vector<uint8_t> &sessionId) = 0;
66 
67     virtual DrmStatus closeSession(Vector<uint8_t> const &sessionId) = 0;
68 
69     virtual DrmStatus
70         getKeyRequest(Vector<uint8_t> const &sessionId,
71                       Vector<uint8_t> const &initData,
72                       String8 const &mimeType, DrmPlugin::KeyType keyType,
73                       KeyedVector<String8, String8> const &optionalParameters,
74                       Vector<uint8_t> &request, String8 &defaultUrl,
75                       DrmPlugin::KeyRequestType *keyRequestType) = 0;
76 
77     virtual DrmStatus provideKeyResponse(Vector<uint8_t> const &sessionId,
78                                          Vector<uint8_t> const &response,
79                                          Vector<uint8_t> &keySetId) = 0;
80 
81     virtual DrmStatus removeKeys(Vector<uint8_t> const &keySetId) = 0;
82 
83     virtual DrmStatus restoreKeys(Vector<uint8_t> const &sessionId,
84                                   Vector<uint8_t> const &keySetId) = 0;
85 
86     virtual DrmStatus queryKeyStatus(Vector<uint8_t> const &sessionId,
87                                      KeyedVector<String8, String8> &infoMap) const = 0;
88 
89     virtual DrmStatus getProvisionRequest(String8 const &certType,
90                                           String8 const &certAuthority,
91                                           Vector<uint8_t> &request,
92                                           String8 &defaultUrl) = 0;
93 
94     virtual DrmStatus provideProvisionResponse(Vector<uint8_t> const &response,
95                                                Vector<uint8_t> &certificate,
96                                                Vector<uint8_t> &wrappedKey) = 0;
97 
98     virtual DrmStatus getSecureStops(List<Vector<uint8_t>> &secureStops) = 0;
99     virtual DrmStatus getSecureStopIds(List<Vector<uint8_t>> &secureStopIds) = 0;
100     virtual DrmStatus getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) = 0;
101 
102     virtual DrmStatus releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0;
103     virtual DrmStatus removeSecureStop(Vector<uint8_t> const &ssid) = 0;
104     virtual DrmStatus removeAllSecureStops() = 0;
105 
106     virtual DrmStatus getHdcpLevels(DrmPlugin::HdcpLevel *connectedLevel,
107             DrmPlugin::HdcpLevel *maxLevel)
108             const = 0;
109     virtual DrmStatus getNumberOfSessions(uint32_t *currentSessions,
110             uint32_t *maxSessions) const = 0;
111     virtual DrmStatus getSecurityLevel(Vector<uint8_t> const &sessionId,
112             DrmPlugin::SecurityLevel *level) const = 0;
113 
114     virtual DrmStatus getOfflineLicenseKeySetIds(List<Vector<uint8_t>> &keySetIds) const = 0;
115     virtual DrmStatus removeOfflineLicense(Vector<uint8_t> const &keySetId) = 0;
116     virtual DrmStatus getOfflineLicenseState(Vector<uint8_t> const &keySetId,
117             DrmPlugin::OfflineLicenseState *licenseState) const = 0;
118 
119     virtual DrmStatus getPropertyString(String8 const &name, String8 &value) const = 0;
120     virtual DrmStatus getPropertyByteArray(String8 const &name,
121                                            Vector<uint8_t> &value) const = 0;
122     virtual DrmStatus setPropertyString(String8 const &name,
123                                         String8 const &value ) const = 0;
124     virtual DrmStatus setPropertyByteArray(String8 const &name,
125                                            Vector<uint8_t> const &value) const = 0;
126 
127     virtual DrmStatus getMetrics(const sp<IDrmMetricsConsumer> &consumer) = 0;
128 
129     virtual DrmStatus setCipherAlgorithm(Vector<uint8_t> const &sessionId,
130                                          String8 const &algorithm) = 0;
131 
132     virtual DrmStatus setMacAlgorithm(Vector<uint8_t> const &sessionId,
133                                       String8 const &algorithm) = 0;
134 
135     virtual DrmStatus encrypt(Vector<uint8_t> const &sessionId,
136                               Vector<uint8_t> const &keyId,
137                               Vector<uint8_t> const &input,
138                               Vector<uint8_t> const &iv,
139                               Vector<uint8_t> &output) = 0;
140 
141     virtual DrmStatus decrypt(Vector<uint8_t> const &sessionId,
142                               Vector<uint8_t> const &keyId,
143                               Vector<uint8_t> const &input,
144                               Vector<uint8_t> const &iv,
145                               Vector<uint8_t> &output) = 0;
146 
147     virtual DrmStatus sign(Vector<uint8_t> const &sessionId,
148                            Vector<uint8_t> const &keyId,
149                            Vector<uint8_t> const &message,
150                            Vector<uint8_t> &signature) = 0;
151 
152     virtual DrmStatus verify(Vector<uint8_t> const &sessionId,
153                              Vector<uint8_t> const &keyId,
154                              Vector<uint8_t> const &message,
155                              Vector<uint8_t> const &signature,
156                              bool &match) = 0;
157 
158     virtual DrmStatus signRSA(Vector<uint8_t> const &sessionId,
159                               String8 const &algorithm,
160                               Vector<uint8_t> const &message,
161                               Vector<uint8_t> const &wrappedKey,
162                               Vector<uint8_t> &signature) = 0;
163 
164     virtual DrmStatus setListener(const sp<IDrmClient>& listener) = 0;
165 
166     virtual DrmStatus requiresSecureDecoder(const char *mime, bool *required) const = 0;
167 
168     virtual DrmStatus requiresSecureDecoder(const char *mime,
169                                             DrmPlugin::SecurityLevel securityLevel,
170                                             bool *required) const = 0;
171 
172     virtual DrmStatus setPlaybackId(
173             Vector<uint8_t> const &sessionId,
174             const char *playbackId) = 0;
175 
176     virtual DrmStatus getLogMessages(Vector<drm::V1_4::LogMessage> &logs) const = 0;
177 
178     virtual DrmStatus getSupportedSchemes(std::vector<uint8_t> &schemes) const = 0;
179 
180 protected:
IDrmIDrm181     IDrm() {}
182 
183 private:
184     DISALLOW_EVIL_CONSTRUCTORS(IDrm);
185 };
186 
187 }  // namespace android
188 
189 #endif // ANDROID_IDRM_H_
190