aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame^] | 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 | #define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "DrmManagerClient(Native)" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <utils/String8.h> |
| 22 | #include <binder/IServiceManager.h> |
| 23 | #include <drm/DrmManagerClient.h> |
| 24 | |
| 25 | #include "DrmManagerClientImpl.h" |
| 26 | |
| 27 | using namespace android; |
| 28 | |
| 29 | DrmManagerClient::DrmManagerClient() { |
| 30 | int uniqueId = 0; |
| 31 | mDrmManagerClientImpl = NULL; |
| 32 | |
| 33 | mDrmManagerClientImpl = DrmManagerClientImpl::create(&uniqueId); |
| 34 | mUniqueId = uniqueId; |
| 35 | |
| 36 | loadPlugIns(); |
| 37 | } |
| 38 | |
| 39 | DrmManagerClient::~DrmManagerClient() { |
| 40 | unloadPlugIns(); |
| 41 | DrmManagerClientImpl::remove(mUniqueId); |
| 42 | |
| 43 | delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL; |
| 44 | } |
| 45 | |
| 46 | status_t DrmManagerClient::loadPlugIns() { |
| 47 | return mDrmManagerClientImpl->loadPlugIns(mUniqueId); |
| 48 | } |
| 49 | |
| 50 | status_t DrmManagerClient::setOnInfoListener( |
| 51 | const sp<DrmManagerClient::OnInfoListener>& infoListener) { |
| 52 | return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener); |
| 53 | } |
| 54 | |
| 55 | status_t DrmManagerClient::unloadPlugIns() { |
| 56 | return mDrmManagerClientImpl->unloadPlugIns(mUniqueId); |
| 57 | } |
| 58 | |
| 59 | DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) { |
| 60 | return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action); |
| 61 | } |
| 62 | |
| 63 | bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) { |
| 64 | return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType); |
| 65 | } |
| 66 | |
| 67 | DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) { |
| 68 | return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo); |
| 69 | } |
| 70 | |
| 71 | DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) { |
| 72 | return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest); |
| 73 | } |
| 74 | |
| 75 | void DrmManagerClient::saveRights( |
| 76 | const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) { |
| 77 | return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath); |
| 78 | } |
| 79 | |
| 80 | String8 DrmManagerClient::getOriginalMimeType(const String8& path) { |
| 81 | return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path); |
| 82 | } |
| 83 | |
| 84 | int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) { |
| 85 | return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType); |
| 86 | } |
| 87 | |
| 88 | int DrmManagerClient::checkRightsStatus(const String8& path, int action) { |
| 89 | return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action); |
| 90 | } |
| 91 | |
| 92 | void DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) { |
| 93 | mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); |
| 94 | } |
| 95 | |
| 96 | void DrmManagerClient::setPlaybackStatus( |
| 97 | DecryptHandle* decryptHandle, int playbackStatus, int position) { |
| 98 | mDrmManagerClientImpl->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position); |
| 99 | } |
| 100 | |
| 101 | bool DrmManagerClient::validateAction( |
| 102 | const String8& path, int action, const ActionDescription& description) { |
| 103 | return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description); |
| 104 | } |
| 105 | |
| 106 | void DrmManagerClient::removeRights(const String8& path) { |
| 107 | mDrmManagerClientImpl->removeRights(mUniqueId, path); |
| 108 | } |
| 109 | |
| 110 | void DrmManagerClient::removeAllRights() { |
| 111 | mDrmManagerClientImpl->removeAllRights(mUniqueId); |
| 112 | } |
| 113 | |
| 114 | int DrmManagerClient::openConvertSession(const String8& mimeType) { |
| 115 | return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType); |
| 116 | } |
| 117 | |
| 118 | DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) { |
| 119 | return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData); |
| 120 | } |
| 121 | |
| 122 | DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) { |
| 123 | return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId); |
| 124 | } |
| 125 | |
| 126 | status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) { |
| 127 | return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray); |
| 128 | } |
| 129 | |
| 130 | DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int length) { |
| 131 | return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); |
| 132 | } |
| 133 | |
| 134 | void DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) { |
| 135 | mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle); |
| 136 | } |
| 137 | |
| 138 | void DrmManagerClient::initializeDecryptUnit( |
| 139 | DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { |
| 140 | mDrmManagerClientImpl->initializeDecryptUnit( |
| 141 | mUniqueId, decryptHandle, decryptUnitId, headerInfo); |
| 142 | } |
| 143 | |
| 144 | status_t DrmManagerClient::decrypt( |
| 145 | DecryptHandle* decryptHandle, int decryptUnitId, |
| 146 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer) { |
| 147 | return mDrmManagerClientImpl->decrypt( |
| 148 | mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer); |
| 149 | } |
| 150 | |
| 151 | void DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) { |
| 152 | mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId); |
| 153 | } |
| 154 | |
| 155 | ssize_t DrmManagerClient::pread( |
| 156 | DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) { |
| 157 | return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset); |
| 158 | } |
| 159 | |