| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/android/media_statistics.h" | 5 #include "media/base/android/media_statistics.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "media/base/android/demuxer_stream_player_params.h" | 9 #include "media/base/android/demuxer_stream_player_params.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ++late; | 34 ++late; |
| 35 } | 35 } |
| 36 | 36 |
| 37 MediaStatistics::MediaStatistics() {} | 37 MediaStatistics::MediaStatistics() {} |
| 38 | 38 |
| 39 MediaStatistics::~MediaStatistics() {} | 39 MediaStatistics::~MediaStatistics() {} |
| 40 | 40 |
| 41 void MediaStatistics::Start(base::TimeDelta current_playback_time) { | 41 void MediaStatistics::Start(base::TimeDelta current_playback_time) { |
| 42 DVLOG(1) << __FUNCTION__; | 42 DVLOG(1) << __FUNCTION__; |
| 43 | 43 |
| 44 if (start_time_ == kNoTimestamp()) { | 44 if (start_time_ == kNoTimestamp) { |
| 45 Clear(); | 45 Clear(); |
| 46 start_time_ = current_playback_time; | 46 start_time_ = current_playback_time; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void MediaStatistics::StopAndReport(base::TimeDelta current_playback_time) { | 50 void MediaStatistics::StopAndReport(base::TimeDelta current_playback_time) { |
| 51 DVLOG(1) << __FUNCTION__; | 51 DVLOG(1) << __FUNCTION__; |
| 52 | 52 |
| 53 if (start_time_ == kNoTimestamp()) | 53 if (start_time_ == kNoTimestamp) |
| 54 return; // skip if there was no prior Start(). | 54 return; // skip if there was no prior Start(). |
| 55 | 55 |
| 56 if (current_playback_time == kNoTimestamp()) { | 56 if (current_playback_time == kNoTimestamp) { |
| 57 // Cancel the start event and skip if current time is unknown. | 57 // Cancel the start event and skip if current time is unknown. |
| 58 start_time_ = kNoTimestamp(); | 58 start_time_ = kNoTimestamp; |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 | 61 |
| 62 base::TimeDelta duration = current_playback_time - start_time_; | 62 base::TimeDelta duration = current_playback_time - start_time_; |
| 63 | 63 |
| 64 // Reset start time. | 64 // Reset start time. |
| 65 start_time_ = kNoTimestamp(); | 65 start_time_ = kNoTimestamp; |
| 66 | 66 |
| 67 if (duration < base::TimeDelta::FromSeconds(kMinDurationInSeconds)) | 67 if (duration < base::TimeDelta::FromSeconds(kMinDurationInSeconds)) |
| 68 return; // duration is too short. | 68 return; // duration is too short. |
| 69 | 69 |
| 70 if (duration > base::TimeDelta::FromSeconds(kMaxDurationInSeconds)) | 70 if (duration > base::TimeDelta::FromSeconds(kMaxDurationInSeconds)) |
| 71 return; // duration is too long. | 71 return; // duration is too long. |
| 72 | 72 |
| 73 Report(duration); | 73 Report(duration); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void MediaStatistics::Clear() { | 76 void MediaStatistics::Clear() { |
| 77 start_time_ = kNoTimestamp(); | 77 start_time_ = kNoTimestamp; |
| 78 audio_frame_stats_.Clear(); | 78 audio_frame_stats_.Clear(); |
| 79 video_frame_stats_.Clear(); | 79 video_frame_stats_.Clear(); |
| 80 num_starvations_ = 0; | 80 num_starvations_ = 0; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MediaStatistics::Report(base::TimeDelta duration) { | 83 void MediaStatistics::Report(base::TimeDelta duration) { |
| 84 DVLOG(1) << __FUNCTION__ << " duration:" << duration | 84 DVLOG(1) << __FUNCTION__ << " duration:" << duration |
| 85 << " audio frames:" | 85 << " audio frames:" |
| 86 << audio_frame_stats_.late << "/" << audio_frame_stats_.total | 86 << audio_frame_stats_.late << "/" << audio_frame_stats_.total |
| 87 << " video frames:" | 87 << " video frames:" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 116 | 116 |
| 117 uint32_t total_frames = audio_frame_stats_.total ? audio_frame_stats_.total | 117 uint32_t total_frames = audio_frame_stats_.total ? audio_frame_stats_.total |
| 118 : video_frame_stats_.total; | 118 : video_frame_stats_.total; |
| 119 if (total_frames) { | 119 if (total_frames) { |
| 120 UMA_HISTOGRAM_COUNTS("Media.MSE.Starvations", | 120 UMA_HISTOGRAM_COUNTS("Media.MSE.Starvations", |
| 121 kOneMillion * num_starvations_ / total_frames); | 121 kOneMillion * num_starvations_ / total_frames); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace media | 125 } // namespace media |
| OLD | NEW |