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

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

Issue 1367403003: Added UMA metrics for MediaSourcePlayer and MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-drm
Patch Set: Addressed most of the 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 #ifndef MEDIA_BASE_ANDROID_MEDIA_STATISTICS_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_STATISTICS_H_
7
8 #include <stdint.h>
9 #include "base/time/time.h"
10 #include "media/base/demuxer_stream.h"
11
12 namespace media {
13
14 // FrameStatistics struct deals with frames of one stream, i.e. either
15 // audio or video.
16 struct FrameStatistics {
17 // Stream type that this statistics belong to (Audio or Video).
18 DemuxerStream::Type stream_type;
19
20 // Audio: total number of frame that has been rendered.
Ilya Sherman 2015/10/01 07:19:20 nit: "has" -> "have"
Tima Vaisburd 2015/10/01 20:05:16 Done.
21 // Video: total amount of frames thatwere supposed to be rendered. Late video
Ilya Sherman 2015/10/01 07:19:20 nit: "thatwere" -> "that were"
Tima Vaisburd 2015/10/01 20:05:16 Done.
22 // frames might be skipped, but are counted here.
23 uint32_t total;
24
25 // A number of late frames. Late frames are a subset of the total frames.
xhwang 2015/09/30 21:02:58 What's the definition of being late?
Tima Vaisburd 2015/10/01 20:05:15 Copied the text from histogram.xml
26 uint32_t late;
xhwang 2015/09/30 21:02:57 nit: consider using Non-Static Class Member Initia
Tima Vaisburd 2015/10/01 20:05:15 Done.
27
28 FrameStatistics(DemuxerStream::Type type)
29 : stream_type(type), total(0), late(0) {}
30
31 void Clear() { total = late = 0; }
32
33 // Adds a frame to |total|.
34 void AddFrame() { ++total; }
35
36 // Adds a frame to |late|. For each AddLateFrame() call there should be
37 // preceding AddFrame() call.
38 void AddLateFrame(base::TimeDelta delay);
39 };
40
41 // MediaStatistics class gathers and reports playback quality statistics to UMA.
42 //
43 // This class is not thread safe. The caller should guarantee that operations
44 // on FrameStatistics objects does not happen during Start() and
45 // StopAndReport(). The Start() and StopAndReport() methods need to be called
46 // sequantially.
47
48 class MediaStatistics {
49 public:
50 MediaStatistics();
51 ~MediaStatistics();
52
53 // Returns the frame statistics for audio frames.
54 FrameStatistics& audio_frames() { return audio_frames_; }
xhwang 2015/09/30 21:02:58 nit: s/audio_frame/audio_frame_statistic
Tima Vaisburd 2015/10/01 20:05:16 The only place in the code it is being called has
55
56 // Returns the frame statistics for video frames.
57 FrameStatistics& video_frames() { return video_frames_; }
xhwang 2015/09/30 21:02:58 ditto
Tima Vaisburd 2015/10/01 20:05:16 See above
58
59 // Starts gathering statistics. Can be called several times in the row, the
60 // latest call takes effect.
61 void Start(base::TimeDelta current_playback_time);
62
63 // Stops gathering statistics, calculate and report results. Can be called
64 // several times in a row, without a prior Start() this call is ignored.
65 void StopAndReport(base::TimeDelta current_playback_time);
xhwang 2015/09/30 21:02:58 When called in a row, will only the first call tak
Tima Vaisburd 2015/10/01 20:05:16 This is what I wanted to say. Changed the comment.
66
67 // Adds starvation event.
68 void AddStarvation() { ++num_starvations_; }
69
70 private:
71 // Resets the data to the initial state.
72 void Clear();
73
74 // Calculates relative data based on total frame numbers and reports it and
75 // the duration to UMA.
76 void Report(base::TimeDelta duration);
77
78 base::TimeDelta start_time_;
79 FrameStatistics audio_frames_;
80 FrameStatistics video_frames_;
81 uint32_t num_starvations_;
82 };
83
84 } // namespace media
85
86 #endif // MEDIA_BASE_ANDROID_MEDIA_STATISTICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698