blob: 0cbbbd4ef0f84427403b29198d1d95d219c0b003 [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);
aimitakeshid074e302010-07-29 10:12:27 +090034 delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
35}
36
aimitakeshid074e302010-07-29 10:12:27 +090037status_t DrmManagerClient::setOnInfoListener(
38 const sp<DrmManagerClient::OnInfoListener>& infoListener) {
39 return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
40}
41
aimitakeshid074e302010-07-29 10:12:27 +090042DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
43 return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
44}
45
46bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) {
47 return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType);
48}
49
50DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) {
51 return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo);
52}
53
54DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) {
55 return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
56}
57
Takeshi Aimidc549d62010-09-20 23:40:41 +090058status_t DrmManagerClient::saveRights(
aimitakeshid074e302010-07-29 10:12:27 +090059 const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
60 return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
61}
62
63String8 DrmManagerClient::getOriginalMimeType(const String8& path) {
64 return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path);
65}
66
67int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) {
68 return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType);
69}
70
71int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
72 return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
73}
74
Takeshi Aimidc549d62010-09-20 23:40:41 +090075status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090076 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +090077 return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
aimitakeshid074e302010-07-29 10:12:27 +090078}
79
Takeshi Aimidc549d62010-09-20 23:40:41 +090080status_t DrmManagerClient::setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -080081 DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
Takeshi Aimidc549d62010-09-20 23:40:41 +090082 return mDrmManagerClientImpl
83 ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
aimitakeshid074e302010-07-29 10:12:27 +090084}
85
86bool DrmManagerClient::validateAction(
87 const String8& path, int action, const ActionDescription& description) {
88 return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
89}
90
Takeshi Aimidc549d62010-09-20 23:40:41 +090091status_t DrmManagerClient::removeRights(const String8& path) {
92 return mDrmManagerClientImpl->removeRights(mUniqueId, path);
aimitakeshid074e302010-07-29 10:12:27 +090093}
94
Takeshi Aimidc549d62010-09-20 23:40:41 +090095status_t DrmManagerClient::removeAllRights() {
96 return mDrmManagerClientImpl->removeAllRights(mUniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090097}
98
99int DrmManagerClient::openConvertSession(const String8& mimeType) {
100 return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType);
101}
102
103DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) {
104 return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData);
105}
106
107DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) {
108 return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId);
109}
110
111status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) {
112 return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
113}
114
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800115DecryptHandle* DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
aimitakeshid074e302010-07-29 10:12:27 +0900116 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
117}
118
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900119DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) {
120 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
121}
122
Takeshi Aimidc549d62010-09-20 23:40:41 +0900123status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
124 return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900125}
126
Takeshi Aimidc549d62010-09-20 23:40:41 +0900127status_t DrmManagerClient::initializeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900128 DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900129 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +0900130 return mDrmManagerClientImpl->initializeDecryptUnit(
131 mUniqueId, decryptHandle, decryptUnitId, headerInfo);
aimitakeshid074e302010-07-29 10:12:27 +0900132}
133
134status_t DrmManagerClient::decrypt(
135 DecryptHandle* decryptHandle, int decryptUnitId,
Takeshi Aimidc549d62010-09-20 23:40:41 +0900136 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900137 Mutex::Autolock _l(mDecryptLock);
aimitakeshid074e302010-07-29 10:12:27 +0900138 return mDrmManagerClientImpl->decrypt(
Takeshi Aimidc549d62010-09-20 23:40:41 +0900139 mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
aimitakeshid074e302010-07-29 10:12:27 +0900140}
141
Takeshi Aimidc549d62010-09-20 23:40:41 +0900142status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900143 Mutex::Autolock _l(mDecryptLock);
Takeshi Aimidc549d62010-09-20 23:40:41 +0900144 return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
aimitakeshid074e302010-07-29 10:12:27 +0900145}
146
147ssize_t DrmManagerClient::pread(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800148 DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) {
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900149 Mutex::Autolock _l(mDecryptLock);
aimitakeshid074e302010-07-29 10:12:27 +0900150 return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
151}
152