Home | History | Annotate | Download | only in default
      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_V1_0__CRYPTOPLUGIN_H
     18 #define ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H
     19 
     20 #include <android/hidl/memory/1.0/IMemory.h>
     21 #include <android/hardware/drm/1.0/ICryptoPlugin.h>
     22 #include <hidl/Status.h>
     23 #include <media/hardware/CryptoAPI.h>
     24 
     25 namespace android {
     26 namespace hardware {
     27 namespace drm {
     28 namespace V1_0 {
     29 namespace implementation {
     30 
     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;
     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::hidl::memory::V1_0::IMemory;
     42 using ::android::sp;
     43 
     44 struct CryptoPlugin : public ICryptoPlugin {
     45     CryptoPlugin(android::CryptoPlugin *plugin) : mLegacyPlugin(plugin) {}
     46 
     47     ~CryptoPlugin() {delete mLegacyPlugin;}
     48 
     49     // Methods from ::android::hardware::drm::V1_0::ICryptoPlugin
     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 
     60     Return<void> setSharedBufferBase(const ::android::hardware::hidl_memory& base,
     61         uint32_t bufferId) override;
     62 
     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,
     65             const hidl_vec<SubSample>& subSamples, const SharedBuffer& source,
     66             uint64_t offset, const DestinationBuffer& destination,
     67             decrypt_cb _hidl_cb) override;
     68 
     69 private:
     70     android::CryptoPlugin *mLegacyPlugin;
     71     std::map<uint32_t, sp<IMemory> > mSharedBufferMap;
     72 
     73     CryptoPlugin() = delete;
     74     CryptoPlugin(const CryptoPlugin &) = delete;
     75     void operator=(const CryptoPlugin &) = delete;
     76 };
     77 
     78 }  // namespace implementation
     79 }  // namespace V1_0
     80 }  // namespace drm
     81 }  // namespace hardware
     82 }  // namespace android
     83 
     84 #endif  // ANDROID_HARDWARE_DRM_V1_0__CRYPTOPLUGIN_H
     85