Clean up CdmEngine logs.
[ Merge of http://go/wvgerrit/121568 ] The CdmEngine logs had both too much and too little information. Since our logging has been enabled to print function names natively, many of the log information has become superfluous. Needless information has been removed, and many of the important INFO logs have been reduced to only the information not present in the function name. Some of the INFO and ERROR logs were missing identifiers to match failures with the same session request should the failures take more than a few milliseconds to occur. CDM session IDs and key set IDs have been included in all the logs that _appeared_ to have a slow operation between the top of the method and log. To help make enum values more readable, several enums-to-string functions have been implemented. These converters are intended for INFO logging and as such, do not log any addition information should the enum be out of range. To help make empty and null identifiers more readable in the logs, empty strings will be logged as <empty> and null strings will be logged as <null>. While working through the "cdm_engine.cpp" file, a few minor changes have been made: - Adjust if statements to match with Google C++ style guidelines - Skipped anything that was not obvious - Added a const qualifier to variables where appropriate - Moved some null checks to the top of the method - Only where sequence is non-critical to normal operation - Removed unnecessary string to vector to string conversions - Reject empty |force_session_id| - Already enforced on CE CDM code and not uesd on Android Bug: 183576879 Test: CE CDM unittests Change-Id: Id165373055f7ce6097c93c48f84af74bd353c8cb
This commit is contained in:
@@ -61,6 +61,7 @@ cc_library_static {
|
||||
CORE_SRC_DIR + "/privacy_crypto_boringssl.cpp",
|
||||
CORE_SRC_DIR + "/service_certificate.cpp",
|
||||
CORE_SRC_DIR + "/usage_table_header.cpp",
|
||||
CORE_SRC_DIR + "/wv_cdm_types.cpp",
|
||||
SRC_DIR + "/wv_content_decryption_module.cpp",
|
||||
METRICS_SRC_DIR + "/attribute_handler.cpp",
|
||||
METRICS_SRC_DIR + "/counter_metric.cpp",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace wvcdm {
|
||||
|
||||
class CryptoKey;
|
||||
class CryptoSessionFactory;
|
||||
class UsageTableHeader;
|
||||
|
||||
using CryptoKeyMap = std::map<std::string, CryptoKey*>;
|
||||
@@ -40,8 +41,6 @@ OEMCrypto_Substring GetSubstring(const std::string& message = "",
|
||||
bool set_zero = false);
|
||||
OEMCryptoCipherMode ToOEMCryptoCipherMode(CdmCipherMode cipher_mode);
|
||||
|
||||
class CryptoSessionFactory;
|
||||
|
||||
class CryptoSession {
|
||||
public:
|
||||
using HdcpCapability = OEMCrypto_HDCP_Capability;
|
||||
|
||||
@@ -21,7 +21,6 @@ class VersionInfo;
|
||||
} // namespace video_widevine
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class Clock;
|
||||
class CryptoSession;
|
||||
class PolicyEngine;
|
||||
@@ -186,7 +185,6 @@ class CdmLicense {
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmLicense);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_LICENSE_H_
|
||||
|
||||
@@ -793,6 +793,22 @@ class KeyMessage;
|
||||
class Request;
|
||||
class Key;
|
||||
|
||||
// Logging utilities for types defined above.
|
||||
// Converts the different enum types to a human readable C-string for
|
||||
// logging. Query strings values are used if available for the enum.
|
||||
// These functions will fail silently to avoid double logging.
|
||||
const char* CdmCertificateTypeToString(CdmCertificateType type);
|
||||
const char* CdmLicenseTypeToString(CdmLicenseType license_type);
|
||||
const char* CdmSecurityLevelToString(CdmSecurityLevel security_level);
|
||||
const char* SecurityLevelToString(SecurityLevel security_level);
|
||||
// Both IdToString() and IdPtrToString() functions are used to convert
|
||||
// session IDs, key set IDs or other CDM specific identifiers to a
|
||||
// loggable format.
|
||||
const char* IdToString(const std::string& id);
|
||||
// Some CDM API function allow for optional string parameters to be
|
||||
// provided as string pointers.
|
||||
const char* IdPtrToString(const std::string* id);
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_WV_CDM_TYPES_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace {
|
||||
|
||||
const std::string kEmptyString;
|
||||
|
||||
// URL for Google Provisioning Server.
|
||||
@@ -104,10 +104,7 @@ bool ExtractAndDecodeSignedMessage(const std::string& provisioning_response,
|
||||
result->assign(decoded_message.begin(), decoded_message.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
// Protobuf generated classes.
|
||||
using video_widevine::ClientIdentification_ClientCapabilities;
|
||||
using video_widevine::ClientIdentification_NameValue;
|
||||
|
||||
@@ -164,11 +164,6 @@ size_t GenericEncryptionBlockSize(CdmEncryptionAlgorithm algorithm) {
|
||||
}
|
||||
return kAes128BlockSize;
|
||||
}
|
||||
|
||||
const char* SecurityLevelToString(SecurityLevel security_level) {
|
||||
return security_level == kLevel3 ? QUERY_VALUE_SECURITY_LEVEL_L3.c_str()
|
||||
: QUERY_VALUE_SECURITY_LEVEL_DEFAULT.c_str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
shared_mutex CryptoSession::static_field_mutex_;
|
||||
|
||||
76
libwvdrmengine/cdm/core/src/wv_cdm_types.cpp
Normal file
76
libwvdrmengine/cdm/core/src/wv_cdm_types.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace {
|
||||
const char kEmptyIdRep[] = "<empty>";
|
||||
const char kNullIdRep[] = "<null>";
|
||||
const char kUnknownValueRep[] = "<unknown>";
|
||||
} // namespace
|
||||
|
||||
const char* CdmCertificateTypeToString(CdmCertificateType type) {
|
||||
switch (type) {
|
||||
case kCertificateWidevine:
|
||||
return "Widevine";
|
||||
case kCertificateX509:
|
||||
return "x509";
|
||||
}
|
||||
return kUnknownValueRep;
|
||||
}
|
||||
|
||||
const char* CdmLicenseTypeToString(CdmLicenseType license_type) {
|
||||
switch (license_type) {
|
||||
case kLicenseTypeOffline:
|
||||
return "Offline";
|
||||
case kLicenseTypeStreaming:
|
||||
return "Streaming";
|
||||
case kLicenseTypeRelease:
|
||||
return "Release";
|
||||
case kLicenseTypeTemporary:
|
||||
return "Temporary";
|
||||
case kLicenseTypeEmbeddedKeyData:
|
||||
return "EmbeddedKeyData";
|
||||
}
|
||||
return kUnknownValueRep;
|
||||
}
|
||||
|
||||
const char* CdmSecurityLevelToString(CdmSecurityLevel security_level) {
|
||||
switch (security_level) {
|
||||
case kSecurityLevelUninitialized:
|
||||
return "Uninitialized";
|
||||
case kSecurityLevelL1:
|
||||
return QUERY_VALUE_SECURITY_LEVEL_L1.c_str();
|
||||
case kSecurityLevelL2:
|
||||
return QUERY_VALUE_SECURITY_LEVEL_L2.c_str();
|
||||
case kSecurityLevelL3:
|
||||
return QUERY_VALUE_SECURITY_LEVEL_L3.c_str();
|
||||
case kSecurityLevelUnknown:
|
||||
break;
|
||||
}
|
||||
return QUERY_VALUE_SECURITY_LEVEL_UNKNOWN.c_str();
|
||||
}
|
||||
|
||||
const char* SecurityLevelToString(SecurityLevel security_level) {
|
||||
switch (security_level) {
|
||||
case kLevelDefault:
|
||||
return QUERY_VALUE_SECURITY_LEVEL_DEFAULT.c_str();
|
||||
case kLevel3:
|
||||
return QUERY_VALUE_SECURITY_LEVEL_L3.c_str();
|
||||
}
|
||||
return kUnknownValueRep;
|
||||
}
|
||||
|
||||
const char* IdToString(const std::string& id) {
|
||||
return id.empty() ? kEmptyIdRep : id.c_str();
|
||||
}
|
||||
|
||||
const char* IdPtrToString(const std::string* id) {
|
||||
if (id == nullptr) return kNullIdRep;
|
||||
return id->empty() ? kEmptyIdRep : id->c_str();
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
Reference in New Issue
Block a user