Source release 17.1.0

This commit is contained in:
John "Juce" Bruce
2022-07-07 17:14:31 -07:00
parent 8c17574083
commit 694cf6fb25
2233 changed files with 272026 additions and 223371 deletions

View File

@@ -1,15 +1,18 @@
// Copyright 2016 Google Inc. All Rights Reserved.
// Copyright 2016 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
// This file contains definitions for metrics being collected throughout the
// CDM.
#ifndef WVCDM_METRICS_METRICS_GROUP_H_
#define WVCDM_METRICS_METRICS_GROUP_H_
#ifndef WVCDM_METRICS_METRICS_COLLECTIONS_H_
#define WVCDM_METRICS_METRICS_COLLECTIONS_H_
#include <stddef.h>
#include <stdint.h>
#include <mutex>
#include <ostream>
#include <string>
#include <vector>
#include "OEMCryptoCENC.h"
#include "counter_metric.h"
@@ -48,7 +51,7 @@
// sts);
#define M_TIME(CALL, GROUP, METRIC, ...) \
if (GROUP) { \
wvcdm::metrics::TimerMetric timer; \
wvcdm::metrics::Timer timer; \
timer.Start(); \
CALL; \
(GROUP)->METRIC.Record(timer.AsUs(), ##__VA_ARGS__); \
@@ -58,9 +61,7 @@
namespace wvcdm {
namespace metrics {
namespace {
// Short name definitions to ease AttributeHandler definitions.
// Internal namespace to help simplify declarations.
const int kErrorCodeFieldNumber =
@@ -73,8 +74,7 @@ const int kCdmSecurityLevelFieldNumber =
::drm_metrics::Attributes::kCdmSecurityLevelFieldNumber;
const int kSecurityLevelFieldNumber =
::drm_metrics::Attributes::kSecurityLevelFieldNumber;
const int kLengthFieldNumber =
::drm_metrics::Attributes::kLengthFieldNumber;
const int kLengthFieldNumber = ::drm_metrics::Attributes::kLengthFieldNumber;
const int kEncryptAlgorithmFieldNumber =
::drm_metrics::Attributes::kEncryptionAlgorithmFieldNumber;
const int kSigningAlgorithmFieldNumber =
@@ -89,8 +89,7 @@ const int kKeyRequestTypeFieldNumber =
::drm_metrics::Attributes::kKeyRequestTypeFieldNumber;
const int kLicenseTypeFieldNumber =
::drm_metrics::Attributes::kLicenseTypeFieldNumber;
} // anonymous namespace
} // namespace
// The maximum number of completed sessions that can be stored. More than this
// will cause some metrics to be discarded.
@@ -120,13 +119,14 @@ typedef enum OEMCryptoInitializationMode {
OEMCrypto_INITIALIZED_L3_SAVE_DEVICE_KEYS_FAILED = 18,
OEMCrypto_INITIALIZED_L3_READ_DEVICE_KEYS_FAILED = 19,
OEMCrypto_INITIALIZED_L3_VERIFY_DEVICE_KEYS_FAILED = 20,
OEMCrypto_INITIALIZED_USING_L1_WITH_PROVISIONING_4_0 = 21,
} OEMCryptoInitializationMode;
// This class contains metrics for Crypto Session and OEM Crypto.
class CryptoMetrics {
public:
void Serialize(drm_metrics::WvCdmMetrics::CryptoMetrics *crypto_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::CryptoMetrics* crypto_metrics) const;
/* CRYPTO SESSION */
// TODO(blueeyes): Convert this to crypto_session_default_security_level_.
@@ -156,7 +156,7 @@ class CryptoMetrics {
crypto_session_load_certificate_private_key_;
// This uses the requested security level.
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kSecurityLevelFieldNumber,
SecurityLevel>
RequestedSecurityLevel>
crypto_session_open_;
ValueMetric<uint32_t> crypto_session_system_id_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
@@ -234,7 +234,7 @@ class CryptoMetrics {
ValueMetric<bool> oemcrypto_is_anti_rollback_hw_present_;
ValueMetric<bool> oemcrypto_is_keybox_valid_;
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
oemcrypto_load_device_rsa_key_;
oemcrypto_load_device_drm_key_;
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
oemcrypto_load_entitled_keys_;
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
@@ -293,7 +293,13 @@ class CryptoMetrics {
oemcrypto_load_provisioning_;
ValueMetric<uint32_t> oemcrypto_minor_api_version_;
ValueMetric<uint32_t> oemcrypto_maximum_usage_table_header_size_;
};
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
oemcrypto_generate_certificate_key_pair_;
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
oemcrypto_install_oem_private_key_;
ValueMetric<int> oemcrypto_watermarking_support_;
ValueMetric<int> oemcrypto_production_readiness_;
}; // class CryptoMetrics
// This class contains session-scoped metrics. All properties and
// statistics related to operations within a single session are
@@ -304,12 +310,12 @@ class SessionMetrics {
// Sets the session id of the metrics group. This allows the session
// id to be captured and reported as part of the collection of metrics.
void SetSessionId(const CdmSessionId &session_id) {
void SetSessionId(const CdmSessionId& session_id) {
session_id_ = session_id;
}
// Returns the session id or an empty session id if it has not been set.
const CdmSessionId &GetSessionId() const { return session_id_; }
const CdmSessionId& GetSessionId() const { return session_id_; }
// Marks the metrics object as completed and ready for serialization.
void SetCompleted() { completed_ = true; }
@@ -320,16 +326,16 @@ class SessionMetrics {
// Returns a pointer to the crypto metrics belonging to the engine instance.
// This instance retains ownership of the object.
CryptoMetrics *GetCryptoMetrics() { return &crypto_metrics_; }
CryptoMetrics* GetCryptoMetrics() { return &crypto_metrics_; }
// Metrics collected at the session level.
ValueMetric<double> cdm_session_life_span_; // Milliseconds.
EventMetric<kErrorCodeFieldNumber, CdmResponseType> cdm_session_renew_key_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_session_restore_offline_session_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_session_restore_usage_session_;
EventMetric<kKeyRequestTypeFieldNumber, CdmKeyRequestType>
@@ -337,19 +343,21 @@ class SessionMetrics {
ValueMetric<std::string> oemcrypto_build_info_;
ValueMetric<std::string> license_sdk_version_;
ValueMetric<std::string> license_service_version_;
ValueMetric<std::string> playback_id_;
ValueMetric<int> drm_certificate_key_type_;
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
void Serialize(drm_metrics::WvCdmMetrics::SessionMetrics *session_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::SessionMetrics* session_metrics) const;
private:
void SerializeSessionMetrics(
drm_metrics::WvCdmMetrics::SessionMetrics *session_metrics) const;
drm_metrics::WvCdmMetrics::SessionMetrics* session_metrics) const;
CdmSessionId session_id_;
bool completed_;
CryptoMetrics crypto_metrics_;
};
}; // class SessionMetrics
// This class contains metrics for the OEMCrypto Dynamic Adapter. They are
// separated from other metrics because they need to be encapsulated in a
@@ -373,8 +381,8 @@ class OemCryptoDynamicAdapterMetrics {
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
void Serialize(drm_metrics::WvCdmMetrics::EngineMetrics *engine_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const;
// Clears the existing metric values.
void Clear();
@@ -388,14 +396,14 @@ class OemCryptoDynamicAdapterMetrics {
previous_oemcrypto_initialization_failure_;
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
};
}; // class OemCryptoDynamicAdapterMetrics
// This will fetch the singleton instance for dynamic adapter metrics.
// This method is safe only if we use C++ 11. In C++ 11, static function-local
// initialization is guaranteed to be threadsafe. We return the reference to
// avoid non-guaranteed destructor order problems. Effectively, the destructor
// is never run for the created instance.
OemCryptoDynamicAdapterMetrics &GetDynamicAdapterMetricsInstance();
OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance();
// This class contains engine-scoped metrics. All properties and
// statistics related to operations within the engine, but outside
@@ -426,18 +434,19 @@ class EngineMetrics {
// Returns a pointer to the crypto metrics belonging to the engine instance.
// The CryptoMetrics instance is still owned by this object and will exist
// until this object is deleted.
CryptoMetrics *GetCryptoMetrics() { return &crypto_metrics_; }
CryptoMetrics* GetCryptoMetrics() { return &crypto_metrics_; }
// Serialize engine and session metrics into a serialized WvCdmMetrics
// instance and output that instance to the provided |engine_metrics|.
// |engine_metrics| is owned by the caller and must NOT be null.
void Serialize(drm_metrics::WvCdmMetrics *engine_metrics) const;
void Serialize(drm_metrics::WvCdmMetrics* engine_metrics) const;
void SetAppPackageName(const std::string &app_package_name);
void SetAppPackageName(const std::string& app_package_name);
// Metrics recorded at the engine level.
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType> cdm_engine_add_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kLicenseTypeFieldNumber,
CdmLicenseType>
cdm_engine_add_key_;
ValueMetric<std::string> cdm_engine_cdm_version_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_close_session_;
@@ -447,15 +456,15 @@ class EngineMetrics {
cdm_engine_decrypt_;
CounterMetric<kErrorCodeBoolFieldNumber, bool>
cdm_engine_find_session_for_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType>
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kLicenseTypeFieldNumber,
CdmLicenseType>
cdm_engine_generate_key_request_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_provisioning_request_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_secure_stop_ids_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_engine_get_usage_info_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_handle_provisioning_response_;
@@ -486,15 +495,13 @@ class EngineMetrics {
std::vector<std::shared_ptr<metrics::SessionMetrics>>
completed_session_metrics_list_;
// This is used to populate the engine lifespan metric
metrics::TimerMetric life_span_internal_;
metrics::Timer life_span_internal_;
CryptoMetrics crypto_metrics_;
std::string app_package_name_;
void SerializeEngineMetrics(
drm_metrics::WvCdmMetrics::EngineMetrics *engine_metrics) const;
};
drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const;
}; // class EngineMetrics
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_METRICS_GROUP_H_
#endif // WVCDM_METRICS_METRICS_COLLECTIONS_H_