Merged from http://go/wvgerrit/163639 Bug: 253271674 Test: Google TV Test: atest MediaDrmParameterizedTests Test: atest DrmSessionManagerTest Change-Id: I9f0e83774d405466a389d2fd90d693830682dde4
94 lines
2.7 KiB
C++
94 lines
2.7 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 {
|
|
|
|
class SharedBufferBase {
|
|
public:
|
|
SharedBufferBase(const ::aidl::android::hardware::drm::SharedBuffer& mem);
|
|
~SharedBufferBase();
|
|
uint8_t* base() const { return mBase; }
|
|
int64_t size() const { return mSize; }
|
|
void set_base(uint8_t* base) { mBase = base; }
|
|
void set_size(uint64_t size) { mSize = size; }
|
|
private:
|
|
uint8_t* mBase;
|
|
int64_t mSize;
|
|
};
|
|
|
|
class WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
|
|
public:
|
|
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::drm::SharedBuffer& in_base) override;
|
|
|
|
::ndk::ScopedAStatus decrypt(
|
|
const ::aidl::android::hardware::drm::DecryptArgs& in_args,
|
|
int32_t* _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;
|
|
|
|
::ndk::SpAIBinder createBinder() override;
|
|
|
|
::wvdrm::WvStatus 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_
|