Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: media/base/android/media_statistics.cc

Issue 1367403003: Added UMA metrics for MediaSourcePlayer and MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-drm
Patch Set: Addressed Xiaohan's comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/android/media_statistics.h"
6
7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "media/base/android/demuxer_stream_player_params.h"
10
11 // Limit the value by 9999. Since we multiply |a| by one million before, this
12 // bound means that |a| will never exceed 1%.
13 #define LIMIT_10000(a) std::min(a, 9999U)
Tima Vaisburd 2015/10/02 00:44:32 The Widevine testing on Shaka player shows up to 7
14
15 namespace media {
16
17 namespace {
xhwang 2015/10/01 21:58:58 nit: no need to have anonymous namespace here. nam
Tima Vaisburd 2015/10/02 00:44:32 Done.
18
19 // Minimum playback interval to report.
20 const int kMinDurationInSeconds = 2;
21
22 // Maximum playback interval to report.
23 const int kMaxDurationInSeconds = 3600;
24
25 // Number of slots in the histogram for playback interval.
26 const int kNumDurationSlots = 50;
27
28 // For easier reading.
29 const int kOneMillion = 1000000;
30 }
31
32 MediaStatistics::MediaStatistics() {}
33
34 MediaStatistics::~MediaStatistics() {}
35
36 void MediaStatistics::Start(base::TimeDelta current_playback_time) {
37 DVLOG(1) << __FUNCTION__;
38
39 Clear();
40 start_time_ = current_playback_time;
41 }
42
43 void MediaStatistics::StopAndReport(base::TimeDelta current_playback_time) {
44 DVLOG(1) << __FUNCTION__;
45
46 if (start_time_ == kNoTimestamp())
47 return; // skip if there was no prior Start().
48
49 base::TimeDelta duration = current_playback_time - start_time_;
50
51 // Reset start time.
52 start_time_ = kNoTimestamp();
53
54 if (duration < base::TimeDelta::FromSeconds(kMinDurationInSeconds))
55 return; // duration is too short.
56
57 if (duration > base::TimeDelta::FromSeconds(kMaxDurationInSeconds))
58 return; // duration is too long.
59
60 Report(duration);
61 }
62
63 void MediaStatistics::Clear() {
64 start_time_ = kNoTimestamp();
65 audio_frames_.Clear();
66 video_frames_.Clear();
67 num_starvations_ = 0;
68 }
69
70 void MediaStatistics::Report(base::TimeDelta duration) {
71 DVLOG(1) << __FUNCTION__ << " duration:" << duration
72 << " audio frames:"
73 << audio_frames_.late << "/" << audio_frames_.total
74 << " video frames:"
75 << video_frames_.late << "/" << video_frames_.total;
76
77 // Playback duration is the time interval between the moment playback starts
78 // and the moment it is interrupted either by stopping or by seeking, changing
79 // to full screen, minimizing the browser etc. The interval is measured by
80 // media time.
81
82 UMA_HISTOGRAM_CUSTOM_TIMES(
83 "Media.MSE.PlaybackDuration", duration,
84 base::TimeDelta::FromSeconds(kMinDurationInSeconds),
85 base::TimeDelta::FromSeconds(kMaxDurationInSeconds), kNumDurationSlots);
86
87 // Number of late frames per one million frames.
88 // We expect the ratios of the late frames to the total number of frames to be
89 // less than 1%, therefore after multiplying by one millon the range should be
90 // [0, 10000].
91
92 if (audio_frames_.total) {
93 UMA_HISTOGRAM_COUNTS_10000(
94 "Media.MSE.LateAudioFrames",
95 LIMIT_10000(kOneMillion * audio_frames_.late / audio_frames_.total));
96 }
97
98 if (video_frames_.total) {
99 UMA_HISTOGRAM_COUNTS_10000(
100 "Media.MSE.LateVideoFrames",
101 LIMIT_10000(kOneMillion * video_frames_.late / video_frames_.total));
102 }
103
104 // Number of starvations per one million frames.
105
106 uint32_t total_frames =
107 audio_frames_.total ? audio_frames_.total : video_frames_.total;
108 if (total_frames) {
109 UMA_HISTOGRAM_COUNTS_10000(
110 "Media.MSE.Starvations",
111 LIMIT_10000(kOneMillion * num_starvations_ / total_frames));
112 }
113 }
114
115 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698