Improve summarized statistics
better management of how summarized records are managed.
Use differentiated names for the summations to avoid confusion with
individual records. Track values appropriate to calculating
min, max, mean, and standard deviation.
Bug: 65027360
Test: examination of dumpsys media.metrics -summary
Change-Id: I40d93d8a5a7cc2c188546574f59d557088d9c1e3
diff --git a/services/mediaanalytics/MetricsSummarizerPlayer.cpp b/services/mediaanalytics/MetricsSummarizerPlayer.cpp
index 5162059..f882cb9 100644
--- a/services/mediaanalytics/MetricsSummarizerPlayer.cpp
+++ b/services/mediaanalytics/MetricsSummarizerPlayer.cpp
@@ -51,37 +51,43 @@
setIgnorables(player_ignorable);
}
+// NB: this is also called for the first time -- so summation == item
+// Not sure if we need a flag for that or not.
+// In this particular mergeRecord() code -- we're' ok for this.
void MetricsSummarizerPlayer::mergeRecord(MediaAnalyticsItem &summation, MediaAnalyticsItem &item) {
ALOGV("MetricsSummarizerPlayer::mergeRecord()");
- //
- // we sum time & frames.
- // be careful about our special "-1" values that indicate 'unknown'
- // treat those as 0 [basically, not summing them into the totals].
+
int64_t duration = 0;
if (item.getInt64("android.media.mediaplayer.durationMs", &duration)) {
ALOGV("found durationMs of %" PRId64, duration);
- summation.addInt64("android.media.mediaplayer.durationMs",duration);
+ minMaxVar64(summation, "android.media.mediaplayer.durationMs", duration);
}
+
int64_t playing = 0;
- if (item.getInt64("android.media.mediaplayer.playingMs", &playing))
+ if (item.getInt64("android.media.mediaplayer.playingMs", &playing)) {
ALOGV("found playingMs of %" PRId64, playing);
- if (playing >= 0) {
- summation.addInt64("android.media.mediaplayer.playingMs",playing);
- }
+ }
+ if (playing >= 0) {
+ minMaxVar64(summation,"android.media.mediaplayer.playingMs",playing);
+ }
+
int64_t frames = 0;
- if (item.getInt64("android.media.mediaplayer.frames", &frames))
+ if (item.getInt64("android.media.mediaplayer.frames", &frames)) {
ALOGV("found framess of %" PRId64, frames);
- if (frames >= 0) {
- summation.addInt64("android.media.mediaplayer.frames",frames);
- }
+ }
+ if (frames >= 0) {
+ minMaxVar64(summation,"android.media.mediaplayer.frames",frames);
+ }
+
int64_t dropped = 0;
- if (item.getInt64("android.media.mediaplayer.dropped", &dropped))
+ if (item.getInt64("android.media.mediaplayer.dropped", &dropped)) {
ALOGV("found dropped of %" PRId64, dropped);
- if (dropped >= 0) {
- summation.addInt64("android.media.mediaplayer.dropped",dropped);
- }
+ }
+ if (dropped >= 0) {
+ minMaxVar64(summation,"android.media.mediaplayer.dropped",dropped);
+ }
}
} // namespace android