Source release 16.4.0
This commit is contained in:
145
cdm/src/cdm.cpp
145
cdm/src/cdm.cpp
@@ -22,13 +22,13 @@
|
||||
#include "file_store.h"
|
||||
#include "license.h"
|
||||
#include "log.h"
|
||||
#include "metrics.pb.h"
|
||||
#include "properties.h"
|
||||
#include "service_certificate.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_event_listener.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
// CE:
|
||||
#include "cdm_version.h"
|
||||
@@ -367,7 +367,8 @@ Cdm::Status CdmImpl::setServiceCertificate(ServiceRole role,
|
||||
// Verify that the certificate is properly signed and well-formed.
|
||||
CdmResponseType status = cdm_engine_->ValidateServiceCertificate(certificate);
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("Invalid service certificate! Error code = %d", status);
|
||||
LOGE("Invalid service certificate! Error code = %d",
|
||||
static_cast<int>(status));
|
||||
return kTypeError;
|
||||
}
|
||||
|
||||
@@ -421,13 +422,13 @@ Cdm::Status CdmImpl::getRobustnessLevel(RobustnessLevel* level) {
|
||||
}
|
||||
|
||||
std::string level_string;
|
||||
CdmResponseType result = cdm_engine_->QueryStatus(
|
||||
const CdmResponseType result = cdm_engine_->QueryStatus(
|
||||
kLevelDefault, QUERY_KEY_SECURITY_LEVEL, &level_string);
|
||||
if (result == SYSTEM_INVALIDATED_ERROR) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -452,19 +453,19 @@ Cdm::Status CdmImpl::getResourceRatingTier(uint32_t* tier) {
|
||||
}
|
||||
|
||||
std::string tier_string;
|
||||
CdmResponseType result = cdm_engine_->QueryStatus(
|
||||
const CdmResponseType result = cdm_engine_->QueryStatus(
|
||||
kLevelDefault, QUERY_KEY_RESOURCE_RATING_TIER, &tier_string);
|
||||
if (result == SYSTEM_INVALIDATED_ERROR) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
uint32_t parsed_tier = static_cast<uint32_t>(std::stoul(tier_string));
|
||||
const uint32_t parsed_tier = static_cast<uint32_t>(std::stoul(tier_string));
|
||||
if (parsed_tier <= 0) {
|
||||
LOGE("Invalid resource rating tier %lu", parsed_tier);
|
||||
LOGE("Invalid resource rating tier %u", parsed_tier);
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -484,7 +485,7 @@ Cdm::Status CdmImpl::getOemCryptoBuildInfo(std::string* build_info) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -508,7 +509,7 @@ Cdm::Status CdmImpl::getProvisioningRequest(std::string* request) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -524,7 +525,7 @@ Cdm::Status CdmImpl::handleProvisioningResponse(const std::string& response) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -537,7 +538,7 @@ Cdm::Status CdmImpl::removeProvisioning() {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -554,7 +555,7 @@ Cdm::Status CdmImpl::listStoredLicenses(std::vector<std::string>* key_set_ids) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -571,7 +572,7 @@ Cdm::Status CdmImpl::listUsageRecords(std::vector<std::string>* ksids) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -584,7 +585,7 @@ Cdm::Status CdmImpl::deleteUsageRecord(const std::string& key_set_id) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -597,7 +598,7 @@ Cdm::Status CdmImpl::deleteAllUsageRecords() {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -643,7 +644,7 @@ Cdm::Status CdmImpl::createSession(SessionType session_type,
|
||||
case kPersistentUsageRecord:
|
||||
break;
|
||||
default:
|
||||
LOGE("Unsupported session type: %d", session_type);
|
||||
LOGE("Unsupported session type: %d", static_cast<int>(session_type));
|
||||
return kNotSupported;
|
||||
}
|
||||
|
||||
@@ -663,7 +664,7 @@ Cdm::Status CdmImpl::createSession(SessionType session_type,
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
default:
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
}
|
||||
@@ -681,7 +682,7 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
|
||||
return kInvalidState;
|
||||
}
|
||||
|
||||
SessionType session_type = sessions_[session_id].type;
|
||||
const SessionType session_type = sessions_[session_id].type;
|
||||
CdmLicenseType license_type;
|
||||
switch (session_type) {
|
||||
case kTemporary:
|
||||
@@ -694,7 +695,7 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
|
||||
license_type = kLicenseTypeStreaming;
|
||||
break;
|
||||
default:
|
||||
LOGE("Unexpected session type: %d", session_type);
|
||||
LOGE("Unexpected session type: %d", static_cast<int>(session_type));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -713,7 +714,7 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
|
||||
init_data_type_name = HLS_INIT_DATA_FORMAT;
|
||||
break;
|
||||
default:
|
||||
LOGE("Invalid init data type: %d", init_data_type);
|
||||
LOGE("Invalid init data type: %d", static_cast<int>(init_data_type));
|
||||
return kTypeError;
|
||||
}
|
||||
|
||||
@@ -739,7 +740,7 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
|
||||
|
||||
CdmKeyRequest key_request;
|
||||
|
||||
CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
const CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
session_id, session_id, init_data_obj, license_type, app_parameters_,
|
||||
&key_request);
|
||||
|
||||
@@ -760,14 +761,14 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
|
||||
LOGE("No licensing service certificate installed");
|
||||
return kNeedsServiceCertificate;
|
||||
} else if (result != KEY_MESSAGE) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
sessions_[session_id].callable = true;
|
||||
assert(key_request.type == kKeyRequestTypeInitial);
|
||||
|
||||
LOGI("A license request has been generated.");
|
||||
LOGI("A license request has been generated");
|
||||
listener_->onMessage(session_id, kLicenseRequest, key_request.message);
|
||||
return kSuccess;
|
||||
}
|
||||
@@ -794,7 +795,7 @@ Cdm::Status CdmImpl::load(const std::string& session_id) {
|
||||
case NEED_PROVISIONING:
|
||||
return kNeedsDeviceCertificate;
|
||||
default:
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -818,7 +819,7 @@ Cdm::Status CdmImpl::load(const std::string& session_id) {
|
||||
LOGE("Unable to load license: %s", session_id.c_str());
|
||||
return kSessionNotFound;
|
||||
} else {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
}
|
||||
@@ -836,7 +837,7 @@ Cdm::Status CdmImpl::load(const std::string& session_id) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != KEY_ADDED) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -871,8 +872,8 @@ Cdm::Status CdmImpl::update(const std::string& session_id,
|
||||
// NOTE: If the CdmSession object recognizes that this is not the first
|
||||
// AddKey(), it will internally delegate to RenewKey().
|
||||
CdmKeySetId key_set_id = session_id;
|
||||
CdmLicenseType license_type; // Required for AddKey. Unused otherwise.
|
||||
CdmResponseType result =
|
||||
CdmLicenseType license_type = {}; // Required for AddKey. Unused otherwise.
|
||||
const CdmResponseType result =
|
||||
cdm_engine_->AddKey(session_id, response, &license_type, &key_set_id);
|
||||
|
||||
// result should only be NEED_KEY after server certificate provisioning, which
|
||||
@@ -894,7 +895,7 @@ Cdm::Status CdmImpl::update(const std::string& session_id,
|
||||
LOGE("The device needs to reprovision.");
|
||||
return kNeedsDeviceCertificate;
|
||||
} else if (result != KEY_ADDED) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -921,7 +922,7 @@ Cdm::Status CdmImpl::loadEmbeddedKeys(const std::string& session_id,
|
||||
}
|
||||
|
||||
if (init_data_type != kCenc) {
|
||||
LOGE("Invalid init data type: %d", init_data_type);
|
||||
LOGE("Invalid init data type: %d", static_cast<int>(init_data_type));
|
||||
return kTypeError;
|
||||
}
|
||||
|
||||
@@ -942,7 +943,7 @@ Cdm::Status CdmImpl::loadEmbeddedKeys(const std::string& session_id,
|
||||
}
|
||||
|
||||
CdmKeyRequest key_request;
|
||||
CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
const CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
session_id, session_id, init_data_obj, kLicenseTypeEmbeddedKeyData,
|
||||
app_parameters_, &key_request);
|
||||
|
||||
@@ -956,7 +957,8 @@ Cdm::Status CdmImpl::loadEmbeddedKeys(const std::string& session_id,
|
||||
LOGE("Nonce quota exceeded");
|
||||
return kResourceContention;
|
||||
} else if (result != KEY_ADDED) {
|
||||
LOGE("Unexpected Failure: GenerateKeyRequest() returned %lu", result);
|
||||
LOGE("Unexpected Failure: GenerateKeyRequest() returned %d",
|
||||
static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
return kSuccess;
|
||||
@@ -1019,7 +1021,7 @@ Cdm::Status CdmImpl::getKeyAllowedUsages(const std::string& session_id,
|
||||
LOGE("Session invalidated");
|
||||
return kSessionStateLost;
|
||||
} else {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
}
|
||||
@@ -1036,7 +1038,7 @@ Cdm::Status CdmImpl::getKeyAllowedUsages(const std::string& key_id,
|
||||
}
|
||||
|
||||
CdmKeyAllowedUsage usage_for_key;
|
||||
CdmResponseType result =
|
||||
const CdmResponseType result =
|
||||
cdm_engine_->QueryKeyAllowedUsage(key_id, &usage_for_key);
|
||||
if (result != NO_ERROR) {
|
||||
if (result == KEY_NOT_FOUND_1 || result == KEY_NOT_FOUND_2) {
|
||||
@@ -1050,7 +1052,7 @@ Cdm::Status CdmImpl::getKeyAllowedUsages(const std::string& key_id,
|
||||
} else if (result == KEY_CONFLICT_1) {
|
||||
return kTypeError;
|
||||
} else {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
}
|
||||
@@ -1101,12 +1103,12 @@ Cdm::Status CdmImpl::close(const std::string& session_id) {
|
||||
return kSessionNotFound;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->CloseSession(session_id);
|
||||
const CdmResponseType result = cdm_engine_->CloseSession(session_id);
|
||||
if (result == SYSTEM_INVALIDATED_ERROR) {
|
||||
LOGE("System invalidated");
|
||||
return kSystemStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
sessions_.erase(session_id);
|
||||
@@ -1140,7 +1142,7 @@ Cdm::Status CdmImpl::remove(const std::string& session_id) {
|
||||
it->second = kReleased;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
const CdmResponseType result = cdm_engine_->GenerateKeyRequest(
|
||||
session_id, session_id, empty_initialization_data, kLicenseTypeRelease,
|
||||
app_parameters_, &key_request);
|
||||
|
||||
@@ -1154,7 +1156,7 @@ Cdm::Status CdmImpl::remove(const std::string& session_id) {
|
||||
LOGE("Nonce quota exceeded");
|
||||
return kResourceContention;
|
||||
} else if (result != KEY_MESSAGE) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
cdm_engine_->CloseSession(session_id);
|
||||
return kUnexpectedError;
|
||||
}
|
||||
@@ -1181,7 +1183,7 @@ Cdm::Status CdmImpl::forceRemove(const std::string& session_id) {
|
||||
return kRangeError;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->RemoveLicense(session_id);
|
||||
const CdmResponseType result = cdm_engine_->RemoveLicense(session_id);
|
||||
|
||||
if (result == SYSTEM_INVALIDATED_ERROR) {
|
||||
LOGE("System invalidated");
|
||||
@@ -1190,7 +1192,7 @@ Cdm::Status CdmImpl::forceRemove(const std::string& session_id) {
|
||||
LOGE("Session invalidated");
|
||||
return kSessionStateLost;
|
||||
} else if (result != NO_ERROR) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -1285,7 +1287,8 @@ Cdm::Status CdmImpl::decrypt(const std::string& session_id,
|
||||
return cdm_sample;
|
||||
});
|
||||
|
||||
CdmResponseType result = cdm_engine_->DecryptV16(session_id, parameters);
|
||||
const CdmResponseType result =
|
||||
cdm_engine_->DecryptV16(session_id, parameters);
|
||||
|
||||
if (result == NO_ERROR) {
|
||||
return kSuccess;
|
||||
@@ -1317,7 +1320,7 @@ Cdm::Status CdmImpl::decrypt(const std::string& session_id,
|
||||
return kKeyUsageBlockedByPolicy;
|
||||
}
|
||||
|
||||
LOGE("Decrypt error: %d", result);
|
||||
LOGE("Decrypt error: %d", static_cast<int>(result));
|
||||
return kDecryptError;
|
||||
}
|
||||
|
||||
@@ -1327,9 +1330,11 @@ Cdm::Status CdmImpl::genericEncrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
GenericEncryptionAlgorithmType algorithm,
|
||||
std::string* out_buffer) {
|
||||
CdmEncryptionAlgorithm cdm_algorithm = ConvertEncryptionAlgorithm(algorithm);
|
||||
const CdmEncryptionAlgorithm cdm_algorithm =
|
||||
ConvertEncryptionAlgorithm(algorithm);
|
||||
if (cdm_algorithm == wvcdm::kEncryptionAlgorithmUnknown) {
|
||||
LOGE("Unrecognized encryption algorithm: %d.", cdm_algorithm);
|
||||
LOGE("Unrecognized encryption algorithm: %d.",
|
||||
static_cast<int>(cdm_algorithm));
|
||||
return kNotSupported;
|
||||
}
|
||||
|
||||
@@ -1358,7 +1363,7 @@ Cdm::Status CdmImpl::genericEncrypt(const std::string& session_id,
|
||||
LOGE("Key Error: %s", session_id.c_str());
|
||||
return kNoKey;
|
||||
}
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -1368,13 +1373,15 @@ Cdm::Status CdmImpl::genericDecrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
GenericEncryptionAlgorithmType algorithm,
|
||||
std::string* out_buffer) {
|
||||
CdmEncryptionAlgorithm cdm_algorithm = ConvertEncryptionAlgorithm(algorithm);
|
||||
const CdmEncryptionAlgorithm cdm_algorithm =
|
||||
ConvertEncryptionAlgorithm(algorithm);
|
||||
if (cdm_algorithm == wvcdm::kEncryptionAlgorithmUnknown) {
|
||||
LOGE("Unrecognized encryption algorithm: %d.", cdm_algorithm);
|
||||
LOGE("Unrecognized encryption algorithm: %d.",
|
||||
static_cast<int>(cdm_algorithm));
|
||||
return kNotSupported;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->GenericDecrypt(
|
||||
const CdmResponseType result = cdm_engine_->GenericDecrypt(
|
||||
session_id, in_buffer, key_id, iv, cdm_algorithm, out_buffer);
|
||||
if (result == NO_ERROR) {
|
||||
return kSuccess;
|
||||
@@ -1399,7 +1406,7 @@ Cdm::Status CdmImpl::genericDecrypt(const std::string& session_id,
|
||||
LOGE("Key Error: %s", session_id.c_str());
|
||||
return kNoKey;
|
||||
}
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -1408,14 +1415,14 @@ Cdm::Status CdmImpl::genericSign(const std::string& session_id,
|
||||
const std::string& key_id,
|
||||
GenericSigningAlgorithmType algorithm,
|
||||
std::string* signature) {
|
||||
CdmSigningAlgorithm cdm_algorithm = ConvertSigningAlgorithm(algorithm);
|
||||
const CdmSigningAlgorithm cdm_algorithm = ConvertSigningAlgorithm(algorithm);
|
||||
if (cdm_algorithm == wvcdm::kSigningAlgorithmUnknown) {
|
||||
LOGE("Unrecognized signing algorithm: %d.", cdm_algorithm);
|
||||
LOGE("Unrecognized signing algorithm: %d", static_cast<int>(cdm_algorithm));
|
||||
return kNotSupported;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->GenericSign(session_id, message, key_id,
|
||||
cdm_algorithm, signature);
|
||||
const CdmResponseType result = cdm_engine_->GenericSign(
|
||||
session_id, message, key_id, cdm_algorithm, signature);
|
||||
if (result == NO_ERROR) {
|
||||
return kSuccess;
|
||||
}
|
||||
@@ -1435,7 +1442,7 @@ Cdm::Status CdmImpl::genericSign(const std::string& session_id,
|
||||
LOGE("Key Error: %s", session_id.c_str());
|
||||
return kNoKey;
|
||||
}
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
@@ -1444,13 +1451,13 @@ Cdm::Status CdmImpl::genericVerify(const std::string& session_id,
|
||||
const std::string& key_id,
|
||||
GenericSigningAlgorithmType algorithm,
|
||||
const std::string& signature) {
|
||||
CdmSigningAlgorithm cdm_algorithm = ConvertSigningAlgorithm(algorithm);
|
||||
const CdmSigningAlgorithm cdm_algorithm = ConvertSigningAlgorithm(algorithm);
|
||||
if (cdm_algorithm == wvcdm::kSigningAlgorithmUnknown) {
|
||||
LOGE("Unrecognized signing algorithm: %d.", cdm_algorithm);
|
||||
LOGE("Unrecognized signing algorithm: %d", static_cast<int>(cdm_algorithm));
|
||||
return kNotSupported;
|
||||
}
|
||||
|
||||
CdmResponseType result = cdm_engine_->GenericVerify(
|
||||
const CdmResponseType result = cdm_engine_->GenericVerify(
|
||||
session_id, message, key_id, cdm_algorithm, signature);
|
||||
if (result == NO_ERROR) {
|
||||
return kSuccess;
|
||||
@@ -1471,18 +1478,19 @@ Cdm::Status CdmImpl::genericVerify(const std::string& session_id,
|
||||
LOGE("Key Error: %s", session_id.c_str());
|
||||
return kNoKey;
|
||||
}
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return kUnexpectedError;
|
||||
}
|
||||
|
||||
Cdm::Status CdmImpl::setVideoResolution(const std::string& session_id,
|
||||
uint32_t width, uint32_t height) {
|
||||
constexpr uint64_t kMaxUint32 = std::numeric_limits<uint32_t>::max();
|
||||
// Verify that width * height will fit into a 32-bit quantity.
|
||||
// This is done to be compatible with the video resolution in the
|
||||
// license policy settings.
|
||||
uint64_t pixels = width;
|
||||
pixels *= height;
|
||||
if (pixels >= (1ULL << 32)) return kRangeError;
|
||||
const uint64_t pixels =
|
||||
static_cast<uint64_t>(width) * static_cast<uint64_t>(height);
|
||||
if (pixels > kMaxUint32) return kRangeError;
|
||||
if (cdm_engine_->NotifyResolution(session_id, width, height)) {
|
||||
return kSuccess;
|
||||
} else {
|
||||
@@ -1516,7 +1524,7 @@ void CdmImpl::onTimerExpired(void* context) {
|
||||
|
||||
void CdmImpl::OnSessionRenewalNeeded(const CdmSessionId& session_id) {
|
||||
CdmKeyRequest key_request;
|
||||
CdmResponseType result =
|
||||
const CdmResponseType result =
|
||||
cdm_engine_->GenerateRenewalRequest(session_id, &key_request);
|
||||
if (result == LICENSE_RENEWAL_NONCE_GENERATION_ERROR) {
|
||||
// TODO(b/73606893): this error should be recoverable. Rather
|
||||
@@ -1526,7 +1534,7 @@ void CdmImpl::OnSessionRenewalNeeded(const CdmSessionId& session_id) {
|
||||
return;
|
||||
}
|
||||
if (result != KEY_MESSAGE) {
|
||||
LOGE("Unexpected error %d", result);
|
||||
LOGE("Unexpected error %d", static_cast<int>(result));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1574,7 +1582,8 @@ void CdmImpl::OnSessionKeysChange(const CdmSessionId& session_id,
|
||||
// compiler will flag if someone fails to add a case for new enum members,
|
||||
// while still handling the possibility of an invalid value sneaking into
|
||||
// the map at runtime.
|
||||
LOGE("Invalid key status %d. Reporting internal error.", it->second);
|
||||
LOGE("Internal error: Invalid key status: %d",
|
||||
static_cast<int>(it->second));
|
||||
map[it->first] = kInternalError;
|
||||
}
|
||||
|
||||
@@ -1608,7 +1617,7 @@ CdmEncryptionAlgorithm CdmImpl::ConvertEncryptionAlgorithm(
|
||||
if (algorithm == Cdm::kEncryptionAlgorithmAesCbc128) {
|
||||
return wvcdm::kEncryptionAlgorithmAesCbc128;
|
||||
} else {
|
||||
LOGW("Unknown encryption algorithm: %d", algorithm);
|
||||
LOGW("Unknown encryption algorithm: %d", static_cast<int>(algorithm));
|
||||
return wvcdm::kEncryptionAlgorithmUnknown;
|
||||
}
|
||||
}
|
||||
@@ -1618,7 +1627,7 @@ CdmSigningAlgorithm CdmImpl::ConvertSigningAlgorithm(
|
||||
if (algorithm == Cdm::kSigningAlgorithmHmacSha256) {
|
||||
return wvcdm::kSigningAlgorithmHmacSha256;
|
||||
} else {
|
||||
LOGW("Unknown signing algorithm: %d", algorithm);
|
||||
LOGW("Unknown signing algorithm: %d", static_cast<int>(algorithm));
|
||||
return wvcdm::kSigningAlgorithmUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user