Create two new metric types to simplify metrics.
This is part one of a mult-part change to revise some metrics. Several metrics are currently EventMetric type when they should be a simpler type. Test: Added unit tests for the new types. Also, re-ran existing tests. Verified playback works with Google Play, and re-ran Widevine GTS tests. Bug: 36220619 Change-Id: I2ec8fc355f66ad4834dd722aacd22541fb9c94ad
This commit is contained in:
115
libwvdrmengine/cdm/metrics/src/value_metric.cpp
Normal file
115
libwvdrmengine/cdm/metrics/src/value_metric.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This file contains the specializations for helper methods for the
|
||||
// ValueMetric class.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "value_metric.h"
|
||||
|
||||
#include "metrics_collections.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// Private namespace for some helper implementation functions.
|
||||
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 Serialize<int64_t>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const int64_t& value) {
|
||||
serializer->SetInt64(metric_name, 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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 Serialize<std::string>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const std::string& value) {
|
||||
serializer->SetString(metric_name, value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<double>(MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const double& value) {
|
||||
serializer->SetDouble(metric_name, 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 Serialize<OEMCrypto_HDCP_Capability>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCrypto_HDCP_Capability& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<OEMCrypto_ProvisioningMethod>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCrypto_ProvisioningMethod& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialize<OEMCryptoInitializationMode>(
|
||||
MetricSerializer* serializer,
|
||||
const std::string& metric_name,
|
||||
const OEMCryptoInitializationMode& value) {
|
||||
serializer->SetInt32(metric_name, value);
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
Reference in New Issue
Block a user