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,50 @@
// Copyright 2018 Google Inc. All Rights Reserved.
//
// This file contains the declaration of the Pow2Bucket class which
// is a convenient way to bucketize sampled values into powers of 2.
#ifndef WVCDM_METRICS_POW2BUCKET_H_
#define WVCDM_METRICS_POW2BUCKET_H_
namespace wvcdm {
namespace metrics {
// This class converts the size_t value into the highest power of two
// below the value. E.g. for 7, the value is 4. For 11, the value is 8.
// This class is intended to simplify the use of EventMetric Fields that may
// have many possible values, but we want to bucket them into a small set of
// numbers (32 or 64).
class Pow2Bucket {
public:
explicit Pow2Bucket(size_t value) : value_(GetLowerBucket(value)) {}
Pow2Bucket(const Pow2Bucket &value) : value_(value.value_) {}
size_t value() const { return value_; }
// Support for converting to string.
friend std::ostream &operator<<(std::ostream &os, const Pow2Bucket &log) {
return os << log.value_;
}
private:
inline size_t GetLowerBucket(size_t value) {
if (!value) {
return 0;
}
size_t log = 0;
while (value) {
log++;
value >>= 1;
}
return 1u << (log - 1);
}
size_t value_;
};
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_POW2BUCKET_H_