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 | |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H |
| 18 | #define ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 19 | |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 20 | #include <android/hidl/memory/1.0/IMemory.h> |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 21 | #include <android/hardware/drm/1.0/ICryptoPlugin.h> |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 22 | #include <hidl/Status.h> |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 23 | #include <media/hardware/CryptoAPI.h> |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace drm { |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 28 | namespace V1_0 { |
| 29 | namespace implementation { |
| 30 | |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 31 | using ::android::hardware::drm::V1_0::DestinationBuffer; |
| 32 | using ::android::hardware::drm::V1_0::ICryptoPlugin; |
| 33 | using ::android::hardware::drm::V1_0::Mode; |
| 34 | using ::android::hardware::drm::V1_0::Pattern; |
| 35 | using ::android::hardware::drm::V1_0::SubSample; |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 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; |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 41 | using ::android::hidl::memory::V1_0::IMemory; |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 42 | using ::android::sp; |
| 43 | |
| 44 | struct CryptoPlugin : public ICryptoPlugin { |
| 45 | CryptoPlugin(android::CryptoPlugin *plugin) : mLegacyPlugin(plugin) {} |
Jeff Tinker | d59d362 | 2016-12-16 01:34:52 -0800 | [diff] [blame] | 46 | |
Jeff Tinker | e3b6ae1 | 2017-05-16 18:21:39 +0000 | [diff] [blame] | 47 | ~CryptoPlugin() {delete mLegacyPlugin;} |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 48 | |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 49 | // Methods from ::android::hardware::drm::V1_0::ICryptoPlugin |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 50 | // 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 Tinker | 0b3f41e | 2017-02-16 12:20:30 -0800 | [diff] [blame] | 60 | Return<void> setSharedBufferBase(const ::android::hardware::hidl_memory& base, |
| 61 | uint32_t bufferId) override; |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 62 | |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 63 | 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 Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 65 | const hidl_vec<SubSample>& subSamples, const SharedBuffer& source, |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 66 | uint64_t offset, const DestinationBuffer& destination, |
Jeff Tinker | 6fdbe86 | 2017-01-11 19:45:23 -0800 | [diff] [blame] | 67 | decrypt_cb _hidl_cb) override; |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 68 | |
| 69 | private: |
| 70 | android::CryptoPlugin *mLegacyPlugin; |
Jeff Tinker | 0b3f41e | 2017-02-16 12:20:30 -0800 | [diff] [blame] | 71 | std::map<uint32_t, sp<IMemory> > mSharedBufferMap; |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 72 | |
| 73 | CryptoPlugin() = delete; |
| 74 | CryptoPlugin(const CryptoPlugin &) = delete; |
| 75 | void operator=(const CryptoPlugin &) = delete; |
| 76 | }; |
| 77 | |
| 78 | } // namespace implementation |
| 79 | } // namespace V1_0 |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 80 | } // namespace drm |
| 81 | } // namespace hardware |
| 82 | } // namespace android |
| 83 | |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 84 | #endif // ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H |