blob: 7b518226305a445d6098a6dad247f3387c870088 [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
aimitakeshid074e302010-07-29 10:12:27 +090017#include <utils/String8.h>
18#include <binder/IServiceManager.h>
19#include <drm/DrmManagerClient.h>
20
21#include "DrmManagerClientImpl.h"
22
23using namespace android;
24
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090025DrmManagerClient::DrmManagerClient():
26 mUniqueId(0), mDrmManagerClientImpl(NULL) {
27 mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId);
28 mDrmManagerClientImpl->addClient(mUniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090029}
30
31DrmManagerClient::~DrmManagerClient() {
aimitakeshid074e302010-07-29 10:12:27 +090032 DrmManagerClientImpl::remove(mUniqueId);
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090033 mDrmManagerClientImpl->removeClient(mUniqueId);
Takeshi Aimif05913a2010-11-30 16:27:42 +090034 mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
aimitakeshid074e302010-07-29 10:12:27 +090035 delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
36}
37
aimitakeshid074e302010-07-29 10:12:27 +090038status_t DrmManagerClient::setOnInfoListener(
39 const sp<DrmManagerClient::OnInfoListener>& infoListener) {
40 return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
41}
42
aimitakeshid074e302010-07-29 10:12:27 +090043DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
44 return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
45}
46
Takeshi Aimidc9186562010-11-16 13:56:11 +090047DrmMetadata* DrmManagerClient::getMetadata(const String8* path) {
48 return mDrmManagerClientImpl->getMetadata(mUniqueId, path);
49}
50
aimitakeshid074e302010-07-29 10:12:27 +090051bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) {
52 return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType);
53}
54
55DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) {
56 return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo);
57}
58
59DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) {
60 return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
61}
62
Takeshi Aimidc549d62010-09-20 23:40:41 +090063status_t DrmManagerClient::saveRights(
aimitakeshid074e302010-07-29 10:12:27 +090064 const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
65 return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
66}
67
68String8 DrmManagerClient::getOriginalMimeType(const String8& path) {
69 return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path);
70}
71
72int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) {
73 return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType);
74}
75
76int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
77 return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
78}
79
Takeshi Aimidc549d62010-09-20 23:40:41 +090080status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090081 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +090082 return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
aimitakeshid074e302010-07-29 10:12:27 +090083}
84
Takeshi Aimidc549d62010-09-20 23:40:41 +090085status_t DrmManagerClient::setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -080086 DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
Takeshi Aimidc549d62010-09-20 23:40:41 +090087 return mDrmManagerClientImpl
88 ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
aimitakeshid074e302010-07-29 10:12:27 +090089}
90
91bool DrmManagerClient::validateAction(
92 const String8& path, int action, const ActionDescription& description) {
93 return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
94}
95
Takeshi Aimidc549d62010-09-20 23:40:41 +090096status_t DrmManagerClient::removeRights(const String8& path) {
97 return mDrmManagerClientImpl->removeRights(mUniqueId, path);
aimitakeshid074e302010-07-29 10:12:27 +090098}
99
Takeshi Aimidc549d62010-09-20 23:40:41 +0900100status_t DrmManagerClient::removeAllRights() {
101 return mDrmManagerClientImpl->removeAllRights(mUniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900102}
103
104int DrmManagerClient::openConvertSession(const String8& mimeType) {
105 return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType);
106}
107
108DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) {
109 return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData);
110}
111
112DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) {
113 return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId);
114}
115
116status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) {
117 return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
118}
119
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800120DecryptHandle* DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
aimitakeshid074e302010-07-29 10:12:27 +0900121 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
122}
123
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900124DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) {
125 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
126}
127
Takeshi Aimidc549d62010-09-20 23:40:41 +0900128status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
129 return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900130}
131
Takeshi Aimidc549d62010-09-20 23:40:41 +0900132status_t DrmManagerClient::initializeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900133 DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900134 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +0900135 return mDrmManagerClientImpl->initializeDecryptUnit(
136 mUniqueId, decryptHandle, decryptUnitId, headerInfo);
aimitakeshid074e302010-07-29 10:12:27 +0900137}
138
139status_t DrmManagerClient::decrypt(
140 DecryptHandle* decryptHandle, int decryptUnitId,
Takeshi Aimidc549d62010-09-20 23:40:41 +0900141 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900142 Mutex::Autolock _l(mDecryptLock);
aimitakeshid074e302010-07-29 10:12:27 +0900143 return mDrmManagerClientImpl->decrypt(
Takeshi Aimidc549d62010-09-20 23:40:41 +0900144 mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
aimitakeshid074e302010-07-29 10:12:27 +0900145}
146
Takeshi Aimidc549d62010-09-20 23:40:41 +0900147status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900148 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +0900149 return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
aimitakeshid074e302010-07-29 10:12:27 +0900150}
151
152ssize_t DrmManagerClient::pread(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800153 DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900154 Mutex::Autolock _l(mDecryptLock);
aimitakeshid074e302010-07-29 10:12:27 +0900155 return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
156}
157