blob: c367d0b3e71679f4fcba3a971ffa361a9202430b [file] [log] [blame]
Jeff Tinkerb075caa2016-12-06 23:15:20 -08001/*
2 * Copyright (C) 2016 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 ANDROID_HARDWARE_DRM_CRYPTO_V1_0__CRYPTOPLUGIN_H
18#define ANDROID_HARDWARE_DRM_CRYPTO_V1_0__CRYPTOPLUGIN_H
19
20#include <media/hardware/CryptoAPI.h>
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080021#include <android/hidl/memory/1.0/IMemory.h>
Jeff Tinkerb075caa2016-12-06 23:15:20 -080022#include <android/hardware/drm/crypto/1.0/ICryptoPlugin.h>
23#include <hidl/Status.h>
24
25namespace android {
26namespace hardware {
27namespace drm {
28namespace crypto {
29namespace V1_0 {
30namespace implementation {
31
32using ::android::hardware::drm::crypto::V1_0::DestinationBuffer;
33using ::android::hardware::drm::crypto::V1_0::ICryptoPlugin;
34using ::android::hardware::drm::crypto::V1_0::Mode;
35using ::android::hardware::drm::crypto::V1_0::Pattern;
36using ::android::hardware::drm::crypto::V1_0::SubSample;
37using ::android::hardware::hidl_array;
38using ::android::hardware::hidl_string;
39using ::android::hardware::hidl_vec;
40using ::android::hardware::Return;
41using ::android::hardware::Void;
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080042using ::android::hidl::memory::V1_0::IMemory;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080043using ::android::sp;
44
45struct CryptoPlugin : public ICryptoPlugin {
46 CryptoPlugin(android::CryptoPlugin *plugin) : mLegacyPlugin(plugin) {}
Jeff Tinkerd59d3622016-12-16 01:34:52 -080047
Jeff Tinkerb075caa2016-12-06 23:15:20 -080048 ~CryptoPlugin() {delete mLegacyPlugin;}
49
50 // Methods from ::android::hardware::drm::crypto::V1_0::ICryptoPlugin
51 // follow.
52
53 Return<bool> requiresSecureDecoderComponent(const hidl_string& mime)
54 override;
55
56 Return<void> notifyResolution(uint32_t width, uint32_t height) override;
57
58 Return<Status> setMediaDrmSession(const hidl_vec<uint8_t>& sessionId)
59 override;
60
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080061 Return<void> setSharedBufferBase(const ::android::hardware::hidl_memory& base)
62 override;
63
Jeff Tinkerb075caa2016-12-06 23:15:20 -080064 Return<void> decrypt(bool secure, const hidl_array<uint8_t, 16>& keyId,
65 const hidl_array<uint8_t, 16>& iv, Mode mode, const Pattern& pattern,
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080066 const hidl_vec<SubSample>& subSamples, const SharedBuffer& source,
Jeff Tinker6fdbe862017-01-11 19:45:23 -080067 uint32_t offset, const DestinationBuffer& destination,
68 decrypt_cb _hidl_cb) override;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080069
70private:
71 android::CryptoPlugin *mLegacyPlugin;
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080072 sp<IMemory> mSharedBufferBase;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080073
74 CryptoPlugin() = delete;
75 CryptoPlugin(const CryptoPlugin &) = delete;
76 void operator=(const CryptoPlugin &) = delete;
77};
78
79} // namespace implementation
80} // namespace V1_0
81} // namespace crypto
82} // namespace drm
83} // namespace hardware
84} // namespace android
85
86#endif // ANDROID_HARDWARE_DRM_CRYPTO_V1_0__CRYPTOPLUGIN_H