| 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: | 
| Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 49 |     int addUniqueId(bool isNative); | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 50 |  | 
 | 51 |     void removeUniqueId(int uniqueId); | 
 | 52 |  | 
| Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 53 |     void addClient(int uniqueId); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 54 |  | 
| Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 55 |     void removeClient(int uniqueId); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 56 |  | 
 | 57 |     status_t setDrmServiceListener( | 
 | 58 |             int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); | 
 | 59 |  | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 60 |     DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); | 
 | 61 |  | 
| Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 62 |     DrmMetadata* getMetadata(int uniqueId, const String8* path); | 
 | 63 |  | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 64 |     bool canHandle(int uniqueId, const String8& path, const String8& mimeType); | 
 | 65 |  | 
 | 66 |     DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo); | 
 | 67 |  | 
 | 68 |     DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest); | 
 | 69 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 70 |     status_t saveRights(int uniqueId, const DrmRights& drmRights, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 71 |             const String8& rightsPath, const String8& contentPath); | 
 | 72 |  | 
| James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame] | 73 |     String8 getOriginalMimeType(int uniqueId, const String8& path, int fd); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 74 |  | 
 | 75 |     int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType); | 
 | 76 |  | 
 | 77 |     int checkRightsStatus(int uniqueId, const String8& path,int action); | 
 | 78 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 79 |     status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 80 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 81 |     status_t setPlaybackStatus( | 
| Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 82 |             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 83 |  | 
 | 84 |     bool validateAction(int uniqueId, const String8& path, | 
 | 85 |             int action, const ActionDescription& description); | 
 | 86 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 87 |     status_t removeRights(int uniqueId, const String8& path); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 88 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 89 |     status_t removeAllRights(int uniqueId); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 90 |  | 
 | 91 |     int openConvertSession(int uniqueId, const String8& mimeType); | 
 | 92 |  | 
 | 93 |     DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData); | 
 | 94 |  | 
 | 95 |     DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId); | 
 | 96 |  | 
 | 97 |     status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); | 
 | 98 |  | 
| James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 99 |     DecryptHandle* openDecryptSession( | 
 | 100 |         int uniqueId, int fd, off64_t offset, off64_t length, const char *mime); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 101 |  | 
| James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 102 |     DecryptHandle* openDecryptSession( | 
 | 103 |         int uniqueId, const char* uri, const char* mime); | 
| Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 104 |  | 
| Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 105 |     DecryptHandle* openDecryptSession(int uniqueId, const DrmBuffer& buf, | 
 | 106 |             const String8& mimeType); | 
 | 107 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 108 |     status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 109 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 110 |     status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 111 |             int decryptUnitId, const DrmBuffer* headerInfo); | 
 | 112 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 113 |     status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, | 
 | 114 |             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 115 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 116 |     status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 117 |  | 
 | 118 |     ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, | 
| Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 119 |             void* buffer, ssize_t numBytes, off64_t offset); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 120 |  | 
| James Dong | 8635b7b | 2011-03-14 17:01:38 -0700 | [diff] [blame] | 121 |     virtual status_t dump(int fd, const Vector<String16>& args); | 
 | 122 |  | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 123 | private: | 
 | 124 |     DrmManager* mDrmManager; | 
 | 125 | }; | 
 | 126 |  | 
 | 127 | }; | 
 | 128 |  | 
 | 129 | #endif /* __DRM_MANAGER_SERVICE_H__ */ | 
 | 130 |  |