blob: 227496a8bac026176567c0dbb7a0d4b9d91d13e1 [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 __DRM_MANAGER_SERVICE_H__
18#define __DRM_MANAGER_SERVICE_H__
19
20#include <utils/RefBase.h>
21#include <utils/KeyedVector.h>
22#include <binder/IInterface.h>
23#include <binder/Parcel.h>
24#include "IDrmManagerService.h"
25#include "IDrmServiceListener.h"
26
27namespace android {
28
29class DrmManager;
30class String8;
31class Mutex;
32
33/**
34 * This is the implementation class for DRM manager service. This delegates
35 * the responsibility to DrmManager.
36 *
37 * The instance of this class is created while starting the DRM manager service.
38 *
39 */
40class DrmManagerService : public BnDrmManagerService {
41public:
42 static void instantiate();
43
44private:
45 DrmManagerService();
46 virtual ~DrmManagerService();
47
48public:
Takeshi Aimidc549d62010-09-20 23:40:41 +090049 int addUniqueId(int uniqueId);
50
51 void removeUniqueId(int uniqueId);
52
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090053 void addClient(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090054
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090055 void removeClient(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090056
57 status_t setDrmServiceListener(
58 int uniqueId, const sp<IDrmServiceListener>& drmServiceListener);
59
aimitakeshid074e302010-07-29 10:12:27 +090060 status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
61
62 DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
63
Takeshi Aimidc9186562010-11-16 13:56:11 +090064 DrmMetadata* getMetadata(int uniqueId, const String8* path);
65
aimitakeshid074e302010-07-29 10:12:27 +090066 bool canHandle(int uniqueId, const String8& path, const String8& mimeType);
67
68 DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
69
70 DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
71
Takeshi Aimidc549d62010-09-20 23:40:41 +090072 status_t saveRights(int uniqueId, const DrmRights& drmRights,
aimitakeshid074e302010-07-29 10:12:27 +090073 const String8& rightsPath, const String8& contentPath);
74
75 String8 getOriginalMimeType(int uniqueId, const String8& path);
76
77 int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
78
79 int checkRightsStatus(int uniqueId, const String8& path,int action);
80
Takeshi Aimidc549d62010-09-20 23:40:41 +090081 status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
aimitakeshid074e302010-07-29 10:12:27 +090082
Takeshi Aimidc549d62010-09-20 23:40:41 +090083 status_t setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -080084 int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
aimitakeshid074e302010-07-29 10:12:27 +090085
86 bool validateAction(int uniqueId, const String8& path,
87 int action, const ActionDescription& description);
88
Takeshi Aimidc549d62010-09-20 23:40:41 +090089 status_t removeRights(int uniqueId, const String8& path);
aimitakeshid074e302010-07-29 10:12:27 +090090
Takeshi Aimidc549d62010-09-20 23:40:41 +090091 status_t removeAllRights(int uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090092
93 int openConvertSession(int uniqueId, const String8& mimeType);
94
95 DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData);
96
97 DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
98
99 status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
100
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800101 DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
aimitakeshid074e302010-07-29 10:12:27 +0900102
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900103 DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
104
Takeshi Aimidc549d62010-09-20 23:40:41 +0900105 status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900106
Takeshi Aimidc549d62010-09-20 23:40:41 +0900107 status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
aimitakeshid074e302010-07-29 10:12:27 +0900108 int decryptUnitId, const DrmBuffer* headerInfo);
109
Takeshi Aimidc549d62010-09-20 23:40:41 +0900110 status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
111 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
aimitakeshid074e302010-07-29 10:12:27 +0900112
Takeshi Aimidc549d62010-09-20 23:40:41 +0900113 status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
aimitakeshid074e302010-07-29 10:12:27 +0900114
115 ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800116 void* buffer, ssize_t numBytes, off64_t offset);
aimitakeshid074e302010-07-29 10:12:27 +0900117
James Donged732462011-03-14 17:01:38 -0700118 virtual status_t dump(int fd, const Vector<String16>& args);
119
aimitakeshid074e302010-07-29 10:12:27 +0900120private:
121 DrmManager* mDrmManager;
122};
123
124};
125
126#endif /* __DRM_MANAGER_SERVICE_H__ */
127