From 4d34dd9db01dc25a7c21ea5065cab6fadd392256 Mon Sep 17 00:00:00 2001 From: xiaomings Date: Mon, 29 Apr 2024 17:40:01 -0700 Subject: [PATCH] [media] Add UMA metrics for color space info (#3109) Now primaries, transfer, matrix, and range ids for both SDR and HDR playbacks are reported to UMA. b/322027866 Change-Id: Id58f73684404a5d8fc1051ca5a4c6b6083c8ff19 --- cobalt/media/base/sbplayer_bridge.cc | 20 ++++++ cobalt/media/base/sbplayer_bridge.h | 1 + .../histograms/metadata/cobalt/enums.xml | 71 +++++++++++++++++++ .../histograms/metadata/cobalt/histograms.xml | 68 ++++++++++++++++++ 4 files changed, 160 insertions(+) diff --git a/cobalt/media/base/sbplayer_bridge.cc b/cobalt/media/base/sbplayer_bridge.cc index 5d2bbe49845..0e5847119fd 100644 --- a/cobalt/media/base/sbplayer_bridge.cc +++ b/cobalt/media/base/sbplayer_bridge.cc @@ -23,6 +23,7 @@ #include "base/compiler_specific.h" #include "base/location.h" #include "base/logging.h" +#include "base/metrics/histogram_functions.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/statistics.h" #include "cobalt/media/base/format_support_query_metrics.h" @@ -273,6 +274,7 @@ SbPlayerBridge::SbPlayerBridge( } if (video_config.IsValidConfig()) { UpdateVideoConfig(video_config, video_mime_type); + SendColorSpaceHistogram(); } output_mode_ = ComputeSbPlayerOutputMode(default_output_mode); @@ -1360,5 +1362,23 @@ void SbPlayerBridge::LogStartupLatency() const { // clang-format on } +void SbPlayerBridge::SendColorSpaceHistogram() const { + using base::UmaHistogramEnumeration; + + const auto& cs_info = video_config_.color_space_info(); + + if (video_stream_info_.color_metadata.bits_per_channel > 8) { + UmaHistogramEnumeration("Cobalt.Media.HDR.Primaries", cs_info.primaries); + UmaHistogramEnumeration("Cobalt.Media.HDR.Transfer", cs_info.transfer); + UmaHistogramEnumeration("Cobalt.Media.HDR.Matrix", cs_info.matrix); + UmaHistogramEnumeration("Cobalt.Media.HDR.Range", cs_info.range); + } else { + UmaHistogramEnumeration("Cobalt.Media.SDR.Primaries", cs_info.primaries); + UmaHistogramEnumeration("Cobalt.Media.SDR.Transfer", cs_info.transfer); + UmaHistogramEnumeration("Cobalt.Media.SDR.Matrix", cs_info.matrix); + UmaHistogramEnumeration("Cobalt.Media.SDR.Range", cs_info.range); + } +} + } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/sbplayer_bridge.h b/cobalt/media/base/sbplayer_bridge.h index 147a2174f22..f6cc6879c12 100644 --- a/cobalt/media/base/sbplayer_bridge.h +++ b/cobalt/media/base/sbplayer_bridge.h @@ -245,6 +245,7 @@ class SbPlayerBridge { SbPlayerOutputMode default_output_mode) const; void LogStartupLatency() const; + void SendColorSpaceHistogram() const; // The following variables are initialized in the ctor and never changed. #if SB_HAS(PLAYER_WITH_URL) diff --git a/tools/metrics/histograms/metadata/cobalt/enums.xml b/tools/metrics/histograms/metadata/cobalt/enums.xml index f54fc6fdc46..17bce497598 100644 --- a/tools/metrics/histograms/metadata/cobalt/enums.xml +++ b/tools/metrics/histograms/metadata/cobalt/enums.xml @@ -69,6 +69,77 @@ https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histogra + + + Possible primary ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + + Possible transfer ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + + + + + + + Possible matrix ids reported by the Media Pipeline + + + + + + + + + + + + + + + + + + Possible range ids reported by the Media Pipeline + + + + + + + Possible status of Crashpad installation by the Loader App diff --git a/tools/metrics/histograms/metadata/cobalt/histograms.xml b/tools/metrics/histograms/metadata/cobalt/histograms.xml index 196672dee12..29323aafae6 100644 --- a/tools/metrics/histograms/metadata/cobalt/histograms.xml +++ b/tools/metrics/histograms/metadata/cobalt/histograms.xml @@ -131,6 +131,40 @@ Always run the pretty print utility on this file after editing: + + + + xiaomings@google.com + cobalt-team@google.com + Matrix id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Primary id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Range id used in HDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Transfer id used in HDR playbacks. + + @@ -260,6 +294,40 @@ Always run the pretty print utility on this file after editing: Timing data for the destruction of SbPlayer. + + + + xiaomings@google.com + cobalt-team@google.com + Matrix id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Primary id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Range id used in SDR playbacks. + + + + + + xiaomings@google.com + cobalt-team@google.com + Transfer id used in SDR playbacks. + +