Clean up other core CDM logs.
[ Merge of http://go/wvgerrit/122613 ] Further log clean up in the core CDM code. - Changed several INFO logs to DEBUG and VERBOSE - Added more identifiers to the DEBUG logs to help match resource associations - Added more enum-to-string functions - Unknown enum values will be formatted to contain their numeric value Key areas improved are the UsageTableHeader and CdmSession. Bug: 183576879 Test: CE CDM unittests Change-Id: I2d11e714d419e0736d3e2f7a7668e8d36d7ef449
This commit is contained in:
@@ -85,8 +85,8 @@ using video_widevine_client::sdk::
|
||||
return false; \
|
||||
}
|
||||
|
||||
namespace wvcdm {
|
||||
namespace {
|
||||
|
||||
const char kEmptyFileName[] = "";
|
||||
const char kFalse[] = "false";
|
||||
const char kHlsAttributesFileNameExt[] = ".hal";
|
||||
@@ -100,21 +100,21 @@ constexpr int64_t kFourMonthsInSeconds = (2 * 30 + 2 * 31) * 24 * 60 * 60;
|
||||
|
||||
// Helper methods
|
||||
bool SetDeviceCertificate(const std::string& certificate,
|
||||
const wvcdm::CryptoWrappedKey& private_key,
|
||||
const CryptoWrappedKey& private_key,
|
||||
DeviceCertificate* mutable_device_certificate) {
|
||||
RETURN_FALSE_IF_NULL(mutable_device_certificate);
|
||||
|
||||
mutable_device_certificate->set_certificate(certificate);
|
||||
mutable_device_certificate->set_wrapped_private_key(private_key.key());
|
||||
switch (private_key.type()) {
|
||||
case wvcdm::CryptoWrappedKey::kRsa:
|
||||
case CryptoWrappedKey::kRsa:
|
||||
mutable_device_certificate->set_key_type(DeviceCertificate::RSA);
|
||||
return true;
|
||||
case wvcdm::CryptoWrappedKey::kEcc:
|
||||
case CryptoWrappedKey::kEcc:
|
||||
mutable_device_certificate->set_key_type(DeviceCertificate::ECC);
|
||||
return true;
|
||||
case wvcdm::CryptoWrappedKey::kUninitialized: // Suppress compiler
|
||||
// warnings.
|
||||
case CryptoWrappedKey::kUninitialized: // Suppress compiler
|
||||
// warnings.
|
||||
default:
|
||||
LOGE("Unexpected key type: %d", private_key.type());
|
||||
return false;
|
||||
@@ -123,7 +123,7 @@ bool SetDeviceCertificate(const std::string& certificate,
|
||||
|
||||
bool ExtractFromDeviceCertificate(const DeviceCertificate& device_certificate,
|
||||
std::string* certificate,
|
||||
wvcdm::CryptoWrappedKey* private_key) {
|
||||
CryptoWrappedKey* private_key) {
|
||||
RETURN_FALSE_IF_NULL(certificate);
|
||||
RETURN_FALSE_IF_NULL(private_key);
|
||||
|
||||
@@ -161,29 +161,29 @@ bool ExtractFromDeviceCertificate(const DeviceCertificate& device_certificate,
|
||||
device_certificate.key_type();
|
||||
switch (key_type) {
|
||||
case DeviceCertificate::RSA:
|
||||
private_key->set_type(wvcdm::CryptoWrappedKey::kRsa);
|
||||
private_key->set_type(CryptoWrappedKey::kRsa);
|
||||
break;
|
||||
case DeviceCertificate::ECC:
|
||||
private_key->set_type(wvcdm::CryptoWrappedKey::kEcc);
|
||||
private_key->set_type(CryptoWrappedKey::kEcc);
|
||||
break;
|
||||
default:
|
||||
LOGW("Unknown DRM key type, defaulting to RSA: type = %d", key_type);
|
||||
private_key->set_type(wvcdm::CryptoWrappedKey::kRsa);
|
||||
private_key->set_type(CryptoWrappedKey::kRsa);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Possible that device certificate is from V15, in this case, the
|
||||
// only supported key of at that time was RSA.
|
||||
LOGD("No key type info, assuming RSA");
|
||||
private_key->set_type(wvcdm::CryptoWrappedKey::kRsa);
|
||||
private_key->set_type(CryptoWrappedKey::kRsa);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FindOrInsertUsageCertificate(
|
||||
const std::string& drm_certificate,
|
||||
const wvcdm::CryptoWrappedKey& wrapped_private_key, UsageInfo* usage_info,
|
||||
uint32_t* drm_certificate_id) {
|
||||
bool FindOrInsertUsageCertificate(const std::string& drm_certificate,
|
||||
const CryptoWrappedKey& wrapped_private_key,
|
||||
UsageInfo* usage_info,
|
||||
uint32_t* drm_certificate_id) {
|
||||
RETURN_FALSE_IF_NULL(usage_info);
|
||||
RETURN_FALSE_IF_NULL(drm_certificate_id);
|
||||
|
||||
@@ -228,8 +228,7 @@ bool FindUsageCertificate(
|
||||
uint32_t drm_certificate_id,
|
||||
const google::protobuf::RepeatedPtrField<UsageInfo_DrmUsageCertificate>&
|
||||
drm_certificate_cache,
|
||||
std::string* drm_certificate,
|
||||
wvcdm::CryptoWrappedKey* wrapped_private_key) {
|
||||
std::string* drm_certificate, CryptoWrappedKey* wrapped_private_key) {
|
||||
for (const UsageInfo_DrmUsageCertificate& drm_usage_cert :
|
||||
drm_certificate_cache) {
|
||||
if (drm_usage_cert.drm_certificate_id() == drm_certificate_id) {
|
||||
@@ -285,10 +284,80 @@ bool UsageCertificateCacheCleanUp(UsageInfo* usage_info) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
// static
|
||||
const char* DeviceFiles::CertificateStateToString(CertificateState state) {
|
||||
switch (state) {
|
||||
case kCertificateValid:
|
||||
return "Valid";
|
||||
case kCertificateExpired:
|
||||
return "Expired";
|
||||
case kCertificateNotFound:
|
||||
return "NotFound";
|
||||
case kCertificateInvalid:
|
||||
return "Invalid";
|
||||
case kCannotHandle:
|
||||
return "CannotHandle";
|
||||
}
|
||||
return UnknownEnumValueToString(static_cast<int>(state));
|
||||
}
|
||||
|
||||
// static
|
||||
const char* DeviceFiles::CertificateTypeToString(CertificateType type) {
|
||||
switch (type) {
|
||||
case kCertificateDefault:
|
||||
return "Default";
|
||||
case kCertificateLegacy:
|
||||
return "Legacy";
|
||||
case kCertificateAtsc:
|
||||
return "ATSC";
|
||||
}
|
||||
return UnknownEnumValueToString(static_cast<int>(type));
|
||||
}
|
||||
|
||||
// static
|
||||
const char* DeviceFiles::ResponseTypeToString(ResponseType type) {
|
||||
switch (type) {
|
||||
case kNoError:
|
||||
return "NoError";
|
||||
case kObjectNotInitialized:
|
||||
return "ObjectNotInitialized";
|
||||
case kParameterNull:
|
||||
return "ParameterNull";
|
||||
case kBasePathUnavailable:
|
||||
return "PathUnavailable";
|
||||
case kFileNotFound:
|
||||
return "NotFound";
|
||||
case kFileOpenFailed:
|
||||
return "OpenFailed";
|
||||
case kFileWriteError:
|
||||
return "WriteError";
|
||||
case kFileReadError:
|
||||
return "ReadError";
|
||||
case kInvalidFileSize:
|
||||
return "InvalidFileSize";
|
||||
case kHashComputationFailed:
|
||||
return "HashFailed";
|
||||
case kFileHashMismatch:
|
||||
return "HashMismatch";
|
||||
case kFileParseError1:
|
||||
return "ParseHashedFileError";
|
||||
case kFileParseError2:
|
||||
return "ParseFileError";
|
||||
case kUnknownLicenseState:
|
||||
return "UnknownLicenseState";
|
||||
case kIncorrectFileType:
|
||||
return "IncorrectFileType";
|
||||
case kIncorrectFileVersion:
|
||||
return "IncorrectFileVersion";
|
||||
case kLicenseNotPresent:
|
||||
return "LicenseNotFound";
|
||||
case kResponseTypeBase: // Not a valid value.
|
||||
break;
|
||||
}
|
||||
return UnknownEnumValueToString(static_cast<int>(type));
|
||||
}
|
||||
|
||||
// static
|
||||
std::set<std::string> DeviceFiles::reserved_license_ids_;
|
||||
@@ -671,8 +740,8 @@ bool DeviceFiles::RetrieveLicense(const std::string& key_set_id,
|
||||
video_widevine_client::sdk::File file;
|
||||
*result = RetrieveHashedFile(key_set_id + kLicenseFileNameExt, &file);
|
||||
if (*result != kNoError) {
|
||||
LOGE("Unable to retrieve key set license file: result = %d",
|
||||
static_cast<int>(*result));
|
||||
LOGE("Unable to retrieve key set license file: result = %s",
|
||||
ResponseTypeToString(*result));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1771,7 +1840,7 @@ std::string DeviceFiles::GetUsageInfoFileName(const std::string& app_id) {
|
||||
}
|
||||
|
||||
std::string DeviceFiles::GetFileNameSafeHash(const std::string& input) {
|
||||
return wvcdm::Base64SafeEncode(Md5Hash(input));
|
||||
return Base64SafeEncode(Md5Hash(input));
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user