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

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: 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 #include "media/base/android/media_statistics.h"
2
3 #include "base/logging.h"
4 #include "base/metrics/histogram_macros.h"
5 #include "media/base/android/demuxer_stream_player_params.h"
6
7 namespace media {
8
9 namespace {
10
11 // Minimum duration to report.
12 const int kMinDurationInSeconds = 2;
13
14 // Maximum duration to report.
15 const int kMaxDurationInSeconds = 3600;
16
17 // Number of slots in the histogram for duration.
18 const int kNumDurationSlots = 1800;
Ilya Sherman 2015/09/30 04:20:03 nit: Please leave a blank line after this one, for
Ilya Sherman 2015/09/30 04:20:03 Sorry, 1800 buckets is far too many for a histogra
Tima Vaisburd 2015/09/30 18:50:09 Done.
Tima Vaisburd 2015/09/30 18:50:09 Sorry, it was my bad thinking. Changed to 60 inste
19 }
20
21 void FrameStatistics::AddFrame() {
22 ++total;
23 }
24
25 void FrameStatistics::AddLateFrame(base::TimeDelta delay) {
26 // Do not collect the late frame if this is the first frame after start.
27 // This simplifies the MediaSourcePlayer case.
28 if (total == 1)
29 return;
30
31 DVLOG(1) << stream_type << " " << __FUNCTION__ << " delay:" << delay
32 << " total:" << total;
33 ++late;
34 }
35
36 MediaStatistics::MediaStatistics()
37 : audio_frames_(DemuxerStream::AUDIO),
38 video_frames_(DemuxerStream::VIDEO),
39 num_starvations_(0) {
40 }
41
42 MediaStatistics::~MediaStatistics() {}
43
44 void MediaStatistics::Start() {
45 DVLOG(1) << "MediaStatistics::" << __FUNCTION__;
xhwang 2015/09/30 21:02:57 nit: class name not necessary in the log..
Tima Vaisburd 2015/10/01 20:05:15 Removed everywhere in this class.
46
47 Clear();
48 start_time_ = base::TimeTicks::Now();
49 }
50
51 void MediaStatistics::AddStarvation() {
52 DVLOG(1) << "MediaStatistics::" << __FUNCTION__;
53 ++num_starvations_;
54 }
55
56 void MediaStatistics::StopAndReport() {
57 DVLOG(1) << "MediaStatistics::" << __FUNCTION__;
58
59 if (start_time_.is_null())
60 return; // skip if there was no prior Start().
61
62 base::TimeDelta duration = base::TimeTicks::Now() - start_time_;
qinmin 2015/09/29 23:47:44 The duration is calculated from system time. Shoul
Tima Vaisburd 2015/10/01 20:05:15 Done.
63
64 // Reset start time.
65 start_time_ = base::TimeTicks();
66
67 if (duration < base::TimeDelta::FromSeconds(kMinDurationInSeconds))
68 return; // duration is too short.
69
70 if (duration > base::TimeDelta::FromSeconds(kMaxDurationInSeconds))
71 return; // duration is too long.
72
73 Report(duration);
74 }
75
76 void MediaStatistics::Clear() {
77 audio_frames_.Clear();
78 video_frames_.Clear();
79 num_starvations_ = 0;
80 }
81
82 void MediaStatistics::Report(base::TimeDelta duration) {
83 DVLOG(1) << "MediaStatistics::" << __FUNCTION__ << " duration:" << duration
84 << " audio frames:"
85 << audio_frames_.late << "/" << audio_frames_.total
86 << " video frames:"
87 << video_frames_.late << "/" << video_frames_.total;
88
89 UMA_HISTOGRAM_CUSTOM_TIMES(
90 "Media.MSE.Duration", duration,
91 base::TimeDelta::FromSeconds(kMinDurationInSeconds),
92 base::TimeDelta::FromSeconds(kMaxDurationInSeconds), kNumDurationSlots);
93
94 // Number of late frames per one million frames.
95
96 if (audio_frames_.total) {
97 UMA_HISTOGRAM_COUNTS("Media.MSE.LateAudioFrames",
98 1000000 * audio_frames_.late / audio_frames_.total);
99 }
100
101 if (video_frames_.total) {
102 UMA_HISTOGRAM_COUNTS("Media.MSE.LateVideoFrames",
103 1000000 * video_frames_.late / video_frames_.total);
xhwang 2015/09/30 21:02:57 hmm, I wonder why we report frames per milliion fr
Tima Vaisburd 2015/10/01 20:05:15 We expect these values to be less than 1%, so part
104 }
105
106 // Number of starvations per one million frames.
107
108 uint32_t total_frames =
109 audio_frames_.total ? audio_frames_.total : video_frames_.total;
110 if (total_frames) {
111 UMA_HISTOGRAM_COUNTS("Media.MSE.Starvations",
112 1000000 * num_starvations_ / total_frames);
113 }
114 }
115
116 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698