blob: 32a6741e2a417de83e2a61f7ddd60f41e1fc757b [file] [log] [blame]
Jeff Tinkera53d6552017-01-20 00:31:46 -08001/*
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 Tinkera53d6552017-01-20 00:31:46 -080018#define CRYPTO_HAL_H_
19
Jeff Tinker7d2c6e82018-02-16 16:14:59 -080020#include <mediadrm/ICrypto.h>
Jeff Tinkera53d6552017-01-20 00:31:46 -080021#include <utils/KeyedVector.h>
22#include <utils/threads.h>
23
Robert Shih895fba92019-07-16 16:29:44 -070024using ::android::hardware::HidlMemory;
Jeff Tinkera53d6552017-01-20 00:31:46 -080025
Jeff Tinker3cb53162017-02-16 12:06:32 -080026class IMemoryHeap;
27
Jeff Tinkera53d6552017-01-20 00:31:46 -080028namespace android {
29
Robert Shih9c930d02019-07-16 15:44:13 -070030struct CryptoHal : public ICrypto {
Jeff Tinkera53d6552017-01-20 00:31:46 -080031 CryptoHal();
32 virtual ~CryptoHal();
Jeff Tinkera53d6552017-01-20 00:31:46 -080033 virtual status_t initCheck() const;
Jeff Tinkera53d6552017-01-20 00:31:46 -080034 virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]);
Jeff Tinkera53d6552017-01-20 00:31:46 -080035 virtual status_t createPlugin(
36 const uint8_t uuid[16], const void *data, size_t size);
Jeff Tinkera53d6552017-01-20 00:31:46 -080037 virtual status_t destroyPlugin();
Jeff Tinkera53d6552017-01-20 00:31:46 -080038 virtual bool requiresSecureDecoderComponent(
39 const char *mime) const;
Jeff Tinkera53d6552017-01-20 00:31:46 -080040 virtual void notifyResolution(uint32_t width, uint32_t height);
Jeff Tinkera53d6552017-01-20 00:31:46 -080041 virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId);
Jeff Tinkera53d6552017-01-20 00:31:46 -080042 virtual ssize_t decrypt(const uint8_t key[16], const uint8_t iv[16],
43 CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern,
Kyle Zhang6605add2022-01-13 17:51:23 +000044 const drm::V1_0::SharedBuffer &source, size_t offset,
Jeff Tinkera53d6552017-01-20 00:31:46 -080045 const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
Kyle Zhang6605add2022-01-13 17:51:23 +000046 const drm::V1_0::DestinationBuffer &destination,
Jeff Tinkera53d6552017-01-20 00:31:46 -080047 AString *errorDetailMsg);
Kyle Zhang6605add2022-01-13 17:51:23 +000048 virtual int32_t setHeap(const sp<HidlMemory>& heap);
49 virtual void unsetHeap(int32_t seqNum);
Robert Shih9afca952021-02-12 01:36:06 -080050 virtual status_t getLogMessages(Vector<drm::V1_4::LogMessage> &logs) const;
Jeff Tinkera53d6552017-01-20 00:31:46 -080051private:
Kyle Zhang6605add2022-01-13 17:51:23 +000052 sp<ICrypto> mCryptoHalHidl;
53 sp<ICrypto> mCryptoHalAidl;
Jeff Tinkera53d6552017-01-20 00:31:46 -080054 DISALLOW_EVIL_CONSTRUCTORS(CryptoHal);
55};
56
Kyle Zhanga55209d2022-02-03 01:52:46 +000057} // namespace android
Jeff Tinkera53d6552017-01-20 00:31:46 -080058
Kyle Zhanga55209d2022-02-03 01:52:46 +000059#endif // CRYPTO_HAL_H_