Merge "Update secure stops by key set ID."
This commit is contained in:
@@ -262,7 +262,6 @@ class DeviceFiles {
|
|||||||
virtual bool StoreUsageInfo(const std::string& usage_info_file_name,
|
virtual bool StoreUsageInfo(const std::string& usage_info_file_name,
|
||||||
const std::vector<CdmUsageData>& usage_data);
|
const std::vector<CdmUsageData>& usage_data);
|
||||||
virtual bool UpdateUsageInfo(const std::string& usage_info_file_name,
|
virtual bool UpdateUsageInfo(const std::string& usage_info_file_name,
|
||||||
const std::string& provider_session_token,
|
|
||||||
const CdmUsageData& usage_data);
|
const CdmUsageData& usage_data);
|
||||||
|
|
||||||
virtual bool StoreHlsAttributes(const std::string& key_set_id,
|
virtual bool StoreHlsAttributes(const std::string& key_set_id,
|
||||||
|
|||||||
@@ -1159,8 +1159,7 @@ bool CdmSession::UpdateUsageInfo() {
|
|||||||
usage_data.usage_entry_index = usage_entry_index_;
|
usage_data.usage_entry_index = usage_entry_index_;
|
||||||
|
|
||||||
return file_handle_->UpdateUsageInfo(
|
return file_handle_->UpdateUsageInfo(
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), usage_provider_session_token_,
|
DeviceFiles::GetUsageInfoFileName(app_id), usage_data);
|
||||||
usage_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdmSession::UpdateRequestLatencyTiming(CdmResponseType sts) {
|
void CdmSession::UpdateRequestLatencyTiming(CdmResponseType sts) {
|
||||||
|
|||||||
@@ -1379,7 +1379,6 @@ bool DeviceFiles::StoreUsageInfo(const std::string& usage_info_file_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
|
bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
|
||||||
const std::string& provider_session_token,
|
|
||||||
const CdmUsageData& usage_data) {
|
const CdmUsageData& usage_data) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
|
|
||||||
@@ -1388,43 +1387,52 @@ bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
|
|||||||
LOGE("Usage info file does not exist");
|
LOGE("Usage info file does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RetrieveHashedFile(usage_info_file_name, &file) != kNoError) {
|
if (RetrieveHashedFile(usage_info_file_name, &file) != kNoError) {
|
||||||
LOGE("Unable to retrieve usage info file");
|
LOGE("Unable to retrieve usage info file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
video_widevine_client::sdk::UsageInfo* usage_info = file.mutable_usage_info();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (; index < file.usage_info().sessions_size(); ++index) {
|
for (; index < usage_info->sessions_size(); ++index) {
|
||||||
if (file.usage_info().sessions(index).token() == provider_session_token) {
|
// Use key set ID to identify usage info. PST is not guaranteed
|
||||||
UsageInfo* usage_info = file.mutable_usage_info();
|
// to be unique.
|
||||||
UsageInfo_ProviderSession* provider_session =
|
if (usage_info->sessions(index).key_set_id() == usage_data.key_set_id)
|
||||||
usage_info->mutable_sessions(index);
|
break;
|
||||||
provider_session->set_license_request(usage_data.license_request);
|
}
|
||||||
provider_session->set_license(usage_data.license);
|
if (index == usage_info->sessions_size()) {
|
||||||
provider_session->set_key_set_id(usage_data.key_set_id);
|
LOGE("Failed to find usage info: key_set_id = %s",
|
||||||
provider_session->set_usage_entry(usage_data.usage_entry);
|
IdToString(usage_data.key_set_id));
|
||||||
provider_session->set_usage_entry_index(usage_data.usage_entry_index);
|
return false;
|
||||||
|
|
||||||
if (usage_data.drm_certificate.size() > 0) {
|
|
||||||
uint32_t drm_certificate_id;
|
|
||||||
if (!FindOrInsertUsageCertificate(usage_data.drm_certificate,
|
|
||||||
usage_data.wrapped_private_key,
|
|
||||||
usage_info, &drm_certificate_id)) {
|
|
||||||
LOGE("Unable to find a certificate in to update the usage info");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
provider_session->set_drm_certificate_id(drm_certificate_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string serialized_file;
|
|
||||||
file.SerializeToString(&serialized_file);
|
|
||||||
return StoreFileWithHash(usage_info_file_name, serialized_file) ==
|
|
||||||
kNoError;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
video_widevine_client::sdk::UsageInfo::ProviderSession* session =
|
||||||
|
usage_info->mutable_sessions(index);
|
||||||
|
// Verify that the PST are the same.
|
||||||
|
if (session->token() != usage_data.provider_session_token) {
|
||||||
|
LOGE("Mismatch PST: key_set_id = %s", IdToString(usage_data.key_set_id));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update session.
|
||||||
|
session->set_license_request(usage_data.license_request);
|
||||||
|
session->set_license(usage_data.license);
|
||||||
|
session->set_usage_entry(usage_data.usage_entry);
|
||||||
|
session->set_usage_entry_index(usage_data.usage_entry_index);
|
||||||
|
if (usage_data.drm_certificate.size() > 0) {
|
||||||
|
uint32_t drm_certificate_id;
|
||||||
|
if (!FindOrInsertUsageCertificate(usage_data.drm_certificate,
|
||||||
|
usage_data.wrapped_private_key,
|
||||||
|
usage_info, &drm_certificate_id)) {
|
||||||
|
LOGE("Unable to find a certificate in to update the usage info");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
session->set_drm_certificate_id(drm_certificate_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string serialized_file;
|
||||||
|
file.SerializeToString(&serialized_file);
|
||||||
|
return StoreFileWithHash(usage_info_file_name, serialized_file) == kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user