1 /* 2 * Copyright (C) 2018 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 CLEARKEY_SESSION_H_ 18 #define CLEARKEY_SESSION_H_ 19 20 #include <utils/Mutex.h> 21 #include <utils/RefBase.h> 22 #include <vector> 23 24 #include "ClearKeyTypes.h" 25 26 27 namespace android { 28 namespace hardware { 29 namespace drm { 30 namespace V1_1 { 31 namespace clearkey { 32 33 using ::android::hardware::drm::V1_0::Status; 34 using ::android::hardware::drm::V1_0::SubSample; 35 36 class Session : public RefBase { 37 public: Session(const std::vector<uint8_t> & sessionId)38 explicit Session(const std::vector<uint8_t>& sessionId) 39 : mSessionId(sessionId) {} ~Session()40 virtual ~Session() {} 41 sessionId()42 const std::vector<uint8_t>& sessionId() const { return mSessionId; } 43 44 Status getKeyRequest( 45 const std::vector<uint8_t>& mimeType, 46 const std::string& initDataType, 47 std::vector<uint8_t>* keyRequest) const; 48 49 Status provideKeyResponse( 50 const std::vector<uint8_t>& response); 51 52 Status decrypt( 53 const KeyId keyId, const Iv iv, const uint8_t* srcPtr, 54 uint8_t* dstPtr, const std::vector<SubSample> subSamples, 55 size_t* bytesDecryptedOut); 56 57 private: 58 CLEARKEY_DISALLOW_COPY_AND_ASSIGN(Session); 59 60 const std::vector<uint8_t> mSessionId; 61 KeyMap mKeyMap; 62 Mutex mMapLock; 63 }; 64 65 } // namespace clearkey 66 } // namespace V1_1 67 } // namespace drm 68 } // namespace hardware 69 } // namespace android 70 71 #endif // CLEARKEY_SESSION_H_ 72