Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 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 | |
| 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 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace drm { |
| 27 | namespace crypto { |
| 28 | namespace V1_0 { |
| 29 | namespace implementation { |
| 30 | |
| 31 | using ::android::hardware::drm::crypto::V1_0::DestinationBuffer; |
| 32 | using ::android::hardware::drm::crypto::V1_0::ICryptoPlugin; |
| 33 | using ::android::hardware::drm::crypto::V1_0::Mode; |
| 34 | using ::android::hardware::drm::crypto::V1_0::Pattern; |
| 35 | using ::android::hardware::drm::crypto::V1_0::SubSample; |
| 36 | using ::android::hardware::hidl_array; |
| 37 | using ::android::hardware::hidl_string; |
| 38 | using ::android::hardware::hidl_vec; |
| 39 | using ::android::hardware::Return; |
| 40 | using ::android::hardware::Void; |
| 41 | using ::android::sp; |
| 42 | |
| 43 | struct 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 | |
| 63 | private: |
| 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 |