Merge "DRM VTS Vendor module for castkey" into tm-qpr-dev am: c07e9c1ff7
Original change: https://googleplex-android-review.googlesource.com/c/device/google/tangorpro/+/20753280 Change-Id: I5c3ec2300c2f71df736724785e2fb63a788c75d2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
61e700758c
4 changed files with 252 additions and 0 deletions
42
cast_auth/mediadrm/vts/vendor_module/Android.bp
Normal file
42
cast_auth/mediadrm/vts/vendor_module/Android.bp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Builds libvtscastauth.so
|
||||||
|
|
||||||
|
cc_library_shared {
|
||||||
|
name: "libvtscastauth",
|
||||||
|
|
||||||
|
include_dirs: [
|
||||||
|
"hardware/interfaces/drm/1.0/vts/functional",
|
||||||
|
"vendor/widevine/libwvdrmengine/cdm/include",
|
||||||
|
"vendor/widevine/libwvdrmengine/cdm/core/include",
|
||||||
|
"vendor/widevine/libwvdrmengine/cdm/core/test",
|
||||||
|
"vendor/widevine/libwvdrmengine/cdm/util/include",
|
||||||
|
"system/libbase/include",
|
||||||
|
"system/libvintf/include",
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
srcs: [
|
||||||
|
"factory.cpp",
|
||||||
|
"vts_module.cpp",
|
||||||
|
":vts_cdm_core_test_srcs",
|
||||||
|
],
|
||||||
|
|
||||||
|
static_libs: [
|
||||||
|
"libgtest",
|
||||||
|
"libcdm",
|
||||||
|
"libcdm_utils",
|
||||||
|
],
|
||||||
|
|
||||||
|
shared_libs: [
|
||||||
|
"libbase",
|
||||||
|
"libbinder_ndk",
|
||||||
|
"libcrypto",
|
||||||
|
"liblog",
|
||||||
|
"libssl",
|
||||||
|
"libutils",
|
||||||
|
],
|
||||||
|
|
||||||
|
relative_install_path: "drm-vts-test-libs",
|
||||||
|
|
||||||
|
proprietary: true,
|
||||||
|
|
||||||
|
}
|
10
cast_auth/mediadrm/vts/vendor_module/factory.cpp
Normal file
10
cast_auth/mediadrm/vts/vendor_module/factory.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include "drm_hal_vendor_module_api.h"
|
||||||
|
#include "vts_module.h"
|
||||||
|
|
||||||
|
namespace castkey_vts {
|
||||||
|
extern "C" {
|
||||||
|
DrmHalVTSVendorModule *vendorModuleFactory() {
|
||||||
|
return new CastkeyVTSVendorModule_V1();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}; // namespace castkey_vts
|
156
cast_auth/mediadrm/vts/vendor_module/vts_module.cpp
Normal file
156
cast_auth/mediadrm/vts/vendor_module/vts_module.cpp
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
#include "license_request.h"
|
||||||
|
#include "string_conversions.h"
|
||||||
|
#include "url_request.h"
|
||||||
|
#include "utils/Log.h"
|
||||||
|
#include "vts_module.h"
|
||||||
|
|
||||||
|
using std::array;
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
using wvutil::a2b_hex;
|
||||||
|
using wvutil::b2a_hex;
|
||||||
|
using wvcdm::LicenseRequest;
|
||||||
|
using wvcdm::UrlRequest;
|
||||||
|
|
||||||
|
namespace castkey_vts {
|
||||||
|
|
||||||
|
const int kHttpOk = 200;
|
||||||
|
|
||||||
|
vector<uint8_t> CastkeyVTSVendorModule_V1::getUUID() const {
|
||||||
|
uint8_t uuid[16] = {
|
||||||
|
0xBC, 0xB4, 0x81, 0xCB, 0xA1, 0xD5, 0x42, 0xAF,
|
||||||
|
0xB1, 0xE3, 0x7B, 0xFF, 0x14, 0x73, 0xEB, 0x85
|
||||||
|
};
|
||||||
|
return vector<uint8_t>(uuid, uuid + sizeof(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogResponseError(const string& message, int http_status_code) {
|
||||||
|
ALOGD("HTTP Status code = %d", http_status_code);
|
||||||
|
ALOGD("HTTP response(%zd): %s", message.size(), b2a_hex(message).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint8_t> CastkeyVTSVendorModule_V1::handleProvisioningRequest(
|
||||||
|
const vector<uint8_t>& provisioning_request,
|
||||||
|
const string& server_url) {
|
||||||
|
|
||||||
|
// Use secure connection and chunk transfer coding.
|
||||||
|
UrlRequest url_request(server_url);
|
||||||
|
EXPECT_TRUE(url_request.is_connected()) << "Fail to connect to "
|
||||||
|
<< server_url;
|
||||||
|
url_request.PostCertRequestInQueryString(toString(provisioning_request));
|
||||||
|
string reply;
|
||||||
|
EXPECT_TRUE(url_request.GetResponse(&reply));
|
||||||
|
|
||||||
|
int http_status_code = url_request.GetStatusCode(reply);
|
||||||
|
if (kHttpOk != http_status_code) {
|
||||||
|
LogResponseError(reply, http_status_code);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(kHttpOk, http_status_code);
|
||||||
|
vector<uint8_t> result(reply.begin(), reply.end());
|
||||||
|
return vector<uint8_t>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint8_t> CastkeyVTSVendorModule_V1::handleKeyRequest(
|
||||||
|
const vector<uint8_t>&key_request, const string& server_url) {
|
||||||
|
|
||||||
|
// Use secure connection and chunk transfer coding.
|
||||||
|
UrlRequest url_request(server_url);
|
||||||
|
EXPECT_TRUE(url_request.is_connected()) << "Fail to connect to "
|
||||||
|
<< server_url;
|
||||||
|
url_request.PostRequest(toString(key_request));
|
||||||
|
string reply;
|
||||||
|
EXPECT_TRUE(url_request.GetResponse(&reply));
|
||||||
|
|
||||||
|
int httpStatusCode = url_request.GetStatusCode(reply);
|
||||||
|
if (httpStatusCode != kHttpOk) {
|
||||||
|
LogResponseError(reply, httpStatusCode);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(httpStatusCode, kHttpOk);
|
||||||
|
|
||||||
|
string drm_msg;
|
||||||
|
if (kHttpOk == httpStatusCode) {
|
||||||
|
LicenseRequest lic_request;
|
||||||
|
lic_request.GetDrmMessage(reply, drm_msg);
|
||||||
|
ALOGV("HTTP response body: (%zd bytes)", drm_msg.size());
|
||||||
|
}
|
||||||
|
vector<uint8_t> result(drm_msg.begin(), drm_msg.end());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<DrmHalVTSVendorModule_V1::ContentConfiguration>
|
||||||
|
CastkeyVTSVendorModule_V1::getContentConfigurations() const {
|
||||||
|
|
||||||
|
vector<DrmHalVTSVendorModule_V1::ContentConfiguration> configurations;
|
||||||
|
{
|
||||||
|
const string serverUrl = "https://proxy.uat.widevine.com/proxy";
|
||||||
|
const vector<uint8_t> initData = a2b_hex(
|
||||||
|
"00000042" // blob size
|
||||||
|
"70737368" // "pssh"
|
||||||
|
"00000000" // flags
|
||||||
|
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||||
|
"00000022" // pssh data size
|
||||||
|
"08011a0d7769646576696e655f746573" // pssh data...
|
||||||
|
"74220f73747265616d696e675f636c69"
|
||||||
|
"7031");
|
||||||
|
const vector<uint8_t> keyId = a2b_hex("371EA35E1A985D75D198A7F41020DC23");
|
||||||
|
const vector<uint8_t> keyValue = a2b_hex("371EA35E1A985D75D198A7F41020DC23");
|
||||||
|
const vector<DrmHalVTSVendorModule_V1::ContentConfiguration::Key> keys = {
|
||||||
|
{
|
||||||
|
.isSecure = false,
|
||||||
|
.keyId = keyId,
|
||||||
|
.clearContentKey = keyValue
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ContentConfiguration config = {
|
||||||
|
.name = "streaming_clip1",
|
||||||
|
.serverUrl = serverUrl,
|
||||||
|
.initData = initData,
|
||||||
|
.mimeType = "cenc",
|
||||||
|
.optionalParameters = map<string, string>(),
|
||||||
|
.policy.allowOffline = false,
|
||||||
|
.keys = keys
|
||||||
|
};
|
||||||
|
configurations.push_back(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Content Configuration #2 - Allows offline playback
|
||||||
|
{
|
||||||
|
const string serverUrl = "https://proxy.uat.widevine.com/proxy";
|
||||||
|
const vector<uint8_t> initData = a2b_hex(
|
||||||
|
"00000042" // blob size
|
||||||
|
"70737368" // "pssh"
|
||||||
|
"00000000" // flags
|
||||||
|
"edef8ba979d64acea3c827dcd51d21ed" // Widevine system id
|
||||||
|
"00000020" // pssh data size
|
||||||
|
"08011a0d7769646576696e655f746573" // pssh data...
|
||||||
|
"74220d6f66666c696e655f636c697033"
|
||||||
|
"7031");
|
||||||
|
const vector<uint8_t> keyId = a2b_hex("3260f39e12ccf653529990168a3583ff");
|
||||||
|
const vector<uint8_t> keyValue = a2b_hex("8040c019929b2cc116a2e8dac739eafa");
|
||||||
|
const vector<DrmHalVTSVendorModule_V1::ContentConfiguration::Key> keys = {
|
||||||
|
{
|
||||||
|
.isSecure = false,
|
||||||
|
.keyId = keyId,
|
||||||
|
.clearContentKey = keyValue
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ContentConfiguration config = {
|
||||||
|
.name = "offline_clip3",
|
||||||
|
.serverUrl = serverUrl,
|
||||||
|
.initData = initData,
|
||||||
|
.mimeType = "cenc",
|
||||||
|
.optionalParameters = map<string, string>(),
|
||||||
|
.policy.allowOffline = true,
|
||||||
|
.keys = keys
|
||||||
|
};
|
||||||
|
configurations.push_back(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
return configurations;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // namespace castkey_vts
|
44
cast_auth/mediadrm/vts/vendor_module/vts_module.h
Normal file
44
cast_auth/mediadrm/vts/vendor_module/vts_module.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef CASTKEY_VENDOR_VTS_MODULE
|
||||||
|
#define CASTKEY_VENDOR_VTS_MODULE
|
||||||
|
|
||||||
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#include "drm_hal_vendor_module_api.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the DrmHalVTSVendorModule_V1 for Castkey. Refer to
|
||||||
|
* drm_hal_vendor_module_api.h for more details.
|
||||||
|
*/
|
||||||
|
namespace castkey_vts {
|
||||||
|
|
||||||
|
class CastkeyVTSVendorModule_V1 : public DrmHalVTSVendorModule_V1 {
|
||||||
|
public:
|
||||||
|
CastkeyVTSVendorModule_V1() {}
|
||||||
|
virtual ~CastkeyVTSVendorModule_V1() {}
|
||||||
|
|
||||||
|
virtual vector<uint8_t> getUUID() const;
|
||||||
|
|
||||||
|
virtual vector<uint8_t> handleProvisioningRequest(const vector<uint8_t>&
|
||||||
|
provisioningRequest, const std::string& url);
|
||||||
|
|
||||||
|
virtual vector<uint8_t> handleKeyRequest(const vector<uint8_t>&
|
||||||
|
keyRequest, const std::string& serverUrl);
|
||||||
|
|
||||||
|
virtual std::vector<ContentConfiguration>
|
||||||
|
getContentConfigurations() const;
|
||||||
|
|
||||||
|
virtual std::string getServiceName() const {return "castkey";}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CastkeyVTSVendorModule_V1(const CastkeyVTSVendorModule_V1&) = delete;
|
||||||
|
void operator=(const CastkeyVTSVendorModule_V1&) = delete;
|
||||||
|
|
||||||
|
std::string toString(std::vector<uint8_t> vector) {
|
||||||
|
return std::string(vector.begin(), vector.end());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}; // namespace castkey_vts
|
||||||
|
|
||||||
|
#endif //CASTKEY_VENDOR_VTS_MODULE
|
Loading…
Add table
Add a link
Reference in a new issue