Widevine drm aidl: address API review
Interface update in change 16810770 Bug: 214410088 Test: atest VtsAidlHalDrmTargetTest Change-Id: I19da51ef75952f5ff6c7c02e0393f574e69ee30b
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "Utils.h"
|
||||
#include "WVCDMSingleton.h"
|
||||
#include "WVCryptoPlugin.h"
|
||||
#include "WVDrmPlugin.h"
|
||||
#include "WVUUID.h"
|
||||
#include "android-base/properties.h"
|
||||
@@ -31,6 +32,7 @@ namespace widevine {
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using ::aidl::android::hardware::drm::CryptoSchemes;
|
||||
using ::aidl::android::hardware::drm::SecurityLevel;
|
||||
using ::aidl::android::hardware::drm::Status;
|
||||
using ::aidl::android::hardware::drm::Uuid;
|
||||
@@ -41,40 +43,33 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
|
||||
return isWidevineUUID(in_uuid.uuid.data());
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::isCryptoSchemeSupported(
|
||||
const Uuid& in_uuid, const string& in_mimeType,
|
||||
SecurityLevel in_securityLevel, bool* _aidl_return) {
|
||||
bool isMimeTypeSupported = false;
|
||||
isContentTypeSupported(in_mimeType, &isMimeTypeSupported);
|
||||
if (!isWidevineUUID(in_uuid.uuid.data()) || !isMimeTypeSupported) {
|
||||
*_aidl_return = false;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
::ndk::ScopedAStatus WVDrmFactory::createCryptoPlugin(
|
||||
const ::aidl::android::hardware::drm::Uuid& in_uuid,
|
||||
const std::vector<uint8_t>& in_initData,
|
||||
std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>*
|
||||
_aidl_return) {
|
||||
const auto& self = android::IPCThreadState::self();
|
||||
const char* sid = self->getCallingSid();
|
||||
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
|
||||
ALOGI("[%s] calling %s", sid, __PRETTY_FUNCTION__);
|
||||
|
||||
if (!isCryptoSchemeSupported(in_uuid)) {
|
||||
ALOGE(
|
||||
"Widevine Drm HAL: failed to create crypto plugin, "
|
||||
"invalid crypto scheme");
|
||||
*_aidl_return = nullptr;
|
||||
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
||||
}
|
||||
|
||||
if (wvcdm::WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||
wvcdm::kSecurityLevelL1)) {
|
||||
if (wvcdm::WvContentDecryptionModule::IsAudio(in_mimeType)) {
|
||||
if (in_securityLevel < SecurityLevel::HW_SECURE_ALL) {
|
||||
*_aidl_return = true;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
} else {
|
||||
*_aidl_return = true;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
}
|
||||
*_aidl_return = in_securityLevel <= SecurityLevel::SW_SECURE_DECODE;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
std::shared_ptr<WVCryptoPlugin> plugin =
|
||||
::ndk::SharedRefBase::make<WVCryptoPlugin>(in_initData.data(),
|
||||
in_initData.size(), getCDM());
|
||||
AIBinder_setRequestingSid(plugin->asBinder().get(), true);
|
||||
*_aidl_return = std::move(plugin);
|
||||
return toNdkScopedAStatus(Status::OK);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::isContentTypeSupported(
|
||||
const string& in_mimeType, bool* _aidl_return) {
|
||||
*_aidl_return =
|
||||
wvcdm::WvContentDecryptionModule::IsSupported(in_mimeType.c_str());
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::createPlugin(
|
||||
::ndk::ScopedAStatus WVDrmFactory::createDrmPlugin(
|
||||
const Uuid& in_uuid, const string& in_appPackageName,
|
||||
std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) {
|
||||
const auto& self = ::android::IPCThreadState::self();
|
||||
@@ -130,13 +125,22 @@ int32_t WVDrmFactory::firstApiLevel() {
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmFactory::getSupportedCryptoSchemes(
|
||||
vector<Uuid>* _aidl_return) {
|
||||
vector<Uuid> schemes;
|
||||
Uuid scheme;
|
||||
CryptoSchemes* _aidl_return) {
|
||||
CryptoSchemes schemes{};
|
||||
for (const auto& uuid : wvdrm::getSupportedCryptoSchemes()) {
|
||||
scheme.uuid.assign(uuid.begin(), uuid.end());
|
||||
schemes.push_back(scheme);
|
||||
schemes.uuids.push_back({uuid});
|
||||
}
|
||||
schemes.minLevel = schemes.maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
|
||||
if (wvcdm::WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||
wvcdm::kSecurityLevelL1)) {
|
||||
schemes.maxLevel = SecurityLevel::HW_SECURE_ALL;
|
||||
}
|
||||
|
||||
schemes.mimeTypes = {
|
||||
wvcdm::ISO_BMFF_VIDEO_MIME_TYPE, wvcdm::ISO_BMFF_AUDIO_MIME_TYPE,
|
||||
wvcdm::WEBM_VIDEO_MIME_TYPE, wvcdm::WEBM_AUDIO_MIME_TYPE,
|
||||
wvcdm::CENC_INIT_DATA_FORMAT, wvcdm::HLS_INIT_DATA_FORMAT,
|
||||
wvcdm::WEBM_INIT_DATA_FORMAT};
|
||||
*_aidl_return = schemes;
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user