blob: b17dade904d8052fe6c585cf81f1fad9ddc5f1c9 [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>
21#include <android/hardware/drm/crypto/1.0/ICryptoPlugin.h>
22#include <hidl/Status.h>
23
24namespace android {
25namespace hardware {
26namespace drm {
27namespace crypto {
28namespace V1_0 {
29namespace implementation {
30
31using ::android::hardware::drm::crypto::V1_0::DestinationBuffer;
32using ::android::hardware::drm::crypto::V1_0::ICryptoPlugin;
33using ::android::hardware::drm::crypto::V1_0::Mode;
34using ::android::hardware::drm::crypto::V1_0::Pattern;
35using ::android::hardware::drm::crypto::V1_0::SubSample;
36using ::android::hardware::hidl_array;
37using ::android::hardware::hidl_string;
38using ::android::hardware::hidl_vec;
39using ::android::hardware::Return;
40using ::android::hardware::Void;
41using ::android::sp;
42
43struct CryptoPlugin : public ICryptoPlugin {
44 CryptoPlugin(android::CryptoPlugin *plugin) : mLegacyPlugin(plugin) {}
45 ~CryptoPlugin() {delete mLegacyPlugin;}
46
47 // Methods from ::android::hardware::drm::crypto::V1_0::ICryptoPlugin
48 // follow.
49
50 Return<bool> requiresSecureDecoderComponent(const hidl_string& mime)
51 override;
52
53 Return<void> notifyResolution(uint32_t width, uint32_t height) override;
54
55 Return<Status> setMediaDrmSession(const hidl_vec<uint8_t>& sessionId)
56 override;
57
58 Return<void> decrypt(bool secure, const hidl_array<uint8_t, 16>& keyId,
59 const hidl_array<uint8_t, 16>& iv, Mode mode, const Pattern& pattern,
60 const hidl_vec<SubSample>& subSamples, const hidl_memory& source,
61 const DestinationBuffer& destination, decrypt_cb _hidl_cb) override;
62
63private:
64 android::CryptoPlugin *mLegacyPlugin;
65
66 CryptoPlugin() = delete;
67 CryptoPlugin(const CryptoPlugin &) = delete;
68 void operator=(const CryptoPlugin &) = delete;
69};
70
71} // namespace implementation
72} // namespace V1_0
73} // namespace crypto
74} // namespace drm
75} // namespace hardware
76} // namespace android
77
78#endif // ANDROID_HARDWARE_DRM_CRYPTO_V1_0__CRYPTOPLUGIN_H