blob: f882cb9106ed088ca85082c8cc5bbdf092bcb5bb [file] [log] [blame]
Ray Essick2e9c63b2017-03-29 15:16:44 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "MetricsSummarizerPlayer"
18#include <utils/Log.h>
19
20#include <stdint.h>
21#include <inttypes.h>
22
23#include <utils/threads.h>
24#include <utils/Errors.h>
25#include <utils/KeyedVector.h>
26#include <utils/String8.h>
27#include <utils/List.h>
28
29#include <media/IMediaAnalyticsService.h>
30
31#include "MetricsSummarizer.h"
32#include "MetricsSummarizerPlayer.h"
33
34
35
36
37namespace android {
38
39static const char *player_ignorable[] = {
40 "android.media.mediaplayer.durationMs",
41 "android.media.mediaplayer.playingMs",
42 "android.media.mediaplayer.frames",
43 "android.media.mediaplayer.dropped",
44 0
45};
46
47MetricsSummarizerPlayer::MetricsSummarizerPlayer(const char *key)
48 : MetricsSummarizer(key)
49{
50 ALOGV("MetricsSummarizerPlayer::MetricsSummarizerPlayer");
51 setIgnorables(player_ignorable);
52}
53
Ray Essick96eaaac2017-08-31 11:45:05 -070054// NB: this is also called for the first time -- so summation == item
55// Not sure if we need a flag for that or not.
56// In this particular mergeRecord() code -- we're' ok for this.
Ray Essick2e9c63b2017-03-29 15:16:44 -070057void MetricsSummarizerPlayer::mergeRecord(MediaAnalyticsItem &summation, MediaAnalyticsItem &item) {
58
59 ALOGV("MetricsSummarizerPlayer::mergeRecord()");
60
Ray Essick96eaaac2017-08-31 11:45:05 -070061
Ray Essick2e9c63b2017-03-29 15:16:44 -070062 int64_t duration = 0;
63 if (item.getInt64("android.media.mediaplayer.durationMs", &duration)) {
64 ALOGV("found durationMs of %" PRId64, duration);
Ray Essick96eaaac2017-08-31 11:45:05 -070065 minMaxVar64(summation, "android.media.mediaplayer.durationMs", duration);
Ray Essick2e9c63b2017-03-29 15:16:44 -070066 }
Ray Essick96eaaac2017-08-31 11:45:05 -070067
Ray Essick2e9c63b2017-03-29 15:16:44 -070068 int64_t playing = 0;
Ray Essick96eaaac2017-08-31 11:45:05 -070069 if (item.getInt64("android.media.mediaplayer.playingMs", &playing)) {
Ray Essick2e9c63b2017-03-29 15:16:44 -070070 ALOGV("found playingMs of %" PRId64, playing);
Ray Essick96eaaac2017-08-31 11:45:05 -070071 }
72 if (playing >= 0) {
73 minMaxVar64(summation,"android.media.mediaplayer.playingMs",playing);
74 }
75
Ray Essick2e9c63b2017-03-29 15:16:44 -070076 int64_t frames = 0;
Ray Essick96eaaac2017-08-31 11:45:05 -070077 if (item.getInt64("android.media.mediaplayer.frames", &frames)) {
Ray Essick2e9c63b2017-03-29 15:16:44 -070078 ALOGV("found framess of %" PRId64, frames);
Ray Essick96eaaac2017-08-31 11:45:05 -070079 }
80 if (frames >= 0) {
81 minMaxVar64(summation,"android.media.mediaplayer.frames",frames);
82 }
83
Ray Essick2e9c63b2017-03-29 15:16:44 -070084 int64_t dropped = 0;
Ray Essick96eaaac2017-08-31 11:45:05 -070085 if (item.getInt64("android.media.mediaplayer.dropped", &dropped)) {
Ray Essick2e9c63b2017-03-29 15:16:44 -070086 ALOGV("found dropped of %" PRId64, dropped);
Ray Essick96eaaac2017-08-31 11:45:05 -070087 }
88 if (dropped >= 0) {
89 minMaxVar64(summation,"android.media.mediaplayer.dropped",dropped);
90 }
Ray Essick2e9c63b2017-03-29 15:16:44 -070091}
92
93} // namespace android