Files
android/libwvdrmengine/cdm/metrics/src/value_metric.cpp
Adam Stone 795cf8a624 Revise a few metrics and add unit tests.
This is a merge of Widevine cl 39040.

A few of the metrics were not implemented, or implemented incorrectly in
O MR1. This cleans them up

Bug: 64001676

Test: Re-ran unit tests and added some additional tests. GPlay Movies check.

Change-Id: I1e8bcc36fecd76e72d853306075bc46d82f45161
2018-01-25 21:03:07 +00:00

124 lines
3.6 KiB
C++

// 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);
}
template<>
void Serialize<CdmUsageSupportType>(
MetricSerializer* serializer,
const std::string& metric_name,
const CdmUsageSupportType& value) {
serializer->SetInt32(metric_name, value);
}
} // namespace impl
} // namespace metrics
} // namespace wvcdm