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,10 +1,59 @@
cc_library {
// Copyright (C) 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
name: "libcdm_metrics_protos",
// Build host library for metrics_dump tool.
// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
// DEPENDING ON IT IN YOUR PROJECT. ***
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "vendor_widevine_license"
// to get the below license kinds:
// legacy_by_exception_only (by exception only)
default_applicable_licenses: ["vendor_widevine_license"],
}
cc_library_host_shared {
name: "libcdm_metrics_protos_full_host",
vendor: true,
include_dirs: ["external/protobuf/src"],
srcs: [
"wv_metrics.proto",
"wv_metrics.proto",
],
cflags: [
"-Wall",
"-Werror",
],
proto: {
export_proto_headers: true,
type: "full",
},
}
cc_library {
name: "libcdm_metrics_protos",
vendor: true,
srcs: [
"wv_metrics.proto",
],
cflags: [
@@ -16,5 +65,4 @@ cc_library {
export_proto_headers: true,
type: "full",
},
}

View File

@@ -1,113 +1,114 @@
// Copyright 2018 Google Inc. All Rights Reserved.
// Copyright 2018 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 implementations for the AttributeHandler.
#include "attribute_handler.h"
#include "OEMCryptoCENC.h"
#include "field_tuples.h"
#include "pow2bucket.h"
#include "wv_cdm_types.h"
namespace wvcdm {
namespace metrics {
//
// Specializations for setting attribute fields.
//
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorCodeFieldNumber,
CdmResponseType>(const CdmResponseType &cdm_error,
drm_metrics::Attributes *attributes) {
CdmResponseType>(const CdmResponseType& cdm_error,
drm_metrics::Attributes* attributes) {
attributes->set_error_code(cdm_error);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kCdmSecurityLevelFieldNumber,
CdmSecurityLevel>(
const CdmSecurityLevel &cdm_security_level,
drm_metrics::Attributes *attributes) {
const CdmSecurityLevel& cdm_security_level,
drm_metrics::Attributes* attributes) {
attributes->set_cdm_security_level(cdm_security_level);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kSecurityLevelFieldNumber,
SecurityLevel>(const SecurityLevel &security_level,
drm_metrics::Attributes *attributes) {
RequestedSecurityLevel>(
const RequestedSecurityLevel& security_level,
drm_metrics::Attributes* attributes) {
attributes->set_security_level(security_level);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorCodeBoolFieldNumber,
bool>(const bool &cdm_error,
drm_metrics::Attributes *attributes) {
bool>(const bool& cdm_error,
drm_metrics::Attributes* attributes) {
attributes->set_error_code_bool(cdm_error);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kOemCryptoResultFieldNumber,
OEMCryptoResult>(
const OEMCryptoResult &oem_crypto_result,
drm_metrics::Attributes *attributes) {
const OEMCryptoResult& oem_crypto_result,
drm_metrics::Attributes* attributes) {
attributes->set_oem_crypto_result(oem_crypto_result);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket>(
const Pow2Bucket &pow2, drm_metrics::Attributes *attributes) {
const Pow2Bucket& pow2, drm_metrics::Attributes* attributes) {
attributes->set_length(pow2.value());
}
template <>
void SetAttributeField<drm_metrics::Attributes::kEncryptionAlgorithmFieldNumber,
CdmEncryptionAlgorithm>(
const CdmEncryptionAlgorithm &encryption_algorithm,
drm_metrics::Attributes *attributes) {
const CdmEncryptionAlgorithm& encryption_algorithm,
drm_metrics::Attributes* attributes) {
attributes->set_encryption_algorithm(encryption_algorithm);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kSigningAlgorithmFieldNumber,
CdmSigningAlgorithm>(
const CdmSigningAlgorithm &signing_algorithm,
drm_metrics::Attributes *attributes) {
const CdmSigningAlgorithm& signing_algorithm,
drm_metrics::Attributes* attributes) {
attributes->set_signing_algorithm(signing_algorithm);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kKeyRequestTypeFieldNumber,
CdmKeyRequestType>(
const CdmKeyRequestType &key_request_type,
drm_metrics::Attributes *attributes) {
const CdmKeyRequestType& key_request_type,
drm_metrics::Attributes* attributes) {
attributes->set_key_request_type(key_request_type);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kLicenseTypeFieldNumber,
CdmLicenseType>(
const CdmLicenseType &license_type,
drm_metrics::Attributes *attributes) {
CdmLicenseType>(const CdmLicenseType& license_type,
drm_metrics::Attributes* attributes) {
attributes->set_license_type(license_type);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorDetailFieldNumber,
int32_t>(
const int32_t &error_detail,
drm_metrics::Attributes *attributes) {
int32_t>(const int32_t& error_detail,
drm_metrics::Attributes* attributes) {
attributes->set_error_detail(error_detail);
}
template <>
void SetAttributeField<0, util::Unused>(const util::Unused &,
drm_metrics::Attributes *) {
void SetAttributeField<0, util::Unused>(const util::Unused&,
drm_metrics::Attributes*) {
// Intentionally empty.
}
// Specializations only used by tests.
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorCodeFieldNumber, int>(
const int &cdm_error, drm_metrics::Attributes *attributes) {
const int& cdm_error, drm_metrics::Attributes* attributes) {
attributes->set_error_code(cdm_error);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,16 +1,15 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 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 implementations for the BaseCounterMetric, the base class
// for CounterMetric.
#include "counter_metric.h"
#include "wv_metrics.pb.h"
namespace wvcdm {
namespace metrics {
void BaseCounterMetric::Increment(const std::string &counter_key,
void BaseCounterMetric::Increment(const std::string& counter_key,
int64_t value) {
std::unique_lock<std::mutex> lock(internal_lock_);
@@ -20,6 +19,5 @@ void BaseCounterMetric::Increment(const std::string &counter_key,
value_map_[counter_key] = value_map_[counter_key] + value;
}
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,31 +1,19 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 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 the definitions for the Distribution class members.
#include "distribution.h"
#include <float.h>
namespace wvcdm {
namespace metrics {
Distribution::Distribution()
: count_(0ULL),
min_(FLT_MAX),
max_(-FLT_MAX),
mean_(0.0),
sum_squared_deviation_(0.0) {}
void Distribution::Record(float value) {
// Using method of provisional means.
float deviation = value - mean_;
mean_ = mean_ + (deviation / ++count_);
sum_squared_deviation_ =
sum_squared_deviation_ + (deviation * (value - mean_));
const float deviation = value - mean_;
mean_ += (deviation / ++count_);
sum_squared_deviation_ += (deviation * (value - mean_));
min_ = min_ < value ? min_ : value;
max_ = max_ > value ? max_ : value;
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,28 +1,23 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 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 implementations for the BaseEventMetric.
#include "event_metric.h"
using ::google::protobuf::RepeatedPtrField;
namespace wvcdm {
namespace metrics {
BaseEventMetric::~BaseEventMetric() {
std::unique_lock<std::mutex> lock(internal_lock_);
for (std::map<std::string, Distribution *>::iterator it = value_map_.begin();
for (std::map<std::string, Distribution*>::iterator it = value_map_.begin();
it != value_map_.end(); it++) {
delete it->second;
}
}
void BaseEventMetric::Record(const std::string &key, double value) {
void BaseEventMetric::Record(const std::string& key, double value) {
std::unique_lock<std::mutex> lock(internal_lock_);
Distribution *distribution;
Distribution* distribution;
if (value_map_.find(key) == value_map_.end()) {
distribution = new Distribution();
value_map_[key] = distribution;
@@ -32,6 +27,5 @@ void BaseEventMetric::Record(const std::string &key, double value) {
distribution->Record(value);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,5 +1,6 @@
// 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.
#include "metrics_collections.h"
#include <algorithm>
@@ -7,32 +8,28 @@
#include "log.h"
#include "wv_metrics.pb.h"
namespace wvcdm {
namespace metrics {
using ::drm_metrics::Attributes;
using ::drm_metrics::WvCdmMetrics;
using ::google::protobuf::RepeatedPtrField;
using ::wvcdm::metrics::EventMetric;
namespace {
// Helper struct for comparing session ids.
struct CompareSessionIds {
const std::string &target_;
const std::string& target_;
CompareSessionIds(const wvcdm::CdmSessionId &target) : target_(target){};
CompareSessionIds(const wvcdm::CdmSessionId& target) : target_(target){};
bool operator()(const std::shared_ptr<wvcdm::metrics::SessionMetrics> metrics)
const {
bool operator()(
const std::shared_ptr<wvcdm::metrics::SessionMetrics> metrics) const {
return metrics->GetSessionId() == target_;
}
};
} // namespace
} // anonymous namespace
namespace wvcdm {
namespace metrics {
void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
const {
void CryptoMetrics::Serialize(
WvCdmMetrics::CryptoMetrics* crypto_metrics) const {
/* CRYPTO SESSION */
crypto_metrics->set_allocated_crypto_session_security_level(
crypto_session_security_level_.ToProto());
@@ -140,8 +137,8 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
oemcrypto_is_anti_rollback_hw_present_.ToProto());
crypto_metrics->set_allocated_oemcrypto_is_keybox_valid(
oemcrypto_is_keybox_valid_.ToProto());
oemcrypto_load_device_rsa_key_.ToProto(
crypto_metrics->mutable_oemcrypto_load_device_rsa_key_time_us());
oemcrypto_load_device_drm_key_.ToProto(
crypto_metrics->mutable_oemcrypto_load_device_drm_key_time_us());
oemcrypto_load_entitled_keys_.ToProto(
crypto_metrics->mutable_oemcrypto_load_entitled_keys_time_us());
oemcrypto_load_keys_.ToProto(
@@ -182,8 +179,7 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
crypto_metrics->mutable_oemcrypto_create_new_usage_entry());
oemcrypto_load_usage_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_load_usage_entry());
oemcrypto_move_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_move_entry());
oemcrypto_move_entry_.ToProto(crypto_metrics->mutable_oemcrypto_move_entry());
oemcrypto_create_old_usage_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_create_old_usage_entry());
oemcrypto_copy_old_usage_entry_.ToProto(
@@ -213,18 +209,22 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
oemcrypto_minor_api_version_.ToProto());
crypto_metrics->set_allocated_oemcrypto_maximum_usage_table_header_size(
oemcrypto_maximum_usage_table_header_size_.ToProto());
crypto_metrics->set_allocated_oemcrypto_watermarking_support(
oemcrypto_watermarking_support_.ToProto());
crypto_metrics->set_allocated_oemcrypto_production_readiness(
oemcrypto_production_readiness_.ToProto());
}
SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {}
void SessionMetrics::Serialize(WvCdmMetrics::SessionMetrics *session_metrics)
const {
void SessionMetrics::Serialize(
WvCdmMetrics::SessionMetrics* session_metrics) const {
SerializeSessionMetrics(session_metrics);
crypto_metrics_.Serialize(session_metrics->mutable_crypto_metrics());
}
void SessionMetrics::SerializeSessionMetrics(
WvCdmMetrics::SessionMetrics *session_metrics) const {
WvCdmMetrics::SessionMetrics* session_metrics) const {
// If the session id was set, add it to the metrics. It's possible that
// it's not set in some circumstances such as when provisioning is needed.
if (!session_id_.empty()) {
@@ -246,6 +246,9 @@ void SessionMetrics::SerializeSessionMetrics(
license_sdk_version_.ToProto());
session_metrics->set_allocated_license_service_version(
license_service_version_.ToProto());
session_metrics->set_allocated_playback_id(playback_id_.ToProto());
session_metrics->set_allocated_drm_certificate_key_type(
drm_certificate_key_type_.ToProto());
}
OemCryptoDynamicAdapterMetrics::OemCryptoDynamicAdapterMetrics()
@@ -284,15 +287,15 @@ void OemCryptoDynamicAdapterMetrics::SetL1MinApiVersion(uint32_t version) {
}
void OemCryptoDynamicAdapterMetrics::Serialize(
WvCdmMetrics::EngineMetrics *engine_metrics) const {
WvCdmMetrics::EngineMetrics* engine_metrics) const {
std::unique_lock<std::mutex> lock(adapter_lock_);
engine_metrics->set_allocated_level3_oemcrypto_initialization_error(
oemcrypto_initialization_mode_.ToProto());
level3_oemcrypto_initialization_error_.ToProto());
engine_metrics->set_allocated_oemcrypto_initialization_mode(
oemcrypto_initialization_mode_.ToProto());
engine_metrics->set_allocated_previous_oemcrypto_initialization_failure(
oemcrypto_initialization_mode_.ToProto());
previous_oemcrypto_initialization_failure_.ToProto());
engine_metrics->set_allocated_oemcrypto_l1_api_version(
oemcrypto_l1_api_version_.ToProto());
engine_metrics->set_allocated_oemcrypto_l1_min_api_version(
@@ -311,22 +314,20 @@ void OemCryptoDynamicAdapterMetrics::Clear() {
// This method returns a reference. This means that the destructor is never
// executed for the returned object.
OemCryptoDynamicAdapterMetrics &GetDynamicAdapterMetricsInstance() {
OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance() {
// This is safe in C++ 11 since the initialization is guaranteed to run
// only once regardless of multi-threaded access.
static OemCryptoDynamicAdapterMetrics *adapter_metrics =
static OemCryptoDynamicAdapterMetrics* adapter_metrics =
new OemCryptoDynamicAdapterMetrics();
return *adapter_metrics;
}
EngineMetrics::EngineMetrics() {
life_span_internal_.Start();
}
EngineMetrics::EngineMetrics() { life_span_internal_.Start(); }
EngineMetrics::~EngineMetrics() {
std::unique_lock<std::mutex> lock(session_metrics_lock_);
if (!active_session_metrics_list_.empty()
|| !completed_session_metrics_list_.empty()) {
if (!active_session_metrics_list_.empty() ||
!completed_session_metrics_list_.empty()) {
LOGV("Session counts: active = %zu, completed = %zu.",
active_session_metrics_list_.size(),
completed_session_metrics_list_.size());
@@ -355,38 +356,36 @@ void EngineMetrics::RemoveSession(wvcdm::CdmSessionId session_id) {
void EngineMetrics::ConsolidateSessions() {
auto completed_filter =
[] (const std::shared_ptr<SessionMetrics>& session_metrics) {
[](const std::shared_ptr<SessionMetrics>& session_metrics) {
return session_metrics->IsCompleted();
};
std::unique_lock<std::mutex> lock(session_metrics_lock_);
std::copy_if(active_session_metrics_list_.begin(),
active_session_metrics_list_.end(),
std::back_inserter(completed_session_metrics_list_),
completed_filter);
std::copy_if(
active_session_metrics_list_.begin(), active_session_metrics_list_.end(),
std::back_inserter(completed_session_metrics_list_), completed_filter);
active_session_metrics_list_.erase(
std::remove_if(active_session_metrics_list_.begin(),
active_session_metrics_list_.end(),
completed_filter),
active_session_metrics_list_.end(), completed_filter),
active_session_metrics_list_.end());
// TODO(b/118664842): Add support to merge older metrics into one
// consolidated metric.
int excess_completed = completed_session_metrics_list_.size()
- kMaxCompletedSessions;
if (excess_completed > 0) {
if (completed_session_metrics_list_.size() > kMaxCompletedSessions) {
const size_t excess_completed =
completed_session_metrics_list_.size() - kMaxCompletedSessions;
completed_session_metrics_list_.erase(
completed_session_metrics_list_.begin(),
completed_session_metrics_list_.begin() + excess_completed);
}
}
void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const {
void EngineMetrics::Serialize(WvCdmMetrics* wv_metrics) const {
std::unique_lock<std::mutex> lock(session_metrics_lock_);
WvCdmMetrics::EngineMetrics *engine_metrics =
WvCdmMetrics::EngineMetrics* engine_metrics =
wv_metrics->mutable_engine_metrics();
// Serialize the most recent metrics from the OemCyrpto dynamic adapter.
OemCryptoDynamicAdapterMetrics &adapter_metrics =
OemCryptoDynamicAdapterMetrics& adapter_metrics =
GetDynamicAdapterMetricsInstance();
adapter_metrics.Serialize(engine_metrics);
if (!app_package_name_.empty()) {
@@ -405,12 +404,12 @@ void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const {
}
}
void EngineMetrics::SetAppPackageName(const std::string &app_package_name) {
void EngineMetrics::SetAppPackageName(const std::string& app_package_name) {
app_package_name_ = app_package_name;
}
void EngineMetrics::SerializeEngineMetrics(
WvCdmMetrics::EngineMetrics *engine_metrics) const {
WvCdmMetrics::EngineMetrics* engine_metrics) const {
// Set the engine lifespan at the time of serialization.
engine_metrics->mutable_cdm_engine_life_span_ms()->set_int_value(
life_span_internal_.AsMs());
@@ -460,6 +459,5 @@ void EngineMetrics::SerializeEngineMetrics(
crypto_metrics_.Serialize(engine_metrics->mutable_crypto_metrics());
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,24 +1,30 @@
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#include "timer_metric.h"
namespace wvcdm {
namespace metrics {
using ClockType = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<ClockType>;
void TimerMetric::Start() {
start_ = clock_.now();
void Timer::Start() {
start_ = ClockType::now();
is_started_ = true;
}
void TimerMetric::Clear() {
is_started_ = false;
void Timer::Clear() { is_started_ = false; }
double Timer::AsMs() const {
if (!is_started_) return 0.0;
const TimePoint end = ClockType::now();
return (end - start_) / std::chrono::milliseconds(1);
}
double TimerMetric::AsMs() const {
return (clock_.now() - start_) / std::chrono::milliseconds(1);
double Timer::AsUs() const {
if (!is_started_) return 0.0;
const TimePoint end = ClockType::now();
return (end - start_) / std::chrono::microseconds(1);
}
double TimerMetric::AsUs() const {
return (clock_.now() - start_) / std::chrono::microseconds(1);
}
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,115 +1,129 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 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 the specializations for helper methods for the
// ValueMetric class.
#include <stdint.h>
#include <string>
#include "value_metric.h"
#include <limits>
#include "OEMCryptoCENC.h"
#include "metrics_collections.h"
#include "wv_cdm_types.h"
namespace wvcdm {
namespace metrics {
namespace internal {
namespace {
// Max value of protobuf's int64 type.
constexpr uint64_t kMaxValueCmp =
static_cast<uint64_t>(std::numeric_limits<int64_t>::max());
constexpr int64_t kMaxValue = std::numeric_limits<int64_t>::max();
namespace impl{
template <typename T>
constexpr bool WillOverflow(T value) {
return static_cast<uint64_t>(value) > kMaxValueCmp;
}
// Prevents an overflow of very large numbers. If the value attempted to
// be assigned is greater than the maximum value supported by protobuf's
// int64 type, then the value is capped at the max.
template <typename T>
constexpr int64_t SafeAssign(T value) {
return WillOverflow(value) ? kMaxValue : static_cast<int64_t>(value);
}
} // namespace
template <>
void SetValue<int>(drm_metrics::ValueMetric *value_proto,
const int &value) {
value_proto->set_int_value(value);
void SetValue<int>(drm_metrics::ValueMetric* value_proto, const int& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<long>(drm_metrics::ValueMetric *value_proto,
const long &value) {
value_proto->set_int_value(value);
void SetValue<long>(drm_metrics::ValueMetric* value_proto, const long& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<long long>(drm_metrics::ValueMetric *value_proto,
const long long &value) {
value_proto->set_int_value(value);
void SetValue<long long>(drm_metrics::ValueMetric* value_proto,
const long long& value) {
value_proto->set_int_value(SafeAssign(value));
}
template <>
void SetValue<unsigned int>(drm_metrics::ValueMetric *value_proto,
const unsigned int &value) {
value_proto->set_int_value((int64_t)value);
void SetValue<unsigned int>(drm_metrics::ValueMetric* value_proto,
const unsigned int& value) {
value_proto->set_int_value(SafeAssign(value));
}
template <>
void SetValue<unsigned short>(drm_metrics::ValueMetric *value_proto,
const unsigned short &value) {
value_proto->set_int_value((int64_t)value);
void SetValue<unsigned short>(drm_metrics::ValueMetric* value_proto,
const unsigned short& value) {
value_proto->set_int_value(SafeAssign(value));
}
template <>
void SetValue<unsigned long>(drm_metrics::ValueMetric *value_proto,
const unsigned long &value) {
value_proto->set_int_value((int64_t)value);
void SetValue<unsigned long>(drm_metrics::ValueMetric* value_proto,
const unsigned long& value) {
value_proto->set_int_value(SafeAssign(value));
}
template <>
void SetValue<unsigned long long>(drm_metrics::ValueMetric *value_proto,
const unsigned long long &value) {
value_proto->set_int_value((int64_t)value);
void SetValue<unsigned long long>(drm_metrics::ValueMetric* value_proto,
const unsigned long long& value) {
value_proto->set_int_value(SafeAssign(value));
}
template <>
void SetValue<bool>(drm_metrics::ValueMetric *value_proto,
const bool &value) {
value_proto->set_int_value(value);
void SetValue<bool>(drm_metrics::ValueMetric* value_proto, const bool& value) {
value_proto->set_int_value(value ? 1 : 0);
}
template <>
void SetValue<OEMCrypto_HDCP_Capability>(
drm_metrics::ValueMetric *value_proto,
const OEMCrypto_HDCP_Capability &value) {
value_proto->set_int_value(value);
drm_metrics::ValueMetric* value_proto,
const OEMCrypto_HDCP_Capability& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<OEMCrypto_ProvisioningMethod>(
drm_metrics::ValueMetric *value_proto,
const OEMCrypto_ProvisioningMethod &value) {
value_proto->set_int_value(value);
drm_metrics::ValueMetric* value_proto,
const OEMCrypto_ProvisioningMethod& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<OEMCryptoInitializationMode>(
drm_metrics::ValueMetric *value_proto,
const OEMCryptoInitializationMode &value) {
value_proto->set_int_value(value);
drm_metrics::ValueMetric* value_proto,
const OEMCryptoInitializationMode& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<CdmSecurityLevel>(drm_metrics::ValueMetric *value_proto,
const CdmSecurityLevel &value) {
value_proto->set_int_value(value);
void SetValue<CdmSecurityLevel>(drm_metrics::ValueMetric* value_proto,
const CdmSecurityLevel& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<CdmUsageSupportType>(drm_metrics::ValueMetric *value_proto,
const CdmUsageSupportType &value) {
value_proto->set_int_value(value);
void SetValue<CdmUsageSupportType>(drm_metrics::ValueMetric* value_proto,
const CdmUsageSupportType& value) {
value_proto->set_int_value(static_cast<int64_t>(value));
}
template <>
void SetValue<double>(drm_metrics::ValueMetric *value_proto,
const double &value) {
void SetValue<double>(drm_metrics::ValueMetric* value_proto,
const double& value) {
value_proto->set_double_value(value);
}
template <>
void SetValue<std::string>(drm_metrics::ValueMetric *value_proto,
const std::string &value) {
void SetValue<std::string>(drm_metrics::ValueMetric* value_proto,
const std::string& value) {
value_proto->set_string_value(value);
}
} // namespace impl
} // namespace internal
} // namespace metrics
} // namespace wvcdm

View File

@@ -1,4 +1,6 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 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 a proto definition for serialization of metrics data.
//
@@ -15,10 +17,7 @@ option optimize_for = LITE_RUNTIME;
// want to count all of the operations with a give error code.
message Attributes {
// Reserved for compatibility with logging proto.
// TODO(blueeyes): The reserved keyword is not supported in the older version
// of protoc in the CE CDM third_party directory. Uncomment the reserved
// line when we upgrade. b/67016366.
// reserved 8, 10 to 13;
reserved 8, 10 to 13;
// The error code. See CdmResponseType in wv_cdm_types.h
optional int32 error_code = 1;
@@ -93,7 +92,7 @@ message WvCdmMetrics {
// This contains metrics that were captured at the CryptoSession level. These
// include CryptoSession metrics and most OEMCrypto metrics.
// next id: 85
// next id: 87
message CryptoMetrics {
// Crypto Session Metrics.
optional ValueMetric crypto_session_security_level = 1;
@@ -155,7 +154,7 @@ message WvCdmMetrics {
repeated DistributionMetric oemcrypto_initialize_time_us = 38;
optional ValueMetric oemcrypto_is_anti_rollback_hw_present = 39;
optional ValueMetric oemcrypto_is_keybox_valid = 40;
repeated DistributionMetric oemcrypto_load_device_rsa_key_time_us = 41;
repeated DistributionMetric oemcrypto_load_device_drm_key_time_us = 41;
repeated DistributionMetric oemcrypto_load_entitled_keys_time_us = 42;
repeated DistributionMetric oemcrypto_load_keys_time_us = 43;
optional ValueMetric oemcrypto_max_hdcp_capability = 44;
@@ -182,8 +181,6 @@ message WvCdmMetrics {
optional ValueMetric oemcrypto_set_sandbox = 70;
repeated CounterMetric oemcrypto_set_decrypt_hash = 71;
optional ValueMetric oemcrypto_resource_rating_tier = 72;
// TODO(b/142684157): Remove this comment before closing bug.
// OemCrypto V16 metrics start at 77 (4 new metrics pending review).
repeated DistributionMetric
oemcrypto_prep_and_sign_license_request_time_us = 77;
repeated DistributionMetric
@@ -195,11 +192,13 @@ message WvCdmMetrics {
repeated DistributionMetric oemcrypto_load_provisioning_time_us = 82;
optional ValueMetric oemcrypto_minor_api_version = 83;
optional ValueMetric oemcrypto_maximum_usage_table_header_size = 84;
optional ValueMetric oemcrypto_watermarking_support = 85;
optional ValueMetric oemcrypto_production_readiness = 86;
}
// This contains metrics that were captured within a CdmSession. This contains
// nested CryptoMetrics that were captured in the context of the session.
// next id: 9
// next id: 13
message SessionMetrics {
optional ValueMetric session_id = 1;
optional CryptoMetrics crypto_metrics = 2;
@@ -211,6 +210,9 @@ message WvCdmMetrics {
optional ValueMetric oemcrypto_build_info = 8;
optional ValueMetric license_sdk_version = 9;
optional ValueMetric license_service_version = 10;
optional ValueMetric playback_id = 11;
// Value is enumerated based on the OEMCrypto document: RSA = 0, ECC = 1
optional ValueMetric drm_certificate_key_type = 12;
}
// These are metrics recorded at the Engine level. This includes CryptoSession