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 | #ifndef __DRM_MANAGER_CLIENT_IMPL_H__ |
| 18 | #define __DRM_MANAGER_CLIENT_IMPL_H__ |
| 19 | |
| 20 | #include <binder/IMemory.h> |
| 21 | #include <utils/threads.h> |
| 22 | #include <drm/DrmManagerClient.h> |
| 23 | |
| 24 | #include "IDrmManagerService.h" |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | class DrmInfoEvent; |
| 29 | /** |
| 30 | * This is implementation class for DrmManagerClient class. |
| 31 | * |
| 32 | * Only the JNI layer creates an instance of this class to delegate |
| 33 | * functionality to Native later. |
| 34 | * |
| 35 | */ |
| 36 | class DrmManagerClientImpl : public BnDrmServiceListener { |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 37 | protected: |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 38 | DrmManagerClientImpl() { } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 39 | |
| 40 | public: |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 41 | static DrmManagerClientImpl* create(int* pUniqueId, bool isNative); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 42 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 43 | virtual ~DrmManagerClientImpl() { } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 44 | |
| 45 | public: |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 46 | virtual void remove(int uniqueId); |
| 47 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 48 | /** |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 49 | * Adds the client respective to given unique id. |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 50 | * |
| 51 | * @param[in] uniqueId Unique identifier for a session |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 52 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 53 | virtual void addClient(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 54 | |
| 55 | /** |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 56 | * Removes the client respective to given unique id. |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 57 | * |
| 58 | * @param[in] uniqueId Unique identifier for a session |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 59 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 60 | virtual void removeClient(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Register a callback to be invoked when the caller required to |
| 64 | * receive necessary information |
| 65 | * |
| 66 | * @param[in] uniqueId Unique identifier for a session |
| 67 | * @param[in] infoListener Listener |
| 68 | * @return status_t |
| 69 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
| 70 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 71 | virtual status_t setOnInfoListener( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 72 | int uniqueId, const sp<DrmManagerClient::OnInfoListener>& infoListener); |
| 73 | |
| 74 | /** |
| 75 | * Get constraint information associated with input content |
| 76 | * |
| 77 | * @param[in] uniqueId Unique identifier for a session |
| 78 | * @param[in] path Path of the protected content |
| 79 | * @param[in] action Actions defined such as, |
| 80 | * Action::DEFAULT, Action::PLAY, etc |
| 81 | * @return DrmConstraints |
| 82 | * key-value pairs of constraint are embedded in it |
| 83 | * @note |
| 84 | * In case of error, return NULL |
| 85 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 86 | virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 87 | |
| 88 | /** |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 89 | * Get metadata information associated with input content. |
| 90 | * |
| 91 | * @param[in] uniqueId Unique identifier for a session |
| 92 | * @param[in] path Path of the protected content |
| 93 | * @return DrmMetadata |
| 94 | * key-value pairs of metadata are embedded in it |
| 95 | * @note |
| 96 | * In case of error, return NULL |
| 97 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 98 | virtual DrmMetadata* getMetadata(int uniqueId, const String8* path); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 99 | |
| 100 | /** |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 101 | * Check whether the given mimetype or path can be handled |
| 102 | * |
| 103 | * @param[in] uniqueId Unique identifier for a session |
| 104 | * @param[in] path Path of the content needs to be handled |
| 105 | * @param[in] mimetype Mimetype of the content needs to be handled |
| 106 | * @return |
| 107 | * True if DrmManager can handle given path or mime type. |
| 108 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 109 | virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Executes given drm information based on its type |
| 113 | * |
| 114 | * @param[in] uniqueId Unique identifier for a session |
| 115 | * @param[in] drmInfo Information needs to be processed |
| 116 | * @return DrmInfoStatus |
| 117 | * instance as a result of processing given input |
| 118 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 119 | virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Retrieves necessary information for registration, unregistration or rights |
| 123 | * acquisition information. |
| 124 | * |
| 125 | * @param[in] uniqueId Unique identifier for a session |
| 126 | * @param[in] drmInfoRequest Request information to retrieve drmInfo |
| 127 | * @return DrmInfo |
| 128 | * instance as a result of processing given input |
| 129 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 130 | virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * Save DRM rights to specified rights path |
| 134 | * and make association with content path |
| 135 | * |
| 136 | * @param[in] uniqueId Unique identifier for a session |
| 137 | * @param[in] drmRights DrmRights to be saved |
| 138 | * @param[in] rightsPath File path where rights to be saved |
| 139 | * @param[in] contentPath File path where content was saved |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 140 | * @return status_t |
| 141 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 142 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 143 | virtual status_t saveRights(int uniqueId, const DrmRights& drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 144 | const String8& rightsPath, const String8& contentPath); |
| 145 | |
| 146 | /** |
| 147 | * Retrieves the mime type embedded inside the original content |
| 148 | * |
| 149 | * @param[in] uniqueId Unique identifier for a session |
| 150 | * @param[in] path the path of the protected content |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame] | 151 | * @param[in] fd the file descriptor of the protected content |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 152 | * @return String8 |
| 153 | * Returns mime-type of the original content, such as "video/mpeg" |
| 154 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 155 | virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 156 | |
| 157 | /** |
| 158 | * Retrieves the type of the protected object (content, rights, etc..) |
| 159 | * using specified path or mimetype. At least one parameter should be non null |
| 160 | * to retrieve DRM object type |
| 161 | * |
| 162 | * @param[in] uniqueId Unique identifier for a session |
| 163 | * @param[in] path Path of the content or null. |
| 164 | * @param[in] mimeType Mime type of the content or null. |
| 165 | * @return type of the DRM content, |
| 166 | * such as DrmObjectType::CONTENT, DrmObjectType::RIGHTS_OBJECT |
| 167 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 168 | virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 169 | |
| 170 | /** |
| 171 | * Check whether the given content has valid rights or not |
| 172 | * |
| 173 | * @param[in] uniqueId Unique identifier for a session |
| 174 | * @param[in] path Path of the protected content |
| 175 | * @param[in] action Action to perform (Action::DEFAULT, Action::PLAY, etc) |
| 176 | * @return the status of the rights for the protected content, |
| 177 | * such as RightsStatus::RIGHTS_VALID, RightsStatus::RIGHTS_EXPIRED, etc. |
| 178 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 179 | virtual int checkRightsStatus(int uniqueId, const String8& path, int action); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Consumes the rights for a content. |
| 183 | * If the reserve parameter is true the rights is reserved until the same |
| 184 | * application calls this api again with the reserve parameter set to false. |
| 185 | * |
| 186 | * @param[in] uniqueId Unique identifier for a session |
| 187 | * @param[in] decryptHandle Handle for the decryption session |
| 188 | * @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc) |
| 189 | * @param[in] reserve True if the rights should be reserved. |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 190 | * @return status_t |
| 191 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 192 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 193 | virtual status_t consumeRights(int uniqueId, sp<DecryptHandle> &decryptHandle, int action, bool reserve); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * Informs the DRM engine about the playback actions performed on the DRM files. |
| 197 | * |
| 198 | * @param[in] uniqueId Unique identifier for a session |
| 199 | * @param[in] decryptHandle Handle for the decryption session |
| 200 | * @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE) |
| 201 | * @param[in] position Position in the file (in milliseconds) where the start occurs. |
| 202 | * Only valid together with Playback::START. |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 203 | * @return status_t |
| 204 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 205 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 206 | virtual status_t setPlaybackStatus( |
Gloria Wang | b5ce361 | 2011-02-24 16:40:57 -0800 | [diff] [blame] | 207 | int uniqueId, sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 208 | |
| 209 | /** |
| 210 | * Validates whether an action on the DRM content is allowed or not. |
| 211 | * |
| 212 | * @param[in] uniqueId Unique identifier for a session |
| 213 | * @param[in] path Path of the protected content |
| 214 | * @param[in] action Action to validate (Action::PLAY, Action::TRANSFER, etc) |
| 215 | * @param[in] description Detailed description of the action |
| 216 | * @return true if the action is allowed. |
| 217 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 218 | virtual bool validateAction( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 219 | int uniqueId, const String8& path, int action, const ActionDescription& description); |
| 220 | |
| 221 | /** |
| 222 | * Removes the rights associated with the given protected content |
| 223 | * |
| 224 | * @param[in] uniqueId Unique identifier for a session |
| 225 | * @param[in] path Path of the protected content |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 226 | * @return status_t |
| 227 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 228 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 229 | virtual status_t removeRights(int uniqueId, const String8& path); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 230 | |
| 231 | /** |
| 232 | * Removes all the rights information of each plug-in associated with |
| 233 | * DRM framework. Will be used in master reset |
| 234 | * |
| 235 | * @param[in] uniqueId Unique identifier for a session |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 236 | * @return status_t |
| 237 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 238 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 239 | virtual status_t removeAllRights(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 240 | |
| 241 | /** |
| 242 | * This API is for Forward Lock based DRM scheme. |
| 243 | * Each time the application tries to download a new DRM file |
| 244 | * which needs to be converted, then the application has to |
| 245 | * begin with calling this API. |
| 246 | * |
| 247 | * @param[in] uniqueId Unique identifier for a session |
| 248 | * @param[in] mimeType Description/MIME type of the input data packet |
| 249 | * @return Return handle for the convert session |
| 250 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 251 | virtual int openConvertSession(int uniqueId, const String8& mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 252 | |
| 253 | /** |
| 254 | * Accepts and converts the input data which is part of DRM file. |
| 255 | * The resultant converted data and the status is returned in the DrmConvertedInfo |
| 256 | * object. This method will be called each time there are new block |
| 257 | * of data received by the application. |
| 258 | * |
| 259 | * @param[in] uniqueId Unique identifier for a session |
| 260 | * @param[in] convertId Handle for the convert session |
| 261 | * @param[in] inputData Input Data which need to be converted |
| 262 | * @return Return object contains the status of the data conversion, |
| 263 | * the output converted data and offset. In this case the |
| 264 | * application will ignore the offset information. |
| 265 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 266 | virtual DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 267 | |
| 268 | /** |
| 269 | * Informs the Drm Agent when there is no more data which need to be converted |
| 270 | * or when an error occurs. Upon successful conversion of the complete data, |
| 271 | * the agent will inform that where the header and body signature |
| 272 | * should be added. This signature appending is needed to integrity |
| 273 | * protect the converted file. |
| 274 | * |
| 275 | * @param[in] uniqueId Unique identifier for a session |
| 276 | * @param[in] convertId Handle for the convert session |
| 277 | * @return Return object contains the status of the data conversion, |
| 278 | * the header and body signature data. It also informs |
| 279 | * the application on which offset these signature data |
| 280 | * should be appended. |
| 281 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 282 | virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 283 | |
| 284 | /** |
| 285 | * Retrieves all DrmSupportInfo instance that native DRM framework can handle. |
| 286 | * This interface is meant to be used by JNI layer |
| 287 | * |
| 288 | * @param[in] uniqueId Unique identifier for a session |
| 289 | * @param[out] length Number of elements in drmSupportInfoArray |
| 290 | * @param[out] drmSupportInfoArray Array contains all DrmSupportInfo |
| 291 | * that native DRM framework can handle |
| 292 | * @return status_t |
| 293 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
| 294 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 295 | virtual status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 296 | |
| 297 | /** |
| 298 | * Open the decrypt session to decrypt the given protected content |
| 299 | * |
| 300 | * @param[in] uniqueId Unique identifier for a session |
| 301 | * @param[in] fd File descriptor of the protected content to be decrypted |
| 302 | * @param[in] offset Start position of the content |
| 303 | * @param[in] length The length of the protected content |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 304 | * @param[in] mime The mime type of the protected content if it is not NULL or empty |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 305 | * @return |
| 306 | * Handle for the decryption session |
| 307 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 308 | virtual sp<DecryptHandle> openDecryptSession( |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 309 | int uniqueId, int fd, off64_t offset, off64_t length, const char* mime); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 310 | |
| 311 | /** |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 312 | * Open the decrypt session to decrypt the given protected content |
| 313 | * |
| 314 | * @param[in] uniqueId Unique identifier for a session |
| 315 | * @param[in] uri Path of the protected content to be decrypted |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 316 | * @param[in] mime The mime type of the protected content if it is not NULL or empty |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 317 | * @return |
| 318 | * Handle for the decryption session |
| 319 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 320 | virtual sp<DecryptHandle> openDecryptSession( |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 321 | int uniqueId, const char* uri, const char* mime); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 322 | |
| 323 | /** |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 324 | * Open the decrypt session to decrypt the given protected content |
| 325 | * |
| 326 | * @param[in] uniqueId Unique identifier for a session |
| 327 | * @param[in] buf Data to initiate decrypt session |
| 328 | * @param[in] mimeType Mime type of the protected content |
| 329 | * @return |
| 330 | * Handle for the decryption session |
| 331 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 332 | virtual sp<DecryptHandle> openDecryptSession(int uniqueId, const DrmBuffer& buf, |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 333 | const String8& mimeType); |
| 334 | |
| 335 | /** |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 336 | * Close the decrypt session for the given handle |
| 337 | * |
| 338 | * @param[in] uniqueId Unique identifier for a session |
| 339 | * @param[in] decryptHandle Handle for the decryption session |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 340 | * @return status_t |
| 341 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 342 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 343 | virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle> &decryptHandle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 344 | |
| 345 | /** |
| 346 | * Initialize decryption for the given unit of the protected content |
| 347 | * |
| 348 | * @param[in] uniqueId Unique identifier for a session |
| 349 | * @param[in] decryptHandle Handle for the decryption session |
| 350 | * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID |
| 351 | * @param[in] headerInfo Information for initializing decryption of this decrypUnit |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 352 | * @return status_t |
| 353 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 354 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 355 | virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle> &decryptHandle, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 356 | int decryptUnitId, const DrmBuffer* headerInfo); |
| 357 | |
| 358 | /** |
| 359 | * Decrypt the protected content buffers for the given unit |
| 360 | * This method will be called any number of times, based on number of |
| 361 | * encrypted streams received from application. |
| 362 | * |
| 363 | * @param[in] uniqueId Unique identifier for a session |
| 364 | * @param[in] decryptHandle Handle for the decryption session |
| 365 | * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID |
| 366 | * @param[in] encBuffer Encrypted data block |
| 367 | * @param[out] decBuffer Decrypted data block |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 368 | * @param[in] IV Optional buffer |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 369 | * @return status_t |
| 370 | * Returns the error code for this API |
| 371 | * DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED |
| 372 | * DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED, |
| 373 | * DRM_ERROR_DECRYPT for failure. |
| 374 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 375 | virtual status_t decrypt(int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId, |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 376 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 377 | |
| 378 | /** |
| 379 | * Finalize decryption for the given unit of the protected content |
| 380 | * |
| 381 | * @param[in] uniqueId Unique identifier for a session |
| 382 | * @param[in] decryptHandle Handle for the decryption session |
| 383 | * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 384 | * @return status_t |
| 385 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 386 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 387 | virtual status_t finalizeDecryptUnit(int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 388 | |
| 389 | /** |
| 390 | * Reads the specified number of bytes from an open DRM file. |
| 391 | * |
| 392 | * @param[in] uniqueId Unique identifier for a session |
| 393 | * @param[in] decryptHandle Handle for the decryption session |
| 394 | * @param[out] buffer Reference to the buffer that should receive the read data. |
| 395 | * @param[in] numBytes Number of bytes to read. |
| 396 | * @param[in] offset Offset with which to update the file position. |
| 397 | * |
| 398 | * @return Number of bytes read. Returns -1 for Failure. |
| 399 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 400 | virtual ssize_t pread(int uniqueId, sp<DecryptHandle> &decryptHandle, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 401 | void* buffer, ssize_t numBytes, off64_t offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 402 | |
| 403 | /** |
| 404 | * Notify the event to the registered listener |
| 405 | * |
| 406 | * @param[in] event The event to be notified |
| 407 | * @return status_t |
| 408 | * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure |
| 409 | */ |
Adam Lesinski | 927634a | 2014-06-04 15:14:03 -0700 | [diff] [blame] | 410 | virtual status_t notify(const DrmInfoEvent& event); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 411 | |
| 412 | private: |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 413 | Mutex mLock; |
| 414 | sp<DrmManagerClient::OnInfoListener> mOnInfoListener; |
| 415 | |
Gloria Wang | 8d2577b | 2011-03-15 10:52:28 -0700 | [diff] [blame] | 416 | class DeathNotifier: public IBinder::DeathRecipient { |
| 417 | public: |
| 418 | DeathNotifier() {} |
| 419 | virtual ~DeathNotifier(); |
| 420 | virtual void binderDied(const wp<IBinder>& who); |
| 421 | }; |
| 422 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 423 | private: |
Gloria Wang | 8d2577b | 2011-03-15 10:52:28 -0700 | [diff] [blame] | 424 | static Mutex sMutex; |
| 425 | static sp<DeathNotifier> sDeathNotifier; |
| 426 | static sp<IDrmManagerService> sDrmManagerService; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 427 | static const sp<IDrmManagerService>& getDrmManagerService(); |
| 428 | static const String8 EMPTY_STRING; |
| 429 | }; |
| 430 | |
| 431 | }; |
| 432 | |
| 433 | #endif /* __DRM_MANAGER_CLIENT_IMPL_H__ */ |
| 434 | |