Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 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_ |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 18 | #define CRYPTO_HAL_H_ |
| 19 | |
Jeff Tinker | 7d2c6e8 | 2018-02-16 16:14:59 -0800 | [diff] [blame] | 20 | #include <mediadrm/ICrypto.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 21 | #include <utils/KeyedVector.h> |
| 22 | #include <utils/threads.h> |
| 23 | |
Robert Shih | 895fba9 | 2019-07-16 16:29:44 -0700 | [diff] [blame] | 24 | using ::android::hardware::HidlMemory; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 25 | |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 26 | class IMemoryHeap; |
| 27 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 28 | namespace android { |
| 29 | |
Robert Shih | 9c930d0 | 2019-07-16 15:44:13 -0700 | [diff] [blame] | 30 | struct CryptoHal : public ICrypto { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 31 | CryptoHal(); |
| 32 | virtual ~CryptoHal(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 33 | virtual status_t initCheck() const; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 34 | virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 35 | virtual status_t createPlugin( |
| 36 | const uint8_t uuid[16], const void *data, size_t size); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 37 | virtual status_t destroyPlugin(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 38 | virtual bool requiresSecureDecoderComponent( |
| 39 | const char *mime) const; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 40 | virtual void notifyResolution(uint32_t width, uint32_t height); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 41 | virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 42 | virtual ssize_t decrypt(const uint8_t key[16], const uint8_t iv[16], |
| 43 | CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 44 | const drm::V1_0::SharedBuffer &source, size_t offset, |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 45 | const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 46 | const drm::V1_0::DestinationBuffer &destination, |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 47 | AString *errorDetailMsg); |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 48 | virtual int32_t setHeap(const sp<HidlMemory>& heap); |
| 49 | virtual void unsetHeap(int32_t seqNum); |
Robert Shih | 9afca95 | 2021-02-12 01:36:06 -0800 | [diff] [blame] | 50 | virtual status_t getLogMessages(Vector<drm::V1_4::LogMessage> &logs) const; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 51 | private: |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 52 | sp<ICrypto> mCryptoHalHidl; |
| 53 | sp<ICrypto> mCryptoHalAidl; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 54 | DISALLOW_EVIL_CONSTRUCTORS(CryptoHal); |
| 55 | }; |
| 56 | |
Kyle Zhang | a55209d | 2022-02-03 01:52:46 +0000 | [diff] [blame] | 57 | } // namespace android |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 58 | |
Kyle Zhang | a55209d | 2022-02-03 01:52:46 +0000 | [diff] [blame] | 59 | #endif // CRYPTO_HAL_H_ |