Declare class for drmFactory, crypto/drmPlugins
[ Merged from http://go/wvgerrit/152493 ] Replace struct with class for WVDrmFactory, WVCryptoPlugin and WVDrmPlugin. Also fix build_all_unit_tests.sh, hidl_metrics_adapter_unittest has been renamed to hal_metrics_adapter_unittest. Test: unit tests Test: Google TV and Netflix Test: atest GtsMediaTestCases Bug: 216717460 Change-Id: I92b15510267e8f37058845be760a6ec6241bc5d7
This commit is contained in:
@@ -19,7 +19,8 @@ namespace hardware {
|
|||||||
namespace drm {
|
namespace drm {
|
||||||
namespace widevine {
|
namespace widevine {
|
||||||
|
|
||||||
struct WVDrmFactory : public ::aidl::android::hardware::drm::BnDrmFactory {
|
class WVDrmFactory : public ::aidl::android::hardware::drm::BnDrmFactory {
|
||||||
|
public:
|
||||||
WVDrmFactory() {}
|
WVDrmFactory() {}
|
||||||
virtual ~WVDrmFactory() {}
|
virtual ~WVDrmFactory() {}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ WV_UNITTESTS="base64_test \
|
|||||||
file_store_unittest \
|
file_store_unittest \
|
||||||
file_utils_unittest \
|
file_utils_unittest \
|
||||||
generic_crypto_unittest \
|
generic_crypto_unittest \
|
||||||
hidl_metrics_adapter_unittest \
|
hal_metrics_adapter_unittest \
|
||||||
http_socket_test \
|
http_socket_test \
|
||||||
initialization_data_unittest \
|
initialization_data_unittest \
|
||||||
keybox_ota_test \
|
keybox_ota_test \
|
||||||
|
|||||||
@@ -23,14 +23,21 @@ namespace hardware {
|
|||||||
namespace drm {
|
namespace drm {
|
||||||
namespace widevine {
|
namespace widevine {
|
||||||
|
|
||||||
struct SharedBufferBase {
|
class SharedBufferBase {
|
||||||
uint8_t* mBase;
|
public:
|
||||||
int64_t mSize;
|
|
||||||
SharedBufferBase(const ::aidl::android::hardware::drm::SharedBuffer& mem);
|
SharedBufferBase(const ::aidl::android::hardware::drm::SharedBuffer& mem);
|
||||||
~SharedBufferBase();
|
~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;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
|
class WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
|
||||||
|
public:
|
||||||
WVCryptoPlugin(const void* data, size_t size,
|
WVCryptoPlugin(const void* data, size_t size,
|
||||||
const ::android::sp<wvcdm::WvContentDecryptionModule>& cdm);
|
const ::android::sp<wvcdm::WvContentDecryptionModule>& cdm);
|
||||||
virtual ~WVCryptoPlugin();
|
virtual ~WVCryptoPlugin();
|
||||||
|
|||||||
@@ -64,8 +64,9 @@ WVCryptoPlugin::~WVCryptoPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedBufferBase::SharedBufferBase(
|
SharedBufferBase::SharedBufferBase(
|
||||||
const ::aidl::android::hardware::drm::SharedBuffer& mem)
|
const ::aidl::android::hardware::drm::SharedBuffer& mem) {
|
||||||
: mBase(nullptr), mSize(mem.size) {
|
set_base(nullptr);
|
||||||
|
set_size(mem.size);
|
||||||
if (mem.handle.fds.empty()) {
|
if (mem.handle.fds.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -75,13 +76,13 @@ SharedBufferBase::SharedBufferBase(
|
|||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
ALOGE("mmap err: fd %d; errno %s", fd, strerror(errno));
|
ALOGE("mmap err: fd %d; errno %s", fd, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
mBase = static_cast<uint8_t*>(addr);
|
set_base(static_cast<uint8_t*>(addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedBufferBase::~SharedBufferBase() {
|
SharedBufferBase::~SharedBufferBase() {
|
||||||
if (munmap(mBase, mSize)) {
|
if (munmap(base(), size())) {
|
||||||
ALOGE("munmap err: base %p; errno %s", mBase, strerror(errno));
|
ALOGE("munmap err: base %p; errno %s", base(), strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ SharedBufferBase::~SharedBufferBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto src = mSharedBufferMap[in_args.source.bufferId];
|
auto src = mSharedBufferMap[in_args.source.bufferId];
|
||||||
if (src->mBase == nullptr) {
|
if (src->base() == nullptr) {
|
||||||
detailedError = "source is a nullptr";
|
detailedError = "source is a nullptr";
|
||||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE, detailedError);
|
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE, detailedError);
|
||||||
}
|
}
|
||||||
@@ -193,18 +194,18 @@ SharedBufferBase::~SharedBufferBase() {
|
|||||||
&totalSrcSize) ||
|
&totalSrcSize) ||
|
||||||
__builtin_add_overflow(totalSrcSize, in_args.source.size,
|
__builtin_add_overflow(totalSrcSize, in_args.source.size,
|
||||||
&totalSrcSize) ||
|
&totalSrcSize) ||
|
||||||
totalSrcSize > src->mSize) {
|
totalSrcSize > src->size()) {
|
||||||
android_errorWriteLog(0x534e4554, "176496160");
|
android_errorWriteLog(0x534e4554, "176496160");
|
||||||
detailedError = "invalid source buffer size";
|
detailedError = "invalid source buffer size";
|
||||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE, detailedError);
|
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE, detailedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
srcPtr = src->mBase + in_args.source.offset + in_args.offset;
|
srcPtr = src->base() + in_args.source.offset + in_args.offset;
|
||||||
|
|
||||||
if (in_args.destination.getTag() == NON_SECURE) {
|
if (in_args.destination.getTag() == NON_SECURE) {
|
||||||
const SharedBuffer& destBuffer = in_args.destination.get<NON_SECURE>();
|
const SharedBuffer& destBuffer = in_args.destination.get<NON_SECURE>();
|
||||||
auto dest = mSharedBufferMap[destBuffer.bufferId];
|
auto dest = mSharedBufferMap[destBuffer.bufferId];
|
||||||
if (dest->mBase == nullptr) {
|
if (dest->base() == nullptr) {
|
||||||
detailedError = "destination is a nullptr";
|
detailedError = "destination is a nullptr";
|
||||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE,
|
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE,
|
||||||
detailedError);
|
detailedError);
|
||||||
@@ -212,14 +213,14 @@ SharedBufferBase::~SharedBufferBase() {
|
|||||||
size_t totalDstSize = 0;
|
size_t totalDstSize = 0;
|
||||||
if (__builtin_add_overflow(destBuffer.offset, destBuffer.size,
|
if (__builtin_add_overflow(destBuffer.offset, destBuffer.size,
|
||||||
&totalDstSize) ||
|
&totalDstSize) ||
|
||||||
totalDstSize > dest->mSize) {
|
totalDstSize > dest->size()) {
|
||||||
android_errorWriteLog(0x534e4554, "176444622");
|
android_errorWriteLog(0x534e4554, "176444622");
|
||||||
detailedError = "invalid buffer size";
|
detailedError = "invalid buffer size";
|
||||||
return toNdkScopedAStatus(Status::ERROR_DRM_FRAME_TOO_LARGE,
|
return toNdkScopedAStatus(Status::ERROR_DRM_FRAME_TOO_LARGE,
|
||||||
detailedError);
|
detailedError);
|
||||||
}
|
}
|
||||||
destPtr = static_cast<void*>(
|
destPtr = static_cast<void*>(
|
||||||
dest->mBase + in_args.destination.get<NON_SECURE>().offset);
|
dest->base() + in_args.destination.get<NON_SECURE>().offset);
|
||||||
} else if (in_args.destination.getTag() == SECURE) {
|
} else if (in_args.destination.getTag() == SECURE) {
|
||||||
handle = android::makeFromAidl(in_args.destination.get<SECURE>());
|
handle = android::makeFromAidl(in_args.destination.get<SECURE>());
|
||||||
destPtr = static_cast<void*>(handle);
|
destPtr = static_cast<void*>(handle);
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ using wvcdm::WvContentDecryptionModule;
|
|||||||
const OEMCrypto_Algorithm kInvalidCryptoAlgorithm =
|
const OEMCrypto_Algorithm kInvalidCryptoAlgorithm =
|
||||||
static_cast<OEMCrypto_Algorithm>(-1);
|
static_cast<OEMCrypto_Algorithm>(-1);
|
||||||
|
|
||||||
struct WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
||||||
wvcdm::WvCdmEventListener {
|
wvcdm::WvCdmEventListener {
|
||||||
|
public:
|
||||||
WVDrmPlugin(const android::sp<WvContentDecryptionModule>& cdm,
|
WVDrmPlugin(const android::sp<WvContentDecryptionModule>& cdm,
|
||||||
const std::string& appPackageName,
|
const std::string& appPackageName,
|
||||||
WVGenericCryptoInterface* crypto, bool useSpoid);
|
WVGenericCryptoInterface* crypto, bool useSpoid);
|
||||||
|
|||||||
Reference in New Issue
Block a user