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 | #include "DrmEngineBase.h" |
| 18 | |
| 19 | using namespace android; |
| 20 | |
| 21 | DrmEngineBase::DrmEngineBase() { |
| 22 | |
| 23 | } |
| 24 | |
| 25 | DrmEngineBase::~DrmEngineBase() { |
| 26 | |
| 27 | } |
| 28 | |
| 29 | DrmConstraints* DrmEngineBase::getConstraints( |
| 30 | int uniqueId, const String8* path, int action) { |
| 31 | return onGetConstraints(uniqueId, path, action); |
| 32 | } |
| 33 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 34 | DrmMetadata* DrmEngineBase::getMetadata(int uniqueId, const String8* path) { |
| 35 | return onGetMetadata(uniqueId, path); |
| 36 | } |
| 37 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 38 | status_t DrmEngineBase::initialize(int uniqueId) { |
| 39 | return onInitialize(uniqueId); |
| 40 | } |
| 41 | |
| 42 | status_t DrmEngineBase::setOnInfoListener( |
| 43 | int uniqueId, const IDrmEngine::OnInfoListener* infoListener) { |
| 44 | return onSetOnInfoListener(uniqueId, infoListener); |
| 45 | } |
| 46 | |
| 47 | status_t DrmEngineBase::terminate(int uniqueId) { |
| 48 | return onTerminate(uniqueId); |
| 49 | } |
| 50 | |
| 51 | bool DrmEngineBase::canHandle(int uniqueId, const String8& path) { |
| 52 | return onCanHandle(uniqueId, path); |
| 53 | } |
| 54 | |
| 55 | DrmInfoStatus* DrmEngineBase::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { |
| 56 | return onProcessDrmInfo(uniqueId, drmInfo); |
| 57 | } |
| 58 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 59 | status_t DrmEngineBase::saveRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 60 | int uniqueId, const DrmRights& drmRights, |
| 61 | const String8& rightsPath, const String8& contentPath) { |
| 62 | return onSaveRights(uniqueId, drmRights, rightsPath, contentPath); |
| 63 | } |
| 64 | |
| 65 | DrmInfo* DrmEngineBase::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { |
| 66 | return onAcquireDrmInfo(uniqueId, drmInfoRequest); |
| 67 | } |
| 68 | |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame] | 69 | String8 DrmEngineBase::getOriginalMimeType(int uniqueId, const String8& path, int fd) { |
| 70 | return onGetOriginalMimeType(uniqueId, path, fd); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | int DrmEngineBase::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) { |
| 74 | return onGetDrmObjectType(uniqueId, path, mimeType); |
| 75 | } |
| 76 | |
| 77 | int DrmEngineBase::checkRightsStatus(int uniqueId, const String8& path, int action) { |
| 78 | return onCheckRightsStatus(uniqueId, path, action); |
| 79 | } |
| 80 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 81 | status_t DrmEngineBase::consumeRights( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 82 | int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 83 | return onConsumeRights(uniqueId, decryptHandle, action, reserve); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 84 | } |
| 85 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 86 | status_t DrmEngineBase::setPlaybackStatus( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 87 | int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus, int64_t position) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 88 | return onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | bool DrmEngineBase::validateAction( |
| 92 | int uniqueId, const String8& path, |
| 93 | int action, const ActionDescription& description) { |
| 94 | return onValidateAction(uniqueId, path, action, description); |
| 95 | } |
| 96 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 97 | status_t DrmEngineBase::removeRights(int uniqueId, const String8& path) { |
| 98 | return onRemoveRights(uniqueId, path); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 99 | } |
| 100 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 101 | status_t DrmEngineBase::removeAllRights(int uniqueId) { |
| 102 | return onRemoveAllRights(uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 103 | } |
| 104 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 105 | status_t DrmEngineBase::openConvertSession(int uniqueId, int convertId) { |
| 106 | return onOpenConvertSession(uniqueId, convertId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | DrmConvertedStatus* DrmEngineBase::convertData( |
| 110 | int uniqueId, int convertId, const DrmBuffer* inputData) { |
| 111 | return onConvertData(uniqueId, convertId, inputData); |
| 112 | } |
| 113 | |
| 114 | DrmConvertedStatus* DrmEngineBase::closeConvertSession(int uniqueId, int convertId) { |
| 115 | return onCloseConvertSession(uniqueId, convertId); |
| 116 | } |
| 117 | |
| 118 | DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) { |
| 119 | return onGetSupportInfo(uniqueId); |
| 120 | } |
| 121 | |
| 122 | status_t DrmEngineBase::openDecryptSession( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 123 | int uniqueId, sp<DecryptHandle>& decryptHandle, |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 124 | int fd, off64_t offset, off64_t length, const char* mime) { |
| 125 | |
| 126 | if (!mime || mime[0] == '\0') { |
| 127 | return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length); |
| 128 | } |
| 129 | |
| 130 | return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length, mime); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 131 | } |
| 132 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 133 | status_t DrmEngineBase::openDecryptSession( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 134 | int uniqueId, sp<DecryptHandle>& decryptHandle, |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 135 | const char* uri, const char* mime) { |
| 136 | if (!mime || mime[0] == '\0') { |
| 137 | return onOpenDecryptSession(uniqueId, decryptHandle, uri); |
| 138 | } |
| 139 | return onOpenDecryptSession(uniqueId, decryptHandle, uri, mime); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 140 | } |
| 141 | |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 142 | status_t DrmEngineBase::openDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle, |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 143 | const DrmBuffer& buf, const String8& mimeType) { |
| 144 | return onOpenDecryptSession(uniqueId, decryptHandle, buf, mimeType); |
| 145 | } |
| 146 | |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 147 | status_t DrmEngineBase::closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 148 | return onCloseDecryptSession(uniqueId, decryptHandle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 149 | } |
| 150 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 151 | status_t DrmEngineBase::initializeDecryptUnit( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 152 | int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 153 | return onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | status_t DrmEngineBase::decrypt( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 157 | int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId, |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 158 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
| 159 | return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 160 | } |
| 161 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 162 | status_t DrmEngineBase::finalizeDecryptUnit( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 163 | int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 164 | return onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | ssize_t DrmEngineBase::pread( |
Jeff Tinker | 5d49bef | 2018-10-03 23:01:09 -0700 | [diff] [blame] | 168 | int uniqueId, sp<DecryptHandle>& decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 169 | return onPread(uniqueId, decryptHandle, buffer, numBytes, offset); |
| 170 | } |
| 171 | |