Update Simulcrypt ECMg
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "common/content_id_util.h"
|
||||
|
||||
#include "glog/logging.h"
|
||||
#include "common/error_space.h"
|
||||
#include "common/status.h"
|
||||
#include "license_server_sdk/internal/parse_content_id.h"
|
||||
@@ -18,33 +19,14 @@
|
||||
|
||||
namespace widevine {
|
||||
|
||||
// TODO(user): Move the util methods from
|
||||
// //license_server_sdk/internal/parse_content_id.h
|
||||
// into this file.
|
||||
|
||||
Status GetContentIdFromExternalLicenseRequest(
|
||||
const ExternalLicenseRequest& external_license_request,
|
||||
std::string* content_id) {
|
||||
LicenseRequest::ContentIdentification content_identification =
|
||||
external_license_request.content_id();
|
||||
WidevinePsshData widevine_pssh_data;
|
||||
if (content_identification.has_widevine_pssh_data()) {
|
||||
widevine_pssh_data.ParseFromString(
|
||||
content_identification.widevine_pssh_data().pssh_data(0));
|
||||
} else if (content_identification.has_webm_key_id()) {
|
||||
widevine_pssh_data.ParseFromString(
|
||||
content_identification.webm_key_id().header());
|
||||
} else if (content_identification.has_init_data()) {
|
||||
ContentInfo content_info;
|
||||
if (ParseContentId(content_identification, &content_info).ok()) {
|
||||
widevine_pssh_data =
|
||||
content_info.content_info_entry(0).pssh().widevine_data();
|
||||
}
|
||||
}
|
||||
*content_id = widevine_pssh_data.content_id();
|
||||
WidevinePsshData pssh_data;
|
||||
Status status = ParsePsshData(external_license_request, &pssh_data);
|
||||
*content_id = pssh_data.content_id();
|
||||
return OkStatus();
|
||||
}
|
||||
|
||||
Status GetContentIdFromSignedExternalLicenseRequest(
|
||||
const SignedMessage& signed_message, std::string* content_id) {
|
||||
if (signed_message.type() != SignedMessage::EXTERNAL_LICENSE_REQUEST) {
|
||||
@@ -61,4 +43,41 @@ Status GetContentIdFromSignedExternalLicenseRequest(
|
||||
content_id);
|
||||
}
|
||||
|
||||
Status ParsePsshData(ExternalLicenseRequest external_license_request,
|
||||
WidevinePsshData* widevine_pssh_data) {
|
||||
if (!external_license_request.has_content_id()) {
|
||||
std::string error = "ExternalLicenseRequest does not include ContentId";
|
||||
LOG(ERROR) << error
|
||||
<< ", request = " << external_license_request.ShortDebugString();
|
||||
return Status(error_space, MISSING_CONTENT_ID, error);
|
||||
}
|
||||
ContentInfo content_info;
|
||||
Status status =
|
||||
ParseContentId(external_license_request.content_id(), &content_info);
|
||||
if (!status.ok()) {
|
||||
std::string error =
|
||||
"Unable to retrieve ContentId from ExternalLicenseRequest";
|
||||
LOG(ERROR) << error << ", status = " << status
|
||||
<< ", request = " << external_license_request.ShortDebugString();
|
||||
return Status(error_space, MISSING_CONTENT_ID, error);
|
||||
}
|
||||
switch (external_license_request.content_id().init_data().init_data_type()) {
|
||||
case LicenseRequest::ContentIdentification::InitData::WEBM:
|
||||
widevine_pssh_data->ParseFromString(
|
||||
content_info.content_info_entry(0).key_ids(0));
|
||||
break;
|
||||
default:
|
||||
*widevine_pssh_data =
|
||||
content_info.content_info_entry(0).pssh().widevine_data();
|
||||
break;
|
||||
}
|
||||
if (widevine_pssh_data->content_id().empty()) {
|
||||
std::string error =
|
||||
"Missing ContentId within Pssh data for ExternalLicenseRequest";
|
||||
LOG(ERROR) << error
|
||||
<< ", request = " << external_license_request.ShortDebugString();
|
||||
return Status(error_space, MISSING_CONTENT_ID, error);
|
||||
}
|
||||
return OkStatus();
|
||||
}
|
||||
} // namespace widevine
|
||||
|
||||
Reference in New Issue
Block a user