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_SERVICE_H__ |
| 18 | #define __DRM_MANAGER_SERVICE_H__ |
| 19 | |
| 20 | #include <utils/RefBase.h> |
| 21 | #include <utils/KeyedVector.h> |
| 22 | #include <binder/IInterface.h> |
| 23 | #include <binder/Parcel.h> |
| 24 | #include "IDrmManagerService.h" |
| 25 | #include "IDrmServiceListener.h" |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class DrmManager; |
| 30 | class String8; |
| 31 | class Mutex; |
| 32 | |
| 33 | /** |
| 34 | * This is the implementation class for DRM manager service. This delegates |
| 35 | * the responsibility to DrmManager. |
| 36 | * |
| 37 | * The instance of this class is created while starting the DRM manager service. |
| 38 | * |
| 39 | */ |
| 40 | class DrmManagerService : public BnDrmManagerService { |
| 41 | public: |
| 42 | static void instantiate(); |
| 43 | |
| 44 | private: |
| 45 | DrmManagerService(); |
| 46 | virtual ~DrmManagerService(); |
| 47 | |
| 48 | public: |
| 49 | status_t loadPlugIns(int uniqueId); |
| 50 | |
| 51 | status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); |
| 52 | |
| 53 | status_t setDrmServiceListener( |
| 54 | int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); |
| 55 | |
| 56 | status_t unloadPlugIns(int uniqueId); |
| 57 | |
| 58 | status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); |
| 59 | |
| 60 | DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); |
| 61 | |
| 62 | bool canHandle(int uniqueId, const String8& path, const String8& mimeType); |
| 63 | |
| 64 | DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo); |
| 65 | |
| 66 | DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest); |
| 67 | |
| 68 | void saveRights(int uniqueId, const DrmRights& drmRights, |
| 69 | const String8& rightsPath, const String8& contentPath); |
| 70 | |
| 71 | String8 getOriginalMimeType(int uniqueId, const String8& path); |
| 72 | |
| 73 | int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType); |
| 74 | |
| 75 | int checkRightsStatus(int uniqueId, const String8& path,int action); |
| 76 | |
| 77 | void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); |
| 78 | |
| 79 | void setPlaybackStatus( |
| 80 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); |
| 81 | |
| 82 | bool validateAction(int uniqueId, const String8& path, |
| 83 | int action, const ActionDescription& description); |
| 84 | |
| 85 | void removeRights(int uniqueId, const String8& path); |
| 86 | |
| 87 | void removeAllRights(int uniqueId); |
| 88 | |
| 89 | int openConvertSession(int uniqueId, const String8& mimeType); |
| 90 | |
| 91 | DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData); |
| 92 | |
| 93 | DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId); |
| 94 | |
| 95 | status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); |
| 96 | |
| 97 | DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); |
| 98 | |
| 99 | void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); |
| 100 | |
| 101 | void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, |
| 102 | int decryptUnitId, const DrmBuffer* headerInfo); |
| 103 | |
| 104 | status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, |
| 105 | int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer); |
| 106 | |
| 107 | void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); |
| 108 | |
| 109 | ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, |
| 110 | void* buffer, ssize_t numBytes, off_t offset); |
| 111 | |
| 112 | private: |
| 113 | DrmManager* mDrmManager; |
| 114 | }; |
| 115 | |
| 116 | }; |
| 117 | |
| 118 | #endif /* __DRM_MANAGER_SERVICE_H__ */ |
| 119 | |