blob: 7727e551a5efaa1662b1bbeb9246b25317801e2e [file] [log] [blame]
aimitakeshid074e302010-07-29 10:12:27 +09001/*
2 * Copyright (C) 2010 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#ifndef __IDRM_MANAGER_SERVICE_H__
18#define __IDRM_MANAGER_SERVICE_H__
19
20#include <utils/RefBase.h>
21#include <binder/IInterface.h>
22#include <binder/Parcel.h>
23#include <drm/drm_framework_common.h>
24#include "IDrmServiceListener.h"
25
26namespace android {
27
aimitakeshid074e302010-07-29 10:12:27 +090028class DrmConstraints;
Takeshi Aimidc9186562010-11-16 13:56:11 +090029class DrmMetadata;
aimitakeshid074e302010-07-29 10:12:27 +090030class DrmRights;
31class DrmInfo;
32class DrmInfoStatus;
33class DrmInfoRequest;
34class DrmSupportInfo;
35class DrmConvertedStatus;
36class String8;
37class ActionDescription;
38
39/**
40 * This is the interface class for DRM Manager service.
41 *
42 */
43class IDrmManagerService : public IInterface
44{
45public:
46 enum {
Takeshi Aimidc549d62010-09-20 23:40:41 +090047 ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
48 REMOVE_UNIQUEID,
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090049 ADD_CLIENT,
50 REMOVE_CLIENT,
aimitakeshid074e302010-07-29 10:12:27 +090051 SET_DRM_SERVICE_LISTENER,
aimitakeshid074e302010-07-29 10:12:27 +090052 INSTALL_DRM_ENGINE,
53 GET_CONSTRAINTS_FROM_CONTENT,
Takeshi Aimidc9186562010-11-16 13:56:11 +090054 GET_METADATA_FROM_CONTENT,
aimitakeshid074e302010-07-29 10:12:27 +090055 CAN_HANDLE,
56 PROCESS_DRM_INFO,
57 ACQUIRE_DRM_INFO,
58 SAVE_RIGHTS,
59 GET_ORIGINAL_MIMETYPE,
60 GET_DRM_OBJECT_TYPE,
61 CHECK_RIGHTS_STATUS,
62 CONSUME_RIGHTS,
63 SET_PLAYBACK_STATUS,
64 VALIDATE_ACTION,
65 REMOVE_RIGHTS,
66 REMOVE_ALL_RIGHTS,
67 OPEN_CONVERT_SESSION,
68 CONVERT_DATA,
69 CLOSE_CONVERT_SESSION,
70 GET_ALL_SUPPORT_INFO,
71 OPEN_DECRYPT_SESSION,
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090072 OPEN_DECRYPT_SESSION_FROM_URI,
aimitakeshid074e302010-07-29 10:12:27 +090073 CLOSE_DECRYPT_SESSION,
74 INITIALIZE_DECRYPT_UNIT,
75 DECRYPT,
76 FINALIZE_DECRYPT_UNIT,
77 PREAD
78 };
79
80public:
81 DECLARE_META_INTERFACE(DrmManagerService);
82
83public:
Takeshi Aimidc549d62010-09-20 23:40:41 +090084 virtual int addUniqueId(int uniqueId) = 0;
85
86 virtual void removeUniqueId(int uniqueId) = 0;
87
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090088 virtual void addClient(int uniqueId) = 0;
aimitakeshid074e302010-07-29 10:12:27 +090089
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090090 virtual void removeClient(int uniqueId) = 0;
aimitakeshid074e302010-07-29 10:12:27 +090091
92 virtual status_t setDrmServiceListener(
93 int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
94
aimitakeshid074e302010-07-29 10:12:27 +090095 virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0;
96
97 virtual DrmConstraints* getConstraints(
98 int uniqueId, const String8* path, const int action) = 0;
99
Takeshi Aimidc9186562010-11-16 13:56:11 +0900100 virtual DrmMetadata* getMetadata(int uniqueId, const String8* path) = 0;
101
aimitakeshid074e302010-07-29 10:12:27 +0900102 virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType) = 0;
103
104 virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo) = 0;
105
106 virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
107
Takeshi Aimidc549d62010-09-20 23:40:41 +0900108 virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
aimitakeshid074e302010-07-29 10:12:27 +0900109 const String8& rightsPath, const String8& contentPath) = 0;
110
111 virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
112
113 virtual int getDrmObjectType(
114 int uniqueId, const String8& path, const String8& mimeType) = 0;
115
116 virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
117
Takeshi Aimidc549d62010-09-20 23:40:41 +0900118 virtual status_t consumeRights(
aimitakeshid074e302010-07-29 10:12:27 +0900119 int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
120
Takeshi Aimidc549d62010-09-20 23:40:41 +0900121 virtual status_t setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800122 int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900123
124 virtual bool validateAction(
125 int uniqueId, const String8& path,
126 int action, const ActionDescription& description) = 0;
127
Takeshi Aimidc549d62010-09-20 23:40:41 +0900128 virtual status_t removeRights(int uniqueId, const String8& path) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900129
Takeshi Aimidc549d62010-09-20 23:40:41 +0900130 virtual status_t removeAllRights(int uniqueId) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900131
132 virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
133
134 virtual DrmConvertedStatus* convertData(
135 int uniqueId, int convertId, const DrmBuffer* inputData) = 0;
136
137 virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId) = 0;
138
139 virtual status_t getAllSupportInfo(
140 int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
141
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800142 virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900143
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900144 virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
145
Takeshi Aimidc549d62010-09-20 23:40:41 +0900146 virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900147
Takeshi Aimidc549d62010-09-20 23:40:41 +0900148 virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
aimitakeshid074e302010-07-29 10:12:27 +0900149 int decryptUnitId, const DrmBuffer* headerInfo) = 0;
150
Takeshi Aimidc549d62010-09-20 23:40:41 +0900151 virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
152 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900153
Takeshi Aimidc549d62010-09-20 23:40:41 +0900154 virtual status_t finalizeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900155 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
156
157 virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800158 void* buffer, ssize_t numBytes,off64_t offset) = 0;
aimitakeshid074e302010-07-29 10:12:27 +0900159};
160
161/**
162 * This is the Binder implementation class for DRM Manager service.
163 */
164class BpDrmManagerService: public BpInterface<IDrmManagerService>
165{
166public:
167 BpDrmManagerService(const sp<IBinder>& impl)
168 : BpInterface<IDrmManagerService>(impl) {}
169
Takeshi Aimidc549d62010-09-20 23:40:41 +0900170 virtual int addUniqueId(int uniqueId);
171
172 virtual void removeUniqueId(int uniqueId);
173
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900174 virtual void addClient(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900175
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900176 virtual void removeClient(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900177
178 virtual status_t setDrmServiceListener(
179 int uniqueId, const sp<IDrmServiceListener>& infoListener);
180
aimitakeshid074e302010-07-29 10:12:27 +0900181 virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
182
183 virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
184
Takeshi Aimidc9186562010-11-16 13:56:11 +0900185 virtual DrmMetadata* getMetadata(int uniqueId, const String8* path);
186
aimitakeshid074e302010-07-29 10:12:27 +0900187 virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType);
188
189 virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
190
191 virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
192
Takeshi Aimidc549d62010-09-20 23:40:41 +0900193 virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
aimitakeshid074e302010-07-29 10:12:27 +0900194 const String8& rightsPath, const String8& contentPath);
195
196 virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
197
198 virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
199
200 virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
201
Takeshi Aimidc549d62010-09-20 23:40:41 +0900202 virtual status_t consumeRights(
aimitakeshid074e302010-07-29 10:12:27 +0900203 int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
204
Takeshi Aimidc549d62010-09-20 23:40:41 +0900205 virtual status_t setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800206 int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
aimitakeshid074e302010-07-29 10:12:27 +0900207
208 virtual bool validateAction(
209 int uniqueId, const String8& path, int action, const ActionDescription& description);
210
Takeshi Aimidc549d62010-09-20 23:40:41 +0900211 virtual status_t removeRights(int uniqueId, const String8& path);
aimitakeshid074e302010-07-29 10:12:27 +0900212
Takeshi Aimidc549d62010-09-20 23:40:41 +0900213 virtual status_t removeAllRights(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900214
215 virtual int openConvertSession(int uniqueId, const String8& mimeType);
216
217 virtual DrmConvertedStatus* convertData(
218 int uniqueId, int convertId, const DrmBuffer* inputData);
219
220 virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
221
222 virtual status_t getAllSupportInfo(
223 int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
224
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800225 virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
aimitakeshid074e302010-07-29 10:12:27 +0900226
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900227 virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
228
Takeshi Aimidc549d62010-09-20 23:40:41 +0900229 virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900230
Takeshi Aimidc549d62010-09-20 23:40:41 +0900231 virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
aimitakeshid074e302010-07-29 10:12:27 +0900232 int decryptUnitId, const DrmBuffer* headerInfo);
233
Takeshi Aimidc549d62010-09-20 23:40:41 +0900234 virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
235 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
aimitakeshid074e302010-07-29 10:12:27 +0900236
Takeshi Aimidc549d62010-09-20 23:40:41 +0900237 virtual status_t finalizeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900238 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
239
240 virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800241 void* buffer, ssize_t numBytes, off64_t offset);
aimitakeshid074e302010-07-29 10:12:27 +0900242};
243
244/**
245 * This is the Binder implementation class for DRM Manager service.
246 */
247class BnDrmManagerService: public BnInterface<IDrmManagerService>
248{
249public:
250 virtual status_t onTransact(
251 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
252};
253
254};
255
256#endif /* __IDRM_MANAGER_SERVICE_H__ */
257