// // Copyright 2017 Google Inc. All Rights Reserved. // #ifndef WV_CRYPTO_PLUGIN_H_ #define WV_CRYPTO_PLUGIN_H_ #include #include #include "wv_content_decryption_module.h" #include "WVTypes.h" namespace wvdrm { namespace hardware { namespace drm { namespace V1_0 { namespace widevine { using ::android::hardware::drm::V1_0::DestinationBuffer; using ::android::hardware::drm::V1_0::ICryptoPlugin; using ::android::hardware::drm::V1_0::Mode; using ::android::hardware::drm::V1_0::Pattern; using ::android::hardware::drm::V1_0::SharedBuffer; using ::android::hardware::drm::V1_0::Status; using ::android::hardware::drm::V1_0::SubSample; using ::android::hardware::hidl_array; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::hidl_memory; using ::android::hidl::memory::V1_0::IMemory; using ::android::sp; struct WVCryptoPlugin : public ICryptoPlugin { WVCryptoPlugin(const void* data, size_t size, const sp& cdm); virtual ~WVCryptoPlugin() {} Return requiresSecureDecoderComponent(const hidl_string& mime) override; Return notifyResolution(uint32_t width, uint32_t height) override; Return setMediaDrmSession(const hidl_vec& sessionId) override; Return setSharedBufferBase(const hidl_memory& base, uint32_t bufferId) override; Return decrypt( bool secure, const hidl_array& keyId, const hidl_array& iv, Mode mode, const Pattern& pattern, const hidl_vec& subSamples, const SharedBuffer& source, uint64_t offset, const DestinationBuffer& destination, decrypt_cb _hidl_cb) override; private: WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(WVCryptoPlugin); wvcdm::CdmSessionId mSessionId; std::map > mSharedBufferMap; sp const mCDM; Status attemptDecrypt( const wvcdm::CdmDecryptionParameters& params, bool haveEncryptedSubsamples, std::string* errorDetailMsg); static wvcdm::CdmResponseType countEncryptedBlocksInPatternedRange( size_t range, const Pattern& pattern, uint64_t* result); static void incrementIV(uint64_t increaseBy, std::vector* ivPtr); }; } // namespace widevine } // namespace V1_0 } // namespace drm } // namespace hardware } // namespace wvdrm #endif // WV_CRYPTO_PLUGIN_H_