// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. // // Take a line as input, parse the metrics, and returns MediaMetrics // structure as output. #include #include #include namespace metrics_dump { // This is the order of metrics prior to R release, do not change. // We use this to index into a vector of tokens to retrieve metrics. typedef enum { kIndexQ, kVersionQ, kComponentQ, kSessionQ, kUidQ, kPackageQ, kPackageVersionQ, kPidQ, kFinalizedQ, kTimestampQ, kItemCountQ, // kPropertiesQ serves as a sentinel to indicate properties follow kPropertiesQ, } QMediaMetricsItems; // This is the order of metrics since R release, do not change. // We use this to index into a vector of tokens to retrieve metrics. typedef enum { kIndexR, kComponentR, kTimestampR, kPackageR, kPidR, kUidR, // kPropertiesR serves as a sentinel to indicate properties follow kPropertiesR, } RMediaMetricsItems; typedef struct { std::string component, finalized, index, item_count; std::string package, package_version, pid, session; std::string timestamp, version, uid; std::vector> properties; } MediaMetrics; bool is_q_metrics(const std::string &line); void parse_metrics(const std::string& line, MediaMetrics* metrics); void to_lower(std::string& lower); }; // namespace metrics_dump