1/*
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#ifndef ANDROID_HARDWARE_DRM_V1_0__CRYPTOFACTORY_H
17#define ANDROID_HARDWARE_DRM_V1_0__CRYPTOFACTORY_H
18
19#include <android/hardware/drm/1.0/ICryptoFactory.h>
20#include <hidl/Status.h>
21#include <media/hardware/CryptoAPI.h>
22#include <PluginLoader.h>
23
24namespace android {
25namespace hardware {
26namespace drm {
27namespace V1_0 {
28namespace implementation {
29
30using ::android::hardware::drm::V1_0::helper::PluginLoader;
31using ::android::hardware::drm::V1_0::ICryptoFactory;
32using ::android::hardware::drm::V1_0::ICryptoPlugin;
33using ::android::hardware::hidl_array;
34using ::android::hardware::hidl_string;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::Return;
37using ::android::hardware::Void;
38using ::android::sp;
39
40struct CryptoFactory : public ICryptoFactory {
41    CryptoFactory();
42    virtual ~CryptoFactory() {}
43
44    // Methods from ::android::hardware::drm::V1_0::ICryptoFactory follow.
45
46    Return<bool> isCryptoSchemeSupported(const hidl_array<uint8_t, 16>& uuid)
47            override;
48
49    Return<void> createPlugin(const hidl_array<uint8_t, 16>& uuid,
50            const hidl_vec<uint8_t>& initData, createPlugin_cb _hidl_cb)
51            override;
52
53private:
54    PluginLoader<android::CryptoFactory> loader;
55
56    CryptoFactory(const CryptoFactory &) = delete;
57    void operator=(const CryptoFactory &) = delete;
58};
59
60extern "C" ICryptoFactory* HIDL_FETCH_ICryptoFactory(const char* name);
61
62}  // namespace implementation
63}  // namespace V1_0
64}  // namespace drm
65}  // namespace hardware
66}  // namespace android
67
68#endif  // ANDROID_HARDWARE_DRM_V1_0__CRYPTOFACTORY_H
69