Log cleanup and reformatting for core/ (Part 2-6)
[ Merge of http://go/wvgerrit/83423 ] [ Merge of http://go/wvgerrit/83424 ] [ Merge of http://go/wvgerrit/83425 ] [ Merge of http://go/wvgerrit/83426 ] [ Merge of http://go/wvgerrit/83427 ] Types of cleanup: - Removed function / class prefixes from the logs. - Fixed log string format options to match the types passed - Corrected small spelling mistakes / typos - _Tried_ to make the log format more consistent - Added static_cast<int> conversion on enumerations when logged - Changed several LOGE to LOGW and vice versa - Used LOGE if the triggering condition stops the method/function from completing its task - Used LOGW if the triggering condition changes the expected outcome but does not stop the rest of the method/function's task - Changed several instances of `NULL` to `nullptr` - Ran clang-format on files after cleanup This is part of a larger code quality effort in Widevine DRM. Test: WV linux unittests and WV Android unit tests Bug: 134460638 Bug: 134365840 Bug: 136123217 Change-Id: I958ec70ef99eef95c38dbebd7a1acd62ef304145
This commit is contained in:
@@ -176,8 +176,8 @@ static std::vector<CryptoKey> ExtractContentKeys(const License& license) {
|
||||
}
|
||||
|
||||
CdmLicense::CdmLicense(const CdmSessionId& session_id)
|
||||
: crypto_session_(NULL),
|
||||
policy_engine_(NULL),
|
||||
: crypto_session_(nullptr),
|
||||
policy_engine_(nullptr),
|
||||
session_id_(session_id),
|
||||
initialized_(false),
|
||||
renew_with_client_id_(false),
|
||||
@@ -187,8 +187,8 @@ CdmLicense::CdmLicense(const CdmSessionId& session_id)
|
||||
license_key_type_(kLicenseKeyTypeContent) {}
|
||||
|
||||
CdmLicense::CdmLicense(const CdmSessionId& session_id, Clock* clock)
|
||||
: crypto_session_(NULL),
|
||||
policy_engine_(NULL),
|
||||
: crypto_session_(nullptr),
|
||||
policy_engine_(nullptr),
|
||||
session_id_(session_id),
|
||||
initialized_(false),
|
||||
renew_with_client_id_(false),
|
||||
@@ -205,24 +205,24 @@ bool CdmLicense::Init(const std::string& client_token,
|
||||
const std::string& device_id, bool use_privacy_mode,
|
||||
const std::string& signed_service_certificate,
|
||||
CryptoSession* session, PolicyEngine* policy_engine) {
|
||||
if (clock_.get() == NULL) {
|
||||
LOGE("CdmLicense::Init: clock parameter not provided");
|
||||
if (clock_.get() == nullptr) {
|
||||
LOGE("Clock parameter not provided");
|
||||
return false;
|
||||
}
|
||||
if (session_id_.empty()) {
|
||||
LOGE("CdmLicense::Init: empty session id provided");
|
||||
LOGE("Session ID not provided");
|
||||
return false;
|
||||
}
|
||||
if (client_token.size() == 0) {
|
||||
LOGE("CdmLicense::Init: empty client token provided");
|
||||
LOGE("Client token not provided");
|
||||
return false;
|
||||
}
|
||||
if (session == NULL || !session->IsOpen()) {
|
||||
LOGE("CdmLicense::Init: crypto session not provided or not open");
|
||||
if (session == nullptr || !session->IsOpen()) {
|
||||
LOGE("Crypto session not provided or not open");
|
||||
return false;
|
||||
}
|
||||
if (policy_engine == NULL) {
|
||||
LOGE("CdmLicense::Init: no policy engine provided");
|
||||
if (policy_engine == nullptr) {
|
||||
LOGE("Policy engine not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ bool CdmLicense::Init(const std::string& client_token,
|
||||
}
|
||||
if (!service_certificate_.has_certificate() &&
|
||||
!Properties::allow_service_certificate_requests()) {
|
||||
LOGE("CdmLicense::Init: Required service certificate not provided");
|
||||
LOGE("Required service certificate not provided");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
const CdmAppParameterMap& app_parameters, CdmKeyMessage* signed_request,
|
||||
std::string* server_url) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: not initialized");
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_4;
|
||||
}
|
||||
if (init_data.IsEmpty() && stored_init_data_.get()) {
|
||||
@@ -264,20 +264,19 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
}
|
||||
wrapped_keys_ = init_data.ExtractWrappedKeys();
|
||||
if (!init_data.is_supported()) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: unsupported init data type (%s)",
|
||||
init_data.type().c_str());
|
||||
LOGE("Unsupported init data type: type = %s", init_data.type().c_str());
|
||||
return INVALID_PARAMETERS_LIC_3;
|
||||
}
|
||||
if (init_data.IsEmpty()) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: empty init data provided");
|
||||
LOGE("Init data is empty");
|
||||
return INVALID_PARAMETERS_LIC_4;
|
||||
}
|
||||
if (!signed_request) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: no signed request provided");
|
||||
if (signed_request == nullptr) {
|
||||
LOGE("Output parameter |signed_request| not provided");
|
||||
return INVALID_PARAMETERS_LIC_6;
|
||||
}
|
||||
if (!server_url) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: no server url provided");
|
||||
if (server_url == nullptr) {
|
||||
LOGE("Output parameter |server_url| not provided");
|
||||
return INVALID_PARAMETERS_LIC_7;
|
||||
}
|
||||
|
||||
@@ -285,18 +284,14 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
// configuration, request service certificate or declare error
|
||||
if (use_privacy_mode_ && !service_certificate_.has_certificate()) {
|
||||
if (!Properties::allow_service_certificate_requests()) {
|
||||
LOGE(
|
||||
"CdmLicense::PrepareKeyRequest: failure with privacy mode - "
|
||||
"no service certificate.");
|
||||
LOGE("Privacy mode failure: No service certificate");
|
||||
return PRIVACY_MODE_ERROR_1;
|
||||
}
|
||||
|
||||
stored_init_data_.reset(new InitializationData(init_data));
|
||||
|
||||
if (!ServiceCertificate::GetRequest(signed_request)) {
|
||||
LOGE(
|
||||
"CdmLicense::PrepareKeyRequest: failed to prepare a service "
|
||||
"certificated request");
|
||||
LOGE("Failed to prepare service certificated request");
|
||||
return LICENSE_REQUEST_SERVICE_CERTIFICATE_GENERATION_ERROR;
|
||||
}
|
||||
|
||||
@@ -333,7 +328,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
return LICENSE_REQUEST_NONCE_GENERATION_ERROR;
|
||||
}
|
||||
license_request.set_key_control_nonce(nonce);
|
||||
LOGD("PrepareKeyRequest: nonce=%u", nonce);
|
||||
LOGD("nonce = %u", nonce);
|
||||
|
||||
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
||||
|
||||
@@ -354,7 +349,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
}
|
||||
|
||||
if (license_request_signature.empty()) {
|
||||
LOGE("CdmLicense::PrepareKeyRequest: License request signature empty");
|
||||
LOGE("License request signature is empty");
|
||||
signed_request->clear();
|
||||
return EMPTY_LICENSE_REQUEST;
|
||||
}
|
||||
@@ -376,28 +371,26 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
CdmSession* cdm_session, CdmKeyMessage* signed_request,
|
||||
std::string* server_url) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: not initialized");
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_1;
|
||||
}
|
||||
if (!signed_request) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: No signed request provided");
|
||||
if (signed_request == nullptr) {
|
||||
LOGE("Output parameter |signed_request| not provided");
|
||||
return INVALID_PARAMETERS_LIC_1;
|
||||
}
|
||||
if (!server_url) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: No server url provided");
|
||||
if (server_url == nullptr) {
|
||||
LOGE("Output parameter |server_url| not provided");
|
||||
return INVALID_PARAMETERS_LIC_2;
|
||||
}
|
||||
|
||||
if (is_renewal && !policy_engine_->CanRenew()) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: license renewal prohibited");
|
||||
LOGE("License renewal prohibited");
|
||||
return LICENSE_RENEWAL_PROHIBITED;
|
||||
}
|
||||
|
||||
if (renew_with_client_id_) {
|
||||
if (use_privacy_mode_ && !service_certificate_.has_certificate()) {
|
||||
LOGE(
|
||||
"CdmLicense::PrepareKeyUpdateRequest: failure with privacy mode - "
|
||||
"no service certificate.");
|
||||
LOGE("Privacy mode failure: No service certificate");
|
||||
return PRIVACY_MODE_ERROR_2;
|
||||
}
|
||||
}
|
||||
@@ -476,7 +469,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
return LICENSE_RENEWAL_NONCE_GENERATION_ERROR;
|
||||
}
|
||||
license_request.set_key_control_nonce(nonce);
|
||||
LOGD("PrepareKeyUpdateRequest: nonce=%u", nonce);
|
||||
LOGD("nonce = %u", nonce);
|
||||
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
||||
|
||||
// License request is complete. Serialize it.
|
||||
@@ -490,9 +483,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
if (license_request_signature.empty()) {
|
||||
LOGE(
|
||||
"CdmLicense::PrepareKeyUpdateRequest: empty license request"
|
||||
" signature");
|
||||
LOGE("License request signature is empty");
|
||||
return EMPTY_LICENSE_RENEWAL;
|
||||
}
|
||||
|
||||
@@ -510,22 +501,20 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: not initialized");
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_2;
|
||||
}
|
||||
// Clear the latest service version when we receive a new response.
|
||||
latest_service_version_.Clear();
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: empty license response");
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_1;
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyResponse: unable to parse signed license"
|
||||
" response");
|
||||
LOGE("Unable to parse signed license response");
|
||||
return INVALID_LICENSE_RESPONSE;
|
||||
}
|
||||
|
||||
@@ -546,24 +535,24 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
return HandleKeyErrorResponse(signed_response);
|
||||
|
||||
if (signed_response.type() != SignedMessage::LICENSE) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: unrecognized signed message type: %d",
|
||||
signed_response.type());
|
||||
LOGE("Unrecognized signed message type: type = %d",
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE;
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: license response is not signed");
|
||||
LOGE("License response is not signed");
|
||||
return LICENSE_RESPONSE_NOT_SIGNED;
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: unable to parse license response");
|
||||
LOGE("Unable to parse license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_1;
|
||||
}
|
||||
|
||||
if (!signed_response.has_session_key()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: no session keys present");
|
||||
LOGE("Signed response has no session keys present");
|
||||
return SESSION_KEYS_NOT_FOUND;
|
||||
}
|
||||
CdmResponseType status = crypto_session_->GenerateDerivedKeys(
|
||||
@@ -587,8 +576,8 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
if (mac_key_iv.size() != KEY_IV_SIZE ||
|
||||
mac_keys.size() != 2 * MAC_KEY_SIZE) {
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyResponse: mac key/iv size error"
|
||||
"(key/iv size expected: %d/%d, actual: %d/%d",
|
||||
"MAC key/IV size error: expected = %lu/%lu, "
|
||||
"actual = %zu/%zu (key/iv)",
|
||||
2 * MAC_KEY_SIZE, KEY_IV_SIZE, mac_keys.size(), mac_key_iv.size());
|
||||
return KEY_SIZE_ERROR_1;
|
||||
}
|
||||
@@ -601,7 +590,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
key_type = kLicenseKeyTypeContent;
|
||||
}
|
||||
if (key_array.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse : No content keys.");
|
||||
LOGE("No content keys");
|
||||
return NO_CONTENT_KEY;
|
||||
}
|
||||
license_key_type_ = key_type;
|
||||
@@ -628,9 +617,9 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
if (license.id().has_provider_session_token())
|
||||
provider_session_token_ = license.id().provider_session_token();
|
||||
|
||||
LOGV("provider_session_token: %s", provider_session_token_.empty()
|
||||
? "N/A"
|
||||
: provider_session_token_.c_str());
|
||||
LOGV("provider_session_token = %s", provider_session_token_.empty()
|
||||
? "N/A"
|
||||
: provider_session_token_.c_str());
|
||||
|
||||
if (license.policy().has_renewal_server_url()) {
|
||||
server_url_ = license.policy().renewal_server_url();
|
||||
@@ -656,19 +645,17 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
bool is_renewal, const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: not initialized");
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_3;
|
||||
}
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse : Empty license response.");
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_2;
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyUpdateResponse: Unable to parse signed "
|
||||
"message");
|
||||
LOGE("Unable to parse signed message");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_2;
|
||||
}
|
||||
|
||||
@@ -678,28 +665,24 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
case SignedMessage::ERROR_RESPONSE:
|
||||
return HandleKeyErrorResponse(signed_response);
|
||||
default:
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyUpdateResponse: unrecognized signed message "
|
||||
"type: %d",
|
||||
signed_response.type());
|
||||
LOGE("Unrecognized signed message type: type = %d",
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE;
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: signature missing");
|
||||
LOGE("Update key response is missing signature");
|
||||
return SIGNATURE_NOT_FOUND;
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyUpdateResponse: Unable to parse license"
|
||||
" from signed message");
|
||||
LOGE("Unable to parse license from signed message");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_3;
|
||||
}
|
||||
|
||||
if (!license.has_id()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: license id not present");
|
||||
LOGE("License ID not present");
|
||||
return LICENSE_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -747,38 +730,35 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
||||
int64_t last_playback_time, int64_t grace_period_end_time,
|
||||
CdmSession* cdm_session) {
|
||||
if (license_request.empty()) {
|
||||
LOGE("CdmLicense::RestoreOfflineLicense: empty |license_request|");
|
||||
LOGE("License request is empty");
|
||||
return EMPTY_LICENSE_REQUEST_2;
|
||||
}
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::RestoreOfflineLicense: empty |license_response|");
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_3;
|
||||
}
|
||||
|
||||
SignedMessage signed_request;
|
||||
if (!signed_request.ParseFromString(license_request)) {
|
||||
LOGE("CdmLicense::RestoreOfflineLicense: |license_request| parse failed");
|
||||
LOGE("Failed to parse license request");
|
||||
return PARSE_REQUEST_ERROR_1;
|
||||
}
|
||||
|
||||
if (signed_request.type() != SignedMessage::LICENSE_REQUEST) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreOfflineLicense: license request type: expected = "
|
||||
"%d, actual = %d",
|
||||
SignedMessage::LICENSE_REQUEST, signed_request.type());
|
||||
LOGE("Unexpected license request type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE_REQUEST),
|
||||
static_cast<int>(signed_request.type()));
|
||||
return INVALID_LICENSE_REQUEST_TYPE_1;
|
||||
}
|
||||
|
||||
key_request_ = signed_request.msg();
|
||||
|
||||
CdmResponseType sts = HandleKeyResponse(license_response);
|
||||
|
||||
if (sts != KEY_ADDED) return sts;
|
||||
|
||||
if (!license_renewal_response.empty()) {
|
||||
sts = HandleKeyUpdateResponse(true, license_renewal_response);
|
||||
|
||||
if (sts != KEY_ADDED) return sts;
|
||||
}
|
||||
|
||||
@@ -827,27 +807,25 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
const CdmKeyMessage& license_request,
|
||||
const CdmKeyResponse& license_response) {
|
||||
if (license_request.empty()) {
|
||||
LOGE("CdmLicense::RestoreLicenseForRelease: empty |license_request|");
|
||||
LOGE("License request is empty");
|
||||
return EMPTY_LICENSE_REQUEST_3;
|
||||
}
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::RestoreLicenseForRelease: empty |license_response|");
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_4;
|
||||
}
|
||||
|
||||
SignedMessage signed_request;
|
||||
if (!signed_request.ParseFromString(license_request)) {
|
||||
LOGE("CdmLicense::RestoreLicenseForRelease: license_request parse failed");
|
||||
LOGE("Failed to parse signed license request");
|
||||
return PARSE_REQUEST_ERROR_2;
|
||||
}
|
||||
|
||||
if (signed_request.type() != SignedMessage::LICENSE_REQUEST) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreLicenseForRelease: license request type: "
|
||||
"expected "
|
||||
"= %d, actual = %d",
|
||||
SignedMessage::LICENSE_REQUEST, signed_request.type());
|
||||
LOGE("Unexpected signed license request type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE_REQUEST),
|
||||
static_cast<int>(signed_request.type()));
|
||||
return INVALID_LICENSE_REQUEST_TYPE_2;
|
||||
}
|
||||
|
||||
@@ -855,32 +833,25 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreLicenseForRelease: unable to parse signed license"
|
||||
" response");
|
||||
LOGE("Failed to parse signed license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_4;
|
||||
}
|
||||
|
||||
if (SignedMessage::LICENSE != signed_response.type()) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreLicenseForRelease: unrecognized signed message "
|
||||
"type: %d",
|
||||
signed_response.type());
|
||||
LOGE("Unexpected signed license response type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE),
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE_2;
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreLicenseForRelease: license response is not"
|
||||
" signed");
|
||||
LOGE("License response is not signed");
|
||||
return SIGNATURE_NOT_FOUND_2;
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE(
|
||||
"CdmLicense::RestoreLicenseForRelease: unable to parse license"
|
||||
" response");
|
||||
LOGE("Failed to parse license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_5;
|
||||
}
|
||||
|
||||
@@ -894,7 +865,7 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
renew_with_client_id_ = license.policy().always_include_client_id();
|
||||
|
||||
if (!signed_response.has_session_key()) {
|
||||
LOGE("CdmLicense::RestoreLicenseForRelease: no session keys present");
|
||||
LOGE("No session keys present");
|
||||
return SESSION_KEYS_NOT_FOUND_2;
|
||||
}
|
||||
|
||||
@@ -920,31 +891,26 @@ bool CdmLicense::ExtractProviderSessionToken(
|
||||
const CdmKeyResponse& license_response,
|
||||
std::string* provider_session_token) {
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::ExtractProviderSessionToken: empty license response");
|
||||
LOGE("License response is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE(
|
||||
"CdmLicense::ExtractProviderSessionToken: unable to parse signed "
|
||||
"license response");
|
||||
LOGE("Failed to parse signed license response");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (signed_response.type() != SignedMessage::LICENSE) {
|
||||
LOGE(
|
||||
"CdmLicense::ExtractProviderSessionToken: unrecognized signed message "
|
||||
"type: %d",
|
||||
signed_response.type());
|
||||
LOGE("Unexpected signed license response type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE),
|
||||
static_cast<int>(signed_response.type()));
|
||||
return false;
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE(
|
||||
"CdmLicense::ExtractProviderSessionToken: unable to parse license "
|
||||
"response");
|
||||
LOGE("Failed to parse license response");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -961,7 +927,7 @@ CdmResponseType CdmLicense::HandleKeyErrorResponse(
|
||||
const SignedMessage& signed_message) {
|
||||
LicenseError license_error;
|
||||
if (!license_error.ParseFromString(signed_message.msg())) {
|
||||
LOGE("CdmLicense::HandleKeyErrorResponse: Unable to parse license error");
|
||||
LOGE("Failed to parse license error response");
|
||||
return KEY_ERROR;
|
||||
}
|
||||
|
||||
@@ -972,8 +938,8 @@ CdmResponseType CdmLicense::HandleKeyErrorResponse(
|
||||
return DEVICE_REVOKED;
|
||||
case LicenseError::SERVICE_UNAVAILABLE:
|
||||
default:
|
||||
LOGW("CdmLicense::HandleKeyErrorResponse: Unknown error type = %d",
|
||||
license_error.error_code());
|
||||
LOGW("Unknown error type: error_code = %d",
|
||||
static_cast<int>(license_error.error_code()));
|
||||
return KEY_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -992,7 +958,7 @@ CdmResponseType CdmLicense::PrepareClientId(
|
||||
|
||||
if (Properties::UsePrivacyMode(session_id_)) {
|
||||
if (!service_certificate_.has_certificate()) {
|
||||
LOGE("CdmLicense::PrepareClientId: Service Certificate not staged");
|
||||
LOGE("Service certificate not staged");
|
||||
return PRIVACY_MODE_ERROR_3;
|
||||
}
|
||||
EncryptedClientIdentification* encrypted_client_id =
|
||||
@@ -1023,7 +989,7 @@ CdmResponseType CdmLicense::PrepareContentId(
|
||||
if (!init_data.IsEmpty()) {
|
||||
cenc_content_id->add_pssh(init_data.data());
|
||||
} else {
|
||||
LOGE("CdmLicense::PrepareContentId: ISO-CENC init data not available");
|
||||
LOGE("ISO-CENC init data not available");
|
||||
return CENC_INIT_DATA_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1003,7 @@ CdmResponseType CdmLicense::PrepareContentId(
|
||||
if (!init_data.IsEmpty()) {
|
||||
webm_content_id->set_header(init_data.data());
|
||||
} else {
|
||||
LOGE("CdmLicense::PrepareContentId: WebM init data not available");
|
||||
LOGE("WebM init data not available");
|
||||
return WEBM_INIT_DATA_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@@ -1045,8 +1011,7 @@ CdmResponseType CdmLicense::PrepareContentId(
|
||||
return PREPARE_WEBM_CONTENT_ID_FAILED;
|
||||
}
|
||||
} else {
|
||||
LOGE("CdmLicense::PrepareContentId: no support for init data type (%s)",
|
||||
init_data.type().c_str());
|
||||
LOGE("Unsupported init data type: type = %s", init_data.type().c_str());
|
||||
return UNSUPPORTED_INIT_DATA_FORMAT;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@@ -1058,7 +1023,7 @@ CdmResponseType CdmLicense::HandleContentKeyResponse(
|
||||
const std::vector<CryptoKey>& key_array,
|
||||
const video_widevine::License& license) {
|
||||
if (key_array.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse : No content keys.");
|
||||
LOGE("No content keys provided");
|
||||
return NO_CONTENT_KEY;
|
||||
}
|
||||
CdmResponseType resp = crypto_session_->LoadKeys(
|
||||
@@ -1082,7 +1047,7 @@ CdmResponseType CdmLicense::HandleEntitlementKeyResponse(
|
||||
const std::vector<CryptoKey>& key_array,
|
||||
const video_widevine::License& license) {
|
||||
if (key_array.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse : No entitlement keys.");
|
||||
LOGE("No entitlement keys provided");
|
||||
return NO_CONTENT_KEY;
|
||||
}
|
||||
CdmResponseType resp = crypto_session_->LoadKeys(
|
||||
@@ -1120,7 +1085,10 @@ CdmResponseType CdmLicense::HandleNewEntitledKeys(
|
||||
// Strip PKCS#5 padding from entitled content keys.
|
||||
std::string content_key = wk->key();
|
||||
if (content_key.size() < CONTENT_KEY_SIZE) {
|
||||
LOGE("Entitled Key too small, %lu bytes", content_key.size());
|
||||
LOGE(
|
||||
"Entitled content key too small: "
|
||||
"expected = %lu, actual = %zu (bytes)",
|
||||
CONTENT_KEY_SIZE, content_key.size());
|
||||
return KEY_SIZE_ERROR_2;
|
||||
} else if (content_key.size() > CONTENT_KEY_SIZE) {
|
||||
content_key.resize(CONTENT_KEY_SIZE);
|
||||
@@ -1161,8 +1129,7 @@ bool CdmLicense::SetTypeAndId(CdmLicenseType license_type,
|
||||
content_id->set_license_type(video_widevine::STREAMING);
|
||||
break;
|
||||
default:
|
||||
LOGD("CdmLicense::PrepareKeyRequest: Unknown license type = %d",
|
||||
license_type);
|
||||
LOGD("Unknown license type: %d", static_cast<int>(license_type));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user