Renaming of Usage Table related variables and types.

[ Merge of http://go/wvgerrit/164077 ]

This CL makes major changes to the names of variables and types that
are related to the usage table, header, entries, entry indexes, and
other related data.

The renaming followed these rules:
1)  "Usage table header" will exclusively refer to the header blob
    that is OEMCrypto specific.  The CDM class "UsageTableHeader"
    is the CDM-layer's abstraction around the "usage table" concept.
    The name has been updated to reflect that.
2)  The "Cdm" prefix is only used for the CDM-specific data types for
    the usage table and entry info.  It has been removed from
    OEMCrypto-specific types.
    - UsageTableHeader -> CdmUsageTable
    - CdmUsageTableHeader -> UsageTableHeader
    - CdmUsageEntry -> UsageEntry
3)  The "usage_" prefix has been removed from variables when the usage
    table or usage entries are the subject of the function or class.
4)  UsageEntryIndex is the type for entry indexes, instead of directly
    using uint32_t.  This matches how we wrap other types in
    "wv_cdm_types.h"
5)  Changed entry "number" to entry "index".
6)  Vectors of elements have been renamed to be either pluralized or
    have a suffix "_list".
7)  "Usage info" was occasionally being used to refer to the usage
    table or entries generally, rather than specifically secure-stop.
    - CryptoSession::HasUsageInfoSupport() -> HasUsageTableSupport()

The most major change is that the files "usage_table_header*" have
been renamed to be "cdm_usage_table*".

Bug: 242914226
Test: run_x86_64_tests and request_license_test
Change-Id: Iee98446b71f4f2934d3c9e0fb949eb05b84d1f8c
This commit is contained in:
Alex Dale
2022-12-20 15:21:10 -08:00
parent 0080d04579
commit 1603ba127f
24 changed files with 1321 additions and 1382 deletions

View File

