Implement Widevine drm HIDL HAL service.
Modify Android mediadrm and mediacrypto glue layer to use HIDL interface. Test: Play Movies (streaming and offline playback) Test: ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed run gts -m GtsMediaTestCases Test: adb shell /system/bin/libwvdrmengine_hidl_test Test: adb shell /system/bin/libwvdrmmediacrypto_hidl_test Test: adb shell /system/bin/libwvdrmdrmplugin_hidl_test bug: 34628973 Change-Id: Icd5f2dd556acb9874697963b4d7d62cb7c943e74
This commit is contained in:
committed by
John W. Bruce
parent
a4506542df
commit
2dc53442e7
74
libwvdrmengine/src_hidl/TypeConvert.cpp
Normal file
74
libwvdrmengine/src_hidl/TypeConvert.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TypeConvert.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace V1_0 {
|
||||
namespace widevine {
|
||||
|
||||
Status toStatus(status_t mediaError) {
|
||||
Status status;
|
||||
switch(mediaError) {
|
||||
case android::OK:
|
||||
status = Status::OK;
|
||||
break;
|
||||
case android::ERROR_DRM_NO_LICENSE:
|
||||
status = Status::ERROR_DRM_NO_LICENSE;
|
||||
break;
|
||||
case android::ERROR_DRM_LICENSE_EXPIRED:
|
||||
status = Status::ERROR_DRM_LICENSE_EXPIRED;
|
||||
break;
|
||||
case android::ERROR_DRM_SESSION_NOT_OPENED:
|
||||
status = Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
break;
|
||||
case android::ERROR_DRM_CANNOT_HANDLE:
|
||||
status = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
break;
|
||||
case android::ERROR_DRM_TAMPER_DETECTED:
|
||||
status = Status::ERROR_DRM_INVALID_STATE;
|
||||
break;
|
||||
case android::BAD_VALUE:
|
||||
status = Status::BAD_VALUE;
|
||||
break;
|
||||
case android::ERROR_DRM_NOT_PROVISIONED:
|
||||
status = Status::ERROR_DRM_NOT_PROVISIONED;
|
||||
break;
|
||||
case android::ERROR_DRM_RESOURCE_BUSY:
|
||||
status = Status::ERROR_DRM_RESOURCE_BUSY;
|
||||
break;
|
||||
case android::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION:
|
||||
status = Status::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION;
|
||||
break;
|
||||
case android::ERROR_DRM_DEVICE_REVOKED:
|
||||
status = Status::ERROR_DRM_DEVICE_REVOKED;
|
||||
break;
|
||||
default:
|
||||
ALOGW("Unable to convert legacy status: %d, defaulting to UNKNOWN",
|
||||
mediaError);
|
||||
status = Status::ERROR_DRM_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
} // namespace V1_0
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
31
libwvdrmengine/src_hidl/WVCreatePluginFactories.cpp
Normal file
31
libwvdrmengine/src_hidl/WVCreatePluginFactories.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
|
||||
#include "WVCreatePluginFactories.h"
|
||||
|
||||
#include "WVCryptoFactory.h"
|
||||
#include "WVDrmFactory.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace V1_0 {
|
||||
namespace widevine {
|
||||
|
||||
extern "C" {
|
||||
|
||||
IDrmFactory* createDrmFactory() {
|
||||
return new WVDrmFactory();
|
||||
}
|
||||
|
||||
ICryptoFactory* createCryptoFactory() {
|
||||
return new WVCryptoFactory();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
} // namespace widevine
|
||||
} // namespace V1_0
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace wvdrm
|
||||
50
libwvdrmengine/src_hidl/WVCryptoFactory.cpp
Normal file
50
libwvdrmengine/src_hidl/WVCryptoFactory.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVCdm"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "WVCryptoFactory.h"
|
||||
#include "WVCDMSingleton.h"
|
||||
#include "WVCryptoPlugin.h"
|
||||
#include "WVUUID.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace V1_0 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::drm::V1_0::Status;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
Return<bool> WVCryptoFactory::isCryptoSchemeSupported(
|
||||
const hidl_array<uint8_t, 16>& uuid) {
|
||||
return isWidevineUUID(uuid.data());
|
||||
}
|
||||
|
||||
Return<void> WVCryptoFactory::createPlugin(
|
||||
const hidl_array<uint8_t, 16>& uuid,
|
||||
const hidl_vec<uint8_t>& initData,
|
||||
createPlugin_cb _hidl_cb) {
|
||||
|
||||
WVCryptoPlugin *plugin = NULL;
|
||||
if (!isCryptoSchemeSupported(uuid.data())) {
|
||||
ALOGE("Widevine Drm HAL: failed to create crypto plugin, " \
|
||||
"invalid crypto scheme");
|
||||
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, plugin);
|
||||
return Void();
|
||||
}
|
||||
|
||||
plugin = new WVCryptoPlugin(initData.data(), initData.size(), getCDM());
|
||||
_hidl_cb(Status::OK, plugin);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
} // namespace V1_0
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace wvdrm
|
||||
61
libwvdrmengine/src_hidl/WVDrmFactory.cpp
Normal file
61
libwvdrmengine/src_hidl/WVDrmFactory.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVCdm"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "WVDrmFactory.h"
|
||||
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "WVCDMSingleton.h"
|
||||
#include "wv_content_decryption_module.h"
|
||||
#include "WVDrmPlugin.h"
|
||||
#include "WVUUID.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
namespace drm {
|
||||
namespace V1_0 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::drm::V1_0::Status;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
WVGenericCryptoInterface WVDrmFactory::sOemCryptoInterface;
|
||||
|
||||
Return<bool> WVDrmFactory::isCryptoSchemeSupported(
|
||||
const hidl_array<uint8_t, 16>& uuid) {
|
||||
return isWidevineUUID(uuid.data());
|
||||
}
|
||||
|
||||
Return<bool> WVDrmFactory::isContentTypeSupported(
|
||||
const hidl_string& initDataType) {
|
||||
return wvcdm::WvContentDecryptionModule::IsSupported(initDataType.c_str());
|
||||
}
|
||||
|
||||
Return<void> WVDrmFactory::createPlugin(
|
||||
const hidl_array<uint8_t, 16>& uuid,
|
||||
const hidl_string& appPackageName,
|
||||
createPlugin_cb _hidl_cb) {
|
||||
|
||||
WVDrmPlugin *plugin = NULL;
|
||||
if (!isCryptoSchemeSupported(uuid.data())) {
|
||||
ALOGE("Widevine Drm HAL: failed to create drm plugin, " \
|
||||
"invalid crypto scheme");
|
||||
_hidl_cb(Status::BAD_VALUE, plugin);
|
||||
return Void();
|
||||
}
|
||||
|
||||
plugin = new WVDrmPlugin(getCDM(), appPackageName.c_str(),
|
||||
&sOemCryptoInterface);
|
||||
_hidl_cb(Status::OK, plugin);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace widevine
|
||||
} // namespace V1_0
|
||||
} // namespace drm
|
||||
} // namespace hardware
|
||||
} // namespace wvdrm
|
||||
@@ -0,0 +1,6 @@
|
||||
service drm-widevine-hal-1-0 /vendor/bin/hw/android.hardware.drm@1.0-service.widevine
|
||||
class hal
|
||||
user media
|
||||
group mediadrm drmrpc
|
||||
ioprio rt 4
|
||||
writepid /dev/cpuset/foreground/tasks
|
||||
48
libwvdrmengine/src_hidl/service.cpp
Normal file
48
libwvdrmengine/src_hidl/service.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.drm@1.0-service.widevine"
|
||||
|
||||
#include <WVCryptoFactory.h>
|
||||
#include <WVDrmFactory.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
using ::android::hardware::configureRpcThreadpool;
|
||||
using ::android::hardware::joinRpcThreadpool;
|
||||
using ::android::sp;
|
||||
|
||||
using android::hardware::drm::V1_0::ICryptoFactory;
|
||||
using android::hardware::drm::V1_0::IDrmFactory;
|
||||
using wvdrm::hardware::drm::V1_0::widevine::WVCryptoFactory;
|
||||
using wvdrm::hardware::drm::V1_0::widevine::WVDrmFactory;
|
||||
|
||||
int main(int /* argc */, char** /* argv */) {
|
||||
ALOGD("android.hardware.drm@1.0-service.widevine starting...");
|
||||
|
||||
sp<IDrmFactory> drmFactory = new WVDrmFactory;
|
||||
sp<ICryptoFactory> cryptoFactory = new WVCryptoFactory;
|
||||
|
||||
configureRpcThreadpool(8, true /* callerWillJoin */);
|
||||
|
||||
// Setup hwbinder service
|
||||
CHECK_EQ(drmFactory->registerAsService("widevine"), android::NO_ERROR)
|
||||
<< "Failed to register Widevine Factory HAL";
|
||||
CHECK_EQ(cryptoFactory->registerAsService("widevine"), android::NO_ERROR)
|
||||
<< "Failed to register Widevine Crypto HAL";
|
||||
|
||||
joinRpcThreadpool();
|
||||
}
|
||||
Reference in New Issue
Block a user