1 /* 2 * Copyright (C) 2017 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 CRYPTO_HAL_H_ 18 #define CRYPTO_HAL_H_ 19 20 #include <mediadrm/ICrypto.h> 21 #include <utils/KeyedVector.h> 22 #include <utils/threads.h> 23 24 using ::android::hardware::HidlMemory; 25 26 class IMemoryHeap; 27 28 namespace android { 29 30 struct CryptoHal : public ICrypto { 31 CryptoHal(); 32 virtual ~CryptoHal(); 33 virtual status_t initCheck() const; 34 virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]); 35 virtual status_t createPlugin( 36 const uint8_t uuid[16], const void *data, size_t size); 37 virtual status_t destroyPlugin(); 38 virtual bool requiresSecureDecoderComponent( 39 const char *mime) const; 40 virtual void notifyResolution(uint32_t width, uint32_t height); 41 virtual DrmStatus setMediaDrmSession(const Vector<uint8_t> &sessionId); 42 virtual ssize_t decrypt(const uint8_t key[16], const uint8_t iv[16], 43 CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, 44 const drm::V1_0::SharedBuffer &source, size_t offset, 45 const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, 46 const drm::V1_0::DestinationBuffer &destination, 47 AString *errorDetailMsg); 48 virtual int32_t setHeap(const sp<HidlMemory>& heap); 49 virtual void unsetHeap(int32_t seqNum); 50 virtual status_t getLogMessages(Vector<drm::V1_4::LogMessage> &logs) const; 51 private: 52 sp<ICrypto> mCryptoHalHidl; 53 sp<ICrypto> mCryptoHalAidl; 54 DISALLOW_EVIL_CONSTRUCTORS(CryptoHal); 55 }; 56 57 } // namespace android 58 59 #endif // CRYPTO_HAL_H_