blob: 11cc2aae47a65b51f6de6185f0e750a87d33f382 [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
Jeff Tinkerda002fe2017-01-19 14:41:11 -080017#ifndef ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H
18#define ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H
Jeff Tinkerb075caa2016-12-06 23:15:20 -080019
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080020#include <android/hidl/memory/1.0/IMemory.h>
Jeff Tinkerda002fe2017-01-19 14:41:11 -080021#include <android/hardware/drm/1.0/ICryptoPlugin.h>
Jeff Tinkerb075caa2016-12-06 23:15:20 -080022#include <hidl/Status.h>
Jeff Tinkerda002fe2017-01-19 14:41:11 -080023#include <media/hardware/CryptoAPI.h>
Jeff Tinkerb075caa2016-12-06 23:15:20 -080024
25namespace android {
26namespace hardware {
27namespace drm {
Jeff Tinkerb075caa2016-12-06 23:15:20 -080028namespace V1_0 {
29namespace implementation {
30
Jeff Tinkerda002fe2017-01-19 14:41:11 -080031using ::android::hardware::drm::V1_0::DestinationBuffer;
32using ::android::hardware::drm::V1_0::ICryptoPlugin;
33using ::android::hardware::drm::V1_0::Mode;
34using ::android::hardware::drm::V1_0::Pattern;
35using ::android::hardware::drm::V1_0::SubSample;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080036using ::android::hardware::hidl_array;
37using ::android::hardware::hidl_string;
38using ::android::hardware::hidl_vec;
39using ::android::hardware::Return;
40using ::android::hardware::Void;
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080041using ::android::hidl::memory::V1_0::IMemory;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080042using ::android::sp;
43
44struct CryptoPlugin : public ICryptoPlugin {
45 CryptoPlugin(android::CryptoPlugin *plugin) : mLegacyPlugin(plugin) {}
Jeff Tinkerd59d3622016-12-16 01:34:52 -080046
Jeff Tinkere3b6ae12017-05-16 18:21:39 +000047 ~CryptoPlugin() {delete mLegacyPlugin;}
Jeff Tinkerb075caa2016-12-06 23:15:20 -080048
Jeff Tinkerda002fe2017-01-19 14:41:11 -080049 // Methods from ::android::hardware::drm::V1_0::ICryptoPlugin
Jeff Tinkerb075caa2016-12-06 23:15:20 -080050 // follow.
51
52 Return<bool> requiresSecureDecoderComponent(const hidl_string& mime)
53 override;
54
55 Return<void> notifyResolution(uint32_t width, uint32_t height) override;
56
57 Return<Status> setMediaDrmSession(const hidl_vec<uint8_t>& sessionId)
58 override;
59
Jeff Tinker0b3f41e2017-02-16 12:20:30 -080060 Return<void> setSharedBufferBase(const ::android::hardware::hidl_memory& base,
61 uint32_t bufferId) override;
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080062
Jeff Tinkerb075caa2016-12-06 23:15:20 -080063 Return<void> decrypt(bool secure, const hidl_array<uint8_t, 16>& keyId,
64 const hidl_array<uint8_t, 16>& iv, Mode mode, const Pattern& pattern,
Jeff Tinkerf21cdaf2017-01-18 11:49:27 -080065 const hidl_vec<SubSample>& subSamples, const SharedBuffer& source,
Jeff Tinkerda002fe2017-01-19 14:41:11 -080066 uint64_t offset, const DestinationBuffer& destination,
Jeff Tinker6fdbe862017-01-11 19:45:23 -080067 decrypt_cb _hidl_cb) override;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080068
69private:
70 android::CryptoPlugin *mLegacyPlugin;
Jeff Tinker0b3f41e2017-02-16 12:20:30 -080071 std::map<uint32_t, sp<IMemory> > mSharedBufferMap;
Jeff Tinkerb075caa2016-12-06 23:15:20 -080072
73 CryptoPlugin() = delete;
74 CryptoPlugin(const CryptoPlugin &) = delete;
75 void operator=(const CryptoPlugin &) = delete;
76};
77
78} // namespace implementation
79} // namespace V1_0
Jeff Tinkerb075caa2016-12-06 23:15:20 -080080} // namespace drm
81} // namespace hardware
82} // namespace android
83
Jeff Tinkerda002fe2017-01-19 14:41:11 -080084#endif // ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H