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:
Adam Stone
2018-02-20 19:12:02 -08:00
parent efc008c5a1
commit b19f0d106f
25 changed files with 1587 additions and 1867 deletions

View File

@@ -0,0 +1,89 @@
// Copyright 2018 Google Inc. All Rights Reserved.
//
// This file contains implementations for the AttributeHandler.
#include "attribute_handler.h"
#include "OEMCryptoCENC.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) {
attributes->set_error_code(cdm_error);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kCdmSecurityLevelFieldNumber,
CdmSecurityLevel>(
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) {
attributes->set_security_level(security_level);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorCodeBoolFieldNumber,
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) {
attributes->set_oem_crypto_result(oem_crypto_result);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket>(
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) {
attributes->set_encryption_algorithm(encryption_algorithm);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kSigningAlgorithmFieldNumber,
CdmSigningAlgorithm>(
const CdmSigningAlgorithm &signing_algorithm,
drm_metrics::Attributes *attributes) {
attributes->set_signing_algorithm(signing_algorithm);
}
template <>
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) {
attributes->set_error_code(cdm_error);
}
} // namespace metrics
} // namespace wvcdm