Source release 18.7.0
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
# define CDM_VERSION_MAJOR 18
|
||||
#endif
|
||||
#ifndef CDM_VERSION_MINOR
|
||||
# define CDM_VERSION_MINOR 6
|
||||
# define CDM_VERSION_MINOR 7
|
||||
#endif
|
||||
#ifndef CDM_VERSION_PATCH
|
||||
# define CDM_VERSION_PATCH 0
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cdm.h"
|
||||
#include "log.h"
|
||||
#include "oec_device_features.h"
|
||||
#include "stderr_logger.h"
|
||||
#include "test_base.h"
|
||||
#include "test_host.h"
|
||||
@@ -22,13 +25,56 @@ std::string g_sandbox_id;
|
||||
namespace widevine {
|
||||
namespace {
|
||||
constexpr char kSandboxIdParam[] = "--sandbox_id=";
|
||||
constexpr char kCertPathParam[] = "--cert_path=";
|
||||
constexpr char kCertKeyPathParam[] = "--cert_key_path=";
|
||||
|
||||
// Following the pattern established by help text in test_base.cpp
|
||||
constexpr char kExtraHelpText[] =
|
||||
" --sandbox_id=<sandbox_id>\n"
|
||||
" Specifies the Sandbox ID that should be sent to OEMCrypto via\n"
|
||||
" OEMCrypto_SetSandbox(). On most platforms, since Sandbox IDs are not\n"
|
||||
" in use, this parameter should be omitted.\n";
|
||||
" in use, this parameter should be omitted.\n"
|
||||
" --cert_path=<cert_path>\n"
|
||||
" Path to a preloaded DRM certificate. This may speed up some tests\n"
|
||||
" by skipping the provisioning step. On most platforms, this parameter\n"
|
||||
" parameter should be omitted.\n"
|
||||
" --cert_key_path=<cert_key_path>\n"
|
||||
" Path to a key in preloaded DRM certificate. This should only be used\n"
|
||||
" if the device has a baked in cert.\n";
|
||||
|
||||
bool ReadFile(const std::string& path, std::string* output) {
|
||||
output->clear();
|
||||
std::ifstream fs(path, std::ios::in | std::ios::binary);
|
||||
if (!fs) {
|
||||
LOGE("Failed to open %s: %s", path.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
std::stringstream buffer;
|
||||
buffer << fs.rdbuf();
|
||||
*output = buffer.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reads a file from the command line arguments.
|
||||
// The file path is expected to be the first argument after the flag.
|
||||
// For example, if the flag is "--cert_path=" and the command line is
|
||||
// cdm_test_runner --cert_path=/path/to/cert
|
||||
// then the file at /path/to/cert will be read.
|
||||
// The flag will be removed from the command line arguments.
|
||||
bool ReadFileFromArg(const char* path_flag, std::vector<std::string>& args,
|
||||
std::string* data) {
|
||||
auto path_iter = std::find_if(std::begin(args) + 1, std::end(args),
|
||||
[path_flag](const std::string& elem) -> bool {
|
||||
return elem.find(path_flag) == 0;
|
||||
});
|
||||
if (path_iter != std::end(args)) {
|
||||
const std::string path = path_iter->substr(strlen(path_flag));
|
||||
args.erase(path_iter);
|
||||
return ReadFile(path, data);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int Main(Cdm::IStorage* storage, Cdm::IClock* clock, Cdm::ITimer* timer,
|
||||
@@ -50,6 +96,15 @@ int Main(Cdm::IStorage* storage, Cdm::IClock* clock, Cdm::ITimer* timer,
|
||||
(void)status; // status is now used when assertions are turned off.
|
||||
assert(status == Cdm::kSuccess);
|
||||
|
||||
std::string data;
|
||||
if (ReadFileFromArg(kCertPathParam, args, &data)) {
|
||||
g_host->set_baked_in_cert(data);
|
||||
}
|
||||
if (ReadFileFromArg(kCertKeyPathParam, args, &data)) {
|
||||
wvoec::global_features.set_rsa_test_key(
|
||||
std::vector<uint8_t>(data.begin(), data.end()));
|
||||
}
|
||||
|
||||
std::vector<const char*> new_argv(args.size());
|
||||
std::transform(
|
||||
std::begin(args), std::end(args), std::begin(new_argv),
|
||||
|
||||
@@ -137,6 +137,11 @@ bool TestHost::Storage::SaveToString(std::string* data) const {
|
||||
}
|
||||
|
||||
bool TestHost::Storage::read(const std::string& name, std::string* data) {
|
||||
if (wvutil::kLegacyCertificateFileName == name &&
|
||||
!g_host->baked_in_cert().empty()) {
|
||||
*data = g_host->baked_in_cert();
|
||||
return true;
|
||||
}
|
||||
StorageMap::iterator it = files_.find(name);
|
||||
bool ok = it != files_.end();
|
||||
LOGV("read file: %s: %s", name.c_str(), ok ? "ok" : "fail");
|
||||
@@ -148,12 +153,21 @@ bool TestHost::Storage::read(const std::string& name, std::string* data) {
|
||||
bool TestHost::Storage::write(const std::string& name,
|
||||
const std::string& data) {
|
||||
LOGV("write file: %s", name.c_str());
|
||||
if (wvutil::kLegacyCertificateFileName == name &&
|
||||
!g_host->baked_in_cert().empty()) {
|
||||
return false;
|
||||
}
|
||||
if (!CheckFilename(name)) return false;
|
||||
files_[name] = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestHost::Storage::exists(const std::string& name) {
|
||||
if (wvutil::kLegacyCertificateFileName == name &&
|
||||
!g_host->baked_in_cert().empty()) {
|
||||
LOGV("exists? %s: always", name.c_str());
|
||||
return true;
|
||||
}
|
||||
StorageMap::iterator it = files_.find(name);
|
||||
bool ok = it != files_.end();
|
||||
LOGV("exists? %s: %s", name.c_str(), ok ? "true" : "false");
|
||||
@@ -174,6 +188,11 @@ bool TestHost::Storage::remove(const std::string& name) {
|
||||
}
|
||||
|
||||
int32_t TestHost::Storage::size(const std::string& name) {
|
||||
if (wvutil::kLegacyCertificateFileName == name &&
|
||||
!g_host->baked_in_cert().empty()) {
|
||||
LOGV("size? %s: always", name.c_str());
|
||||
return static_cast<int32_t>(g_host->baked_in_cert().size());
|
||||
}
|
||||
StorageMap::iterator it = files_.find(name);
|
||||
bool ok = (it != files_.end());
|
||||
LOGV("size? %s: %s", name.c_str(), ok ? "ok" : "fail");
|
||||
|
||||
@@ -69,6 +69,13 @@ class TestHost : public widevine::Cdm::IClock,
|
||||
void setTimeout(int64_t delay_ms, IClient* client, void* context) override;
|
||||
void cancel(IClient* client) override;
|
||||
|
||||
// If this is set, then the storage will return this as a baked in cert.
|
||||
// Trying to write a new cert will generate an error.
|
||||
const std::string& baked_in_cert() const { return baked_in_cert_; };
|
||||
void set_baked_in_cert(const std::string& baked_in_cert) {
|
||||
baked_in_cert_ = baked_in_cert;
|
||||
};
|
||||
|
||||
private:
|
||||
struct Timer {
|
||||
Timer(int64_t expiry_time, IClient* client, void* context)
|
||||
@@ -95,6 +102,7 @@ class TestHost : public widevine::Cdm::IClock,
|
||||
|
||||
Storage global_storage_;
|
||||
Storage per_origin_storage_;
|
||||
std::string baked_in_cert_;
|
||||
};
|
||||
|
||||
// Owned and managed by the test runner.
|
||||
|
||||
Reference in New Issue
Block a user