@@ -838,7 +838,7 @@ bool DeviceFiles::StoreLicense(const CdmLicenseData& license_data,
app_params->set_value(iter->second);
}
license->set_usage_entry(license_data.usage_entry);
license->set_usage_entry_number(license_data.usage_entry_number);
license->set_usage_entry_index(license_data.usage_entry_index);
if (!license_data.drm_certificate.empty()) {
DeviceCertificate* device_certificate = license->mutable_drm_certificate();
if (!SetDeviceCertificate(license_data.drm_certificate,
@@ -929,8 +929,8 @@ bool DeviceFiles::RetrieveLicense(const std::string& key_set_id,
license.app_parameters(i).value();
}
license_data->usage_entry = license.usage_entry();
license_data->usage_entry_number =
static_cast<uint32_t>(license.usage_entry_number());
license_data->usage_entry_index =
static_cast<uint32_t>(license.usage_entry_index());
if (!license.has_drm_certificate()) {
license_data->drm_certificate.clear();
@@ -1010,8 +1010,8 @@ bool DeviceFiles::UnreserveLicenseId(const std::string& key_set_id) {
bool DeviceFiles::StoreUsageInfo(
const std::string& provider_session_token, const CdmKeyMessage& key_request,
const CdmKeyResponse& key_response, const std::string& usage_info_file_name,
const std::string& key_set_id, const std::string& usage_entry,
uint32_t usage_entry_number, const std::string& drm_certificate,
const std::string& key_set_id, const UsageEntry& usage_entry,
UsageEntryIndex usage_entry_index, const std::string& drm_certificate,
const CryptoWrappedKey& wrapped_private_key) {
RETURN_FALSE_IF_UNINITIALIZED();
video_widevine_client::sdk::File file;
@@ -1034,7 +1034,7 @@ bool DeviceFiles::StoreUsageInfo(
provider_session->set_license(key_response.data(), key_response.size());
provider_session->set_key_set_id(key_set_id.data(), key_set_id.size());
provider_session->set_usage_entry(usage_entry);
provider_session->set_usage_entry_number(usage_entry_number);
provider_session->set_usage_entry_index(usage_entry_index);
if (drm_certificate.size() > 0) {
uint32_t drm_certificate_id;
@@ -1235,15 +1235,15 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
const std::string& provider_session_token,
CdmKeyMessage* license_request,
CdmKeyResponse* license,
std::string* usage_entry,
uint32_t* usage_entry_number,
UsageEntry* usage_entry,
UsageEntryIndex* usage_entry_index,
std::string* drm_certificate,
CryptoWrappedKey* wrapped_private_key) {
RETURN_FALSE_IF_UNINITIALIZED();
RETURN_FALSE_IF_NULL(license_request);
RETURN_FALSE_IF_NULL(license);
RETURN_FALSE_IF_NULL(usage_entry);
RETURN_FALSE_IF_NULL(usage_entry_number);
RETURN_FALSE_IF_NULL(usage_entry_index);
RETURN_FALSE_IF_NULL(drm_certificate);
RETURN_FALSE_IF_NULL(wrapped_private_key);
@@ -1259,8 +1259,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
*license_request = file.usage_info().sessions(index).license_request();
*license = file.usage_info().sessions(index).license();
*usage_entry = file.usage_info().sessions(index).usage_entry();
*usage_entry_number = static_cast<uint32_t>(
file.usage_info().sessions(index).usage_entry_number());
*usage_entry_index = static_cast<UsageEntryIndex>(
file.usage_info().sessions(index).usage_entry_index());
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
drm_certificate->clear();
@@ -1285,14 +1285,14 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
bool DeviceFiles::RetrieveUsageInfoByKeySetId(
const std::string& usage_info_file_name, const std::string& key_set_id,
std::string* provider_session_token, CdmKeyMessage* license_request,
CdmKeyResponse* license, std::string* usage_entry,
uint32_t* usage_entry_number, std::string* drm_certificate,
CdmKeyResponse* license, UsageEntry* usage_entry,
UsageEntryIndex* usage_entry_index, std::string* drm_certificate,
CryptoWrappedKey* wrapped_private_key) {
RETURN_FALSE_IF_UNINITIALIZED();
RETURN_FALSE_IF_NULL(license_request);
RETURN_FALSE_IF_NULL(license);
RETURN_FALSE_IF_NULL(usage_entry);
RETURN_FALSE_IF_NULL(usage_entry_number);
RETURN_FALSE_IF_NULL(usage_entry_index);
RETURN_FALSE_IF_NULL(drm_certificate);
RETURN_FALSE_IF_NULL(wrapped_private_key);
@@ -1309,8 +1309,8 @@ bool DeviceFiles::RetrieveUsageInfoByKeySetId(
*license_request = file.usage_info().sessions(index).license_request();
*license = file.usage_info().sessions(index).license();
*usage_entry = file.usage_info().sessions(index).usage_entry();
*usage_entry_number = static_cast<uint32_t>(
file.usage_info().sessions(index).usage_entry_number());
*usage_entry_index = static_cast<UsageEntryIndex>(
file.usage_info().sessions(index).usage_entry_index());
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
drm_certificate->clear();
@@ -1354,7 +1354,7 @@ bool DeviceFiles::StoreUsageInfo(const std::string& usage_info_file_name,
provider_session->set_key_set_id(usage_data[i].key_set_id.data(),
usage_data[i].key_set_id.size());
provider_session->set_usage_entry(usage_data[i].usage_entry);
provider_session->set_usage_entry_number(usage_data[i].usage_entry_number);
provider_session->set_usage_entry_index(usage_data[i].usage_entry_index);
if (usage_data[i].drm_certificate.size() > 0) {
uint32_t drm_certificate_id;
@@ -1399,7 +1399,7 @@ bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
provider_session->set_license(usage_data.license);
provider_session->set_key_set_id(usage_data.key_set_id);
provider_session->set_usage_entry(usage_data.usage_entry);
provider_session->set_usage_entry_number(usage_data.usage_entry_number);
provider_session->set_usage_entry_index(usage_data.usage_entry_index);
if (usage_data.drm_certificate.size() > 0) {
uint32_t drm_certificate_id;
@@ -1448,8 +1448,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
(*usage_data)[i].license = file.usage_info().sessions(i).license();
(*usage_data)[i].key_set_id = file.usage_info().sessions(i).key_set_id();
(*usage_data)[i].usage_entry = file.usage_info().sessions(i).usage_entry();
(*usage_data)[i].usage_entry_number = static_cast<uint32_t>(
file.usage_info().sessions(i).usage_entry_number());
(*usage_data)[i].usage_entry_index = static_cast<uint32_t>(
file.usage_info().sessions(i).usage_entry_index());
if (!file.usage_info().sessions(i).has_drm_certificate_id()) {
(*usage_data)[i].drm_certificate.clear();
@@ -1490,8 +1490,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
usage_data->license = file.usage_info().sessions(index).license();
usage_data->key_set_id = file.usage_info().sessions(index).key_set_id();
usage_data->usage_entry = file.usage_info().sessions(index).usage_entry();
usage_data->usage_entry_number = static_cast<uint32_t>(
file.usage_info().sessions(index).usage_entry_number());
usage_data->usage_entry_index = static_cast<uint32_t>(
file.usage_info().sessions(index).usage_entry_index());
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
usage_data->drm_certificate.clear();
@@ -1629,8 +1629,8 @@ bool DeviceFiles::DeleteHlsAttributes(const std::string& key_set_id) {
}
bool DeviceFiles::StoreUsageTableInfo(
const CdmUsageTableHeader& usage_table_header,
const std::vector<CdmUsageEntryInfo>& usage_entry_info) {
const UsageTableHeader& table_header,
const std::vector<CdmUsageEntryInfo>& entry_info_list) {
RETURN_FALSE_IF_UNINITIALIZED();
// Fill in file information
@@ -1640,25 +1640,24 @@ bool DeviceFiles::StoreUsageTableInfo(
file.set_version(video_widevine_client::sdk::File::VERSION_1);
UsageTableInfo* usage_table_info = file.mutable_usage_table_info();
usage_table_info->set_usage_table_header(usage_table_header);
for (size_t i = 0; i < usage_entry_info.size(); ++i) {
usage_table_info->set_table_header(table_header);
for (size_t i = 0; i < entry_info_list.size(); ++i) {
UsageTableInfo_UsageEntryInfo* info =
usage_table_info->add_usage_entry_info();
info->set_key_set_id(usage_entry_info[i].key_set_id);
switch (usage_entry_info[i].storage_type) {
usage_table_info->add_entry_info_list();
info->set_key_set_id(entry_info_list[i].key_set_id);
switch (entry_info_list[i].storage_type) {
case kStorageLicense:
info->set_storage(
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE);
info->set_last_use_time(usage_entry_info[i].last_use_time);
info->set_last_use_time(entry_info_list[i].last_use_time);
info->set_offline_license_expiry_time(
usage_entry_info[i].offline_license_expiry_time);
entry_info_list[i].offline_license_expiry_time);
break;
case kStorageUsageInfo:
info->set_storage(
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO);
info->set_usage_info_file_name(
usage_entry_info[i].usage_info_file_name);
info->set_last_use_time(usage_entry_info[i].last_use_time);
info->set_usage_info_file_name(entry_info_list[i].usage_info_file_name);
info->set_last_use_time(entry_info_list[i].last_use_time);
break;
case kStorageTypeUnknown:
default:
@@ -1677,11 +1676,11 @@ bool DeviceFiles::StoreUsageTableInfo(
}
bool DeviceFiles::RetrieveUsageTableInfo(
CdmUsageTableHeader* usage_table_header,
std::vector<CdmUsageEntryInfo>* usage_entry_info, bool* lru_upgrade) {
UsageTableHeader* table_header,
std::vector<CdmUsageEntryInfo>* entry_info_list, bool* lru_upgrade) {
RETURN_FALSE_IF_UNINITIALIZED();
RETURN_FALSE_IF_NULL(usage_table_header);
RETURN_FALSE_IF_NULL(usage_entry_info);
RETURN_FALSE_IF_NULL(table_header);
RETURN_FALSE_IF_NULL(entry_info_list);
RETURN_FALSE_IF_NULL(lru_upgrade);
video_widevine_client::sdk::File file;
@@ -1713,28 +1712,28 @@ bool DeviceFiles::RetrieveUsageTableInfo(
*lru_upgrade = !usage_table_info.use_lru();
*usage_table_header = usage_table_info.usage_table_header();
usage_entry_info->resize(usage_table_info.usage_entry_info_size());
for (int i = 0; i < usage_table_info.usage_entry_info_size(); ++i) {
*table_header = usage_table_info.table_header();
entry_info_list->resize(usage_table_info.entry_info_list_size());
for (int i = 0; i < usage_table_info.entry_info_list_size(); ++i) {
const UsageTableInfo_UsageEntryInfo& info =
usage_table_info.usage_entry_info(i);
(*usage_entry_info)[i].key_set_id = info.key_set_id();
usage_table_info.entry_info_list(i);
(*entry_info_list)[i].key_set_id = info.key_set_id();
switch (info.storage()) {
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE:
(*usage_entry_info)[i].storage_type = kStorageLicense;
(*usage_entry_info)[i].last_use_time = info.last_use_time();
(*usage_entry_info)[i].offline_license_expiry_time =
(*entry_info_list)[i].storage_type = kStorageLicense;
(*entry_info_list)[i].last_use_time = info.last_use_time();
(*entry_info_list)[i].offline_license_expiry_time =
info.offline_license_expiry_time();
break;
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO:
(*usage_entry_info)[i].storage_type = kStorageUsageInfo;
(*usage_entry_info)[i].usage_info_file_name =
(*entry_info_list)[i].storage_type = kStorageUsageInfo;
(*entry_info_list)[i].usage_info_file_name =
info.usage_info_file_name();
(*usage_entry_info)[i].last_use_time = info.last_use_time();
(*entry_info_list)[i].last_use_time = info.last_use_time();
break;
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_UNKNOWN:
default:
(*usage_entry_info)[i].storage_type = kStorageTypeUnknown;
(*entry_info_list)[i].storage_type = kStorageTypeUnknown;
break;
}
}