Files
android/libwvdrmengine/mediacrypto/aidl_include/WVCryptoPlugin.h
Edwin 3c3da01d58 Use aidl interface for Widevine service.
The interface is defined in
hardware/interfaces/drm/aidl(http://go/ag/15329852).

Test: build
  m android.hardware.drm-service.widevine -j128

Test: build_and_run_all_unit_tests.sh
  for hidl tests

Test: atest VtsAidlHalDrmTargetTest

Test:   atest vts_treble_vintf_vendor_test:vts_treble_vintf_vendor_test.DeviceManifest/SingleManifestTest#ManifestAidlHalsServed/0 -- --abi x86_64

Bug: 200055138
Bug: 170964303
Change-Id: I5654d90d8a4b0bae4b4a78e79b27c1cafec36be7
2022-02-01 22:20:04 -08:00

94 lines
3.0 KiB
C++

//
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_CRYPTO_PLUGIN_H_
#define WV_CRYPTO_PLUGIN_H_
#include <aidl/android/hardware/common/Ashmem.h>
#include <aidl/android/hardware/drm/BnCryptoPlugin.h>
#include <aidl/android/hardware/drm/Status.h>
#include <android-base/thread_annotations.h>
#include <mutex>
#include "WVTypes.h"
#include "log.h"
#include "wv_content_decryption_module.h"
namespace wvdrm {
namespace hardware {
namespace drm {
namespace widevine {
struct SharedBufferBase {
uint8_t* mBase;
int64_t mSize;
SharedBufferBase(const ::aidl::android::hardware::common::Ashmem& mem);
~SharedBufferBase();
};
struct WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
WVCryptoPlugin(const void* data, size_t size,
const ::android::sp<wvcdm::WvContentDecryptionModule>& cdm);
virtual ~WVCryptoPlugin();
::ndk::ScopedAStatus requiresSecureDecoderComponent(
const std::string& in_mime, bool* _aidl_return) override;
::ndk::ScopedAStatus notifyResolution(int32_t in_width,
int32_t in_height) override;
::ndk::ScopedAStatus setMediaDrmSession(
const std::vector<uint8_t>& in_sessionId) override;
::ndk::ScopedAStatus setSharedBufferBase(
const ::aidl::android::hardware::common::Ashmem& in_base,
int32_t in_bufferId) override;
::ndk::ScopedAStatus decrypt(
bool in_secure, const std::vector<uint8_t>& in_keyId,
const std::vector<uint8_t>& in_iv,
::aidl::android::hardware::drm::Mode in_mode,
const ::aidl::android::hardware::drm::Pattern& in_pattern,
const std::vector<::aidl::android::hardware::drm::SubSample>&
in_subSamples,
const ::aidl::android::hardware::drm::SharedBuffer& in_source,
int64_t in_offset,
const ::aidl::android::hardware::drm::DestinationBuffer& in_destination,
::aidl::android::hardware::drm::DecryptResult* _aidl_return) override;
::ndk::ScopedAStatus getLogMessages(
std::vector<::aidl::android::hardware::drm::LogMessage>* _aidl_return)
override;
private:
WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(WVCryptoPlugin);
// List this field first so it is destructed last; ensure logging uid
// is cleared right before plugin is destructed.
wvutil::LoggingUidSetter mLoggingUidSetter;
wvcdm::CdmSessionId mSessionId;
std::map<uint32_t, std::shared_ptr<SharedBufferBase>> mSharedBufferMap
GUARDED_BY(mSharedBufferLock);
::android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
uint32_t mUserId;
::aidl::android::hardware::drm::Status attemptDecrypt(
const wvcdm::CdmDecryptionParametersV16& params,
bool haveEncryptedSubsamples, std::string* errorDetailMsg);
std::mutex mSharedBufferLock;
};
} // namespace widevine
} // namespace drm
} // namespace hardware
} // namespace wvdrm
#endif // WV_CRYPTO_PLUGIN_H_