IDrmManagerService.h revision 2272ee27d9022d173b6eab45c409b3c3f57f30ec
1/*
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
28class DrmContentIds;
29class DrmConstraints;
30class 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 {
47        ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
48        REMOVE_UNIQUEID,
49        LOAD_PLUGINS,
50        LOAD_PLUGINS_FROM_PATH,
51        SET_DRM_SERVICE_LISTENER,
52        UNLOAD_PLUGINS,
53        INSTALL_DRM_ENGINE,
54        GET_CONSTRAINTS_FROM_CONTENT,
55        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,
72        CLOSE_DECRYPT_SESSION,
73        INITIALIZE_DECRYPT_UNIT,
74        DECRYPT,
75        FINALIZE_DECRYPT_UNIT,
76        PREAD
77    };
78
79public:
80    DECLARE_META_INTERFACE(DrmManagerService);
81
82public:
83    virtual int addUniqueId(int uniqueId) = 0;
84
85    virtual void removeUniqueId(int uniqueId) = 0;
86
87    virtual status_t loadPlugIns(int uniqueId) = 0;
88
89    virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0;
90
91    virtual status_t setDrmServiceListener(
92            int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
93
94    virtual status_t unloadPlugIns(int uniqueId) = 0;
95
96    virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0;
97
98    virtual DrmConstraints* getConstraints(
99            int uniqueId, const String8* path, const int action) = 0;
100
101    virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType) = 0;
102
103    virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo) = 0;
104
105    virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
106
107    virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
108            const String8& rightsPath, const String8& contentPath) = 0;
109
110    virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
111
112    virtual int getDrmObjectType(
113            int uniqueId, const String8& path, const String8& mimeType) = 0;
114
115    virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
116
117    virtual status_t consumeRights(
118            int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
119
120    virtual status_t setPlaybackStatus(
121            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
122
123    virtual bool validateAction(
124            int uniqueId, const String8& path,
125            int action, const ActionDescription& description) = 0;
126
127    virtual status_t removeRights(int uniqueId, const String8& path) = 0;
128
129    virtual status_t removeAllRights(int uniqueId) = 0;
130
131    virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
132
133    virtual DrmConvertedStatus* convertData(
134            int uniqueId, int convertId, const DrmBuffer* inputData) = 0;
135
136    virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId) = 0;
137
138    virtual status_t getAllSupportInfo(
139            int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
140
141    virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
142
143    virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
144
145    virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
146            int decryptUnitId, const DrmBuffer* headerInfo) = 0;
147
148    virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
149            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
150
151    virtual status_t finalizeDecryptUnit(
152            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
153
154    virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
155            void* buffer, ssize_t numBytes,off_t offset) = 0;
156};
157
158/**
159 * This is the Binder implementation class for DRM Manager service.
160 */
161class BpDrmManagerService: public BpInterface<IDrmManagerService>
162{
163public:
164    BpDrmManagerService(const sp<IBinder>& impl)
165            : BpInterface<IDrmManagerService>(impl) {}
166
167    virtual int addUniqueId(int uniqueId);
168
169    virtual void removeUniqueId(int uniqueId);
170
171    virtual status_t loadPlugIns(int uniqueId);
172
173    virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
174
175    virtual status_t setDrmServiceListener(
176            int uniqueId, const sp<IDrmServiceListener>& infoListener);
177
178    virtual status_t unloadPlugIns(int uniqueId);
179
180    virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
181
182    virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
183
184    virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType);
185
186    virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
187
188    virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
189
190    virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
191            const String8& rightsPath, const String8& contentPath);
192
193    virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
194
195    virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
196
197    virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
198
199    virtual status_t consumeRights(
200            int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
201
202    virtual status_t setPlaybackStatus(
203            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
204
205    virtual bool validateAction(
206            int uniqueId, const String8& path, int action, const ActionDescription& description);
207
208    virtual status_t removeRights(int uniqueId, const String8& path);
209
210    virtual status_t removeAllRights(int uniqueId);
211
212    virtual int openConvertSession(int uniqueId, const String8& mimeType);
213
214    virtual DrmConvertedStatus* convertData(
215            int uniqueId, int convertId, const DrmBuffer* inputData);
216
217    virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
218
219    virtual status_t getAllSupportInfo(
220            int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
221
222    virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
223
224    virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
225
226    virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
227            int decryptUnitId, const DrmBuffer* headerInfo);
228
229    virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
230            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
231
232    virtual status_t finalizeDecryptUnit(
233            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
234
235    virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
236            void* buffer, ssize_t numBytes, off_t offset);
237};
238
239/**
240 * This is the Binder implementation class for DRM Manager service.
241 */
242class BnDrmManagerService: public BnInterface<IDrmManagerService>
243{
244public:
245    virtual status_t onTransact(
246            uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
247};
248
249};
250
251#endif /* __IDRM_MANAGER_SERVICE_H__ */
252
253