Fixes widevine metrics proto serialization
Changes to a much more efficient and more reusable protobuf format for metrics. Test: Widevine tests, Google Play and MediaDrm CTS test. Bug: 73724218 Change-Id: I3299051d7a16bcd7758c8f272415ca40e10c1313
This commit is contained in:
@@ -8,114 +8,100 @@
|
||||
|
||||
#include "value_metric.h"
|
||||
|
||||
#include "metrics_collections.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "metrics_collections.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// Private namespace for some helper implementation functions.
|
||||
namespace impl {
|
||||
namespace impl{
|
||||
|
||||
template<>
|
||||
void Serialize<int32_t>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const int32_t& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<int>(drm_metrics::ValueMetric *value_proto,
|
||||
const int &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<int64_t>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const int64_t& value) {
|
||||
serializer->SetInt64(metric_name, value);
|
||||
template <>
|
||||
void SetValue<long>(drm_metrics::ValueMetric *value_proto,
|
||||
const long &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
// This specialization forces the uint32_t to an int32_t.
|
||||
template<>
|
||||
void Serialize<uint32_t>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const uint32_t& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<long long>(drm_metrics::ValueMetric *value_proto,
|
||||
const long long &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
// This specialization forces the uint32_t to an int64_t.
|
||||
template<>
|
||||
void Serialize<uint64_t>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const uint64_t& value) {
|
||||
serializer->SetInt64(metric_name, value);
|
||||
template <>
|
||||
void SetValue<unsigned int>(drm_metrics::ValueMetric *value_proto,
|
||||
const unsigned int &value) {
|
||||
value_proto->set_int_value((int64_t)value);
|
||||
}
|
||||
|
||||
// This specialization forces a bool to an int32_t.
|
||||
template<>
|
||||
void Serialize<bool>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const bool& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<unsigned short>(drm_metrics::ValueMetric *value_proto,
|
||||
const unsigned short &value) {
|
||||
value_proto->set_int_value((int64_t)value);
|
||||
}
|
||||
|
||||
// This specialization forces an unsigned short to an int32_t.
|
||||
template<>
|
||||
void Serialize<unsigned short>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const unsigned short& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<unsigned long>(drm_metrics::ValueMetric *value_proto,
|
||||
const unsigned long &value) {
|
||||
value_proto->set_int_value((int64_t)value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<std::string>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const std::string& value) {
|
||||
serializer->SetString(metric_name, value);
|
||||
template <>
|
||||
void SetValue<bool>(drm_metrics::ValueMetric *value_proto,
|
||||
const bool &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<double>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const double& value) {
|
||||
serializer->SetDouble(metric_name, value);
|
||||
template <>
|
||||
void SetValue<OEMCrypto_HDCP_Capability>(
|
||||
drm_metrics::ValueMetric *value_proto,
|
||||
const OEMCrypto_HDCP_Capability &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
// These specializations force CDM-specific types to int32_t
|
||||
template<>
|
||||
void Serialize<CdmSecurityLevel>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const CdmSecurityLevel& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<OEMCrypto_ProvisioningMethod>(
|
||||
drm_metrics::ValueMetric *value_proto,
|
||||
const OEMCrypto_ProvisioningMethod &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<OEMCrypto_HDCP_Capability>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCrypto_HDCP_Capability& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<OEMCryptoInitializationMode>(
|
||||
drm_metrics::ValueMetric *value_proto,
|
||||
const OEMCryptoInitializationMode &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<OEMCrypto_ProvisioningMethod>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCrypto_ProvisioningMethod& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<CdmSecurityLevel>(drm_metrics::ValueMetric *value_proto,
|
||||
const CdmSecurityLevel &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<OEMCryptoInitializationMode>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCryptoInitializationMode& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
void SetValue<CdmUsageSupportType>(drm_metrics::ValueMetric *value_proto,
|
||||
const CdmUsageSupportType &value) {
|
||||
value_proto->set_int_value(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<CdmUsageSupportType>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const CdmUsageSupportType& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
template <>
|
||||
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) {
|
||||
value_proto->set_string_value(value);
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
|
||||
Reference in New Issue
Block a user