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

Side by Side Diff: webrtc/video/receive_statistics_proxy.cc

Issue 2873303002: Add some unit tests to ReceiveStatsticsProxy. (Closed)
Patch Set: address comment Created 3 years, 7 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
« no previous file with comments | « no previous file | webrtc/video/receive_statistics_proxy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 "WebRTC.Video.ReceiveStreamLifetimeInSeconds", 97 "WebRTC.Video.ReceiveStreamLifetimeInSeconds",
98 (clock_->TimeInMilliseconds() - start_ms_) / 1000); 98 (clock_->TimeInMilliseconds() - start_ms_) / 1000);
99 99
100 if (first_report_block_time_ms_ != -1 && 100 if (first_report_block_time_ms_ != -1 &&
101 ((clock_->TimeInMilliseconds() - first_report_block_time_ms_) / 1000) >= 101 ((clock_->TimeInMilliseconds() - first_report_block_time_ms_) / 1000) >=
102 metrics::kMinRunTimeInSeconds) { 102 metrics::kMinRunTimeInSeconds) {
103 int fraction_lost = report_block_stats_.FractionLostInPercent(); 103 int fraction_lost = report_block_stats_.FractionLostInPercent();
104 if (fraction_lost != -1) { 104 if (fraction_lost != -1) {
105 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", 105 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent",
106 fraction_lost); 106 fraction_lost);
107 LOG(LS_INFO) << "WebRTC.Video.ReceivedPacketsLostInPercent "
108 << fraction_lost;
107 } 109 }
108 } 110 }
109 111
110 const int kMinRequiredSamples = 200; 112 const int kMinRequiredSamples = 200;
111 int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount()); 113 int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount());
112 if (samples > kMinRequiredSamples) { 114 if (samples >= kMinRequiredSamples) {
113 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", 115 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond",
114 round(render_fps_tracker_.ComputeTotalRate())); 116 round(render_fps_tracker_.ComputeTotalRate()));
115 RTC_HISTOGRAM_COUNTS_100000( 117 RTC_HISTOGRAM_COUNTS_100000(
116 "WebRTC.Video.RenderSqrtPixelsPerSecond", 118 "WebRTC.Video.RenderSqrtPixelsPerSecond",
117 round(render_pixel_tracker_.ComputeTotalRate())); 119 round(render_pixel_tracker_.ComputeTotalRate()));
118 } 120 }
119 int width = render_width_counter_.Avg(kMinRequiredSamples); 121 int width = render_width_counter_.Avg(kMinRequiredSamples);
120 int height = render_height_counter_.Avg(kMinRequiredSamples); 122 int height = render_height_counter_.Avg(kMinRequiredSamples);
121 if (width != -1) { 123 if (width != -1) {
122 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); 124 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width);
123 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); 125 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height);
126 LOG(LS_INFO) << "WebRTC.Video.ReceivedWidthInPixels " << width;
127 LOG(LS_INFO) << "WebRTC.Video.ReceivedHeightInPixels " << height;
124 } 128 }
125 int sync_offset_ms = sync_offset_counter_.Avg(kMinRequiredSamples); 129 int sync_offset_ms = sync_offset_counter_.Avg(kMinRequiredSamples);
126 if (sync_offset_ms != -1) { 130 if (sync_offset_ms != -1) {
127 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.AVSyncOffsetInMs", sync_offset_ms); 131 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.AVSyncOffsetInMs", sync_offset_ms);
132 LOG(LS_INFO) << "WebRTC.Video.AVSyncOffsetInMs " << sync_offset_ms;
128 } 133 }
129 AggregatedStats freq_offset_stats = freq_offset_counter_.GetStats(); 134 AggregatedStats freq_offset_stats = freq_offset_counter_.GetStats();
130 if (freq_offset_stats.num_samples > 0) { 135 if (freq_offset_stats.num_samples > 0) {
131 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtpToNtpFreqOffsetInKhz", 136 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtpToNtpFreqOffsetInKhz",
132 freq_offset_stats.average); 137 freq_offset_stats.average);
133 LOG(LS_INFO) << "WebRTC.Video.RtpToNtpFreqOffsetInKhz, " 138 LOG(LS_INFO) << "WebRTC.Video.RtpToNtpFreqOffsetInKhz, "
134 << freq_offset_stats.ToString(); 139 << freq_offset_stats.ToString();
135 } 140 }
136 141
137 int num_total_frames = 142 int num_total_frames =
138 stats_.frame_counts.key_frames + stats_.frame_counts.delta_frames; 143 stats_.frame_counts.key_frames + stats_.frame_counts.delta_frames;
139 if (num_total_frames >= kMinRequiredSamples) { 144 if (num_total_frames >= kMinRequiredSamples) {
140 int num_key_frames = stats_.frame_counts.key_frames; 145 int num_key_frames = stats_.frame_counts.key_frames;
141 int key_frames_permille = 146 int key_frames_permille =
142 (num_key_frames * 1000 + num_total_frames / 2) / num_total_frames; 147 (num_key_frames * 1000 + num_total_frames / 2) / num_total_frames;
143 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", 148 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille",
144 key_frames_permille); 149 key_frames_permille);
150 LOG(LS_INFO) << "WebRTC.Video.KeyFramesReceivedInPermille "
151 << key_frames_permille;
145 } 152 }
146 153
147 int qp = qp_counters_.vp8.Avg(kMinRequiredSamples); 154 int qp = qp_counters_.vp8.Avg(kMinRequiredSamples);
148 if (qp != -1) 155 if (qp != -1) {
149 RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", qp); 156 RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", qp);
150 157 LOG(LS_INFO) << "WebRTC.Video.Decoded.Vp8.Qp " << qp;
158 }
151 int decode_ms = decode_time_counter_.Avg(kMinRequiredSamples); 159 int decode_ms = decode_time_counter_.Avg(kMinRequiredSamples);
152 if (decode_ms != -1) 160 if (decode_ms != -1) {
153 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); 161 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms);
154 162 LOG(LS_INFO) << "WebRTC.Video.DecodeTimeInMs " << decode_ms;
163 }
155 int jb_delay_ms = jitter_buffer_delay_counter_.Avg(kMinRequiredSamples); 164 int jb_delay_ms = jitter_buffer_delay_counter_.Avg(kMinRequiredSamples);
156 if (jb_delay_ms != -1) { 165 if (jb_delay_ms != -1) {
157 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", 166 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs",
158 jb_delay_ms); 167 jb_delay_ms);
168 LOG(LS_INFO) << "WebRTC.Video.JitterBufferDelayInMs " << jb_delay_ms;
159 } 169 }
160 170
161 int target_delay_ms = target_delay_counter_.Avg(kMinRequiredSamples); 171 int target_delay_ms = target_delay_counter_.Avg(kMinRequiredSamples);
162 if (target_delay_ms != -1) { 172 if (target_delay_ms != -1) {
163 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", target_delay_ms); 173 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", target_delay_ms);
174 LOG(LS_INFO) << "WebRTC.Video.TargetDelayInMs " << target_delay_ms;
164 } 175 }
165 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples); 176 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples);
166 if (current_delay_ms != -1) { 177 if (current_delay_ms != -1) {
167 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", 178 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs",
168 current_delay_ms); 179 current_delay_ms);
180 LOG(LS_INFO) << "WebRTC.Video.CurrentDelayInMs " << current_delay_ms;
169 } 181 }
170 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); 182 int delay_ms = delay_counter_.Avg(kMinRequiredSamples);
171 if (delay_ms != -1) 183 if (delay_ms != -1)
172 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); 184 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms);
173 185
174 int e2e_delay_ms_video = e2e_delay_counter_video_.Avg(kMinRequiredSamples); 186 int e2e_delay_ms_video = e2e_delay_counter_video_.Avg(kMinRequiredSamples);
175 if (e2e_delay_ms_video != -1) { 187 if (e2e_delay_ms_video != -1) {
176 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.EndToEndDelayInMs", 188 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.EndToEndDelayInMs",
177 e2e_delay_ms_video); 189 e2e_delay_ms_video);
190 LOG(LS_INFO) << "WebRTC.Video.EndToEndDelayInMs " << e2e_delay_ms_video;
178 } 191 }
179 192
180 int e2e_delay_ms_screenshare = 193 int e2e_delay_ms_screenshare =
181 e2e_delay_counter_screenshare_.Avg(kMinRequiredSamples); 194 e2e_delay_counter_screenshare_.Avg(kMinRequiredSamples);
182 if (e2e_delay_ms_screenshare != -1) { 195 if (e2e_delay_ms_screenshare != -1) {
183 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.EndToEndDelayInMs", 196 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.EndToEndDelayInMs",
184 e2e_delay_ms_screenshare); 197 e2e_delay_ms_screenshare);
185 } 198 }
186 199
187 int e2e_delay_max_ms_video = e2e_delay_max_ms_video_; 200 int e2e_delay_max_ms_video = e2e_delay_max_ms_video_;
188 if (e2e_delay_max_ms_video != -1) { 201 if (e2e_delay_max_ms_video != -1) {
189 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.EndToEndDelayMaxInMs", 202 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.EndToEndDelayMaxInMs",
190 e2e_delay_max_ms_video); 203 e2e_delay_max_ms_video);
191 } 204 }
192 205
193 int e2e_delay_max_ms_screenshare = e2e_delay_max_ms_screenshare_; 206 int e2e_delay_max_ms_screenshare = e2e_delay_max_ms_screenshare_;
194 if (e2e_delay_max_ms_screenshare != -1) { 207 if (e2e_delay_max_ms_screenshare != -1) {
195 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.Screenshare.EndToEndDelayMaxInMs", 208 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.Screenshare.EndToEndDelayMaxInMs",
196 e2e_delay_max_ms_screenshare); 209 e2e_delay_max_ms_screenshare);
197 } 210 }
198 211
199 StreamDataCounters rtp = stats_.rtp_stats; 212 StreamDataCounters rtp = stats_.rtp_stats;
200 StreamDataCounters rtx; 213 StreamDataCounters rtx;
201 for (auto it : rtx_stats_) 214 for (auto it : rtx_stats_)
202 rtx.Add(it.second); 215 rtx.Add(it.second);
203 StreamDataCounters rtp_rtx = rtp; 216 StreamDataCounters rtp_rtx = rtp;
204 rtp_rtx.Add(rtx); 217 rtp_rtx.Add(rtx);
205 int64_t elapsed_sec = 218 int64_t elapsed_sec =
206 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; 219 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000;
207 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { 220 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) {
208 RTC_HISTOGRAM_COUNTS_10000( 221 RTC_HISTOGRAM_COUNTS_10000(
209 "WebRTC.Video.BitrateReceivedInKbps", 222 "WebRTC.Video.BitrateReceivedInKbps",
210 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / 223 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
211 1000)); 224 1000));
212 RTC_HISTOGRAM_COUNTS_10000( 225 RTC_HISTOGRAM_COUNTS_10000(
213 "WebRTC.Video.MediaBitrateReceivedInKbps", 226 "WebRTC.Video.MediaBitrateReceivedInKbps",
214 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); 227 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000));
215 RTC_HISTOGRAM_COUNTS_10000( 228 RTC_HISTOGRAM_COUNTS_10000(
216 "WebRTC.Video.PaddingBitrateReceivedInKbps", 229 "WebRTC.Video.PaddingBitrateReceivedInKbps",
217 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / 230 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec /
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 sum = 0; 602 sum = 0;
590 } 603 }
591 604
592 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, 605 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms,
593 int64_t max_rtt_ms) { 606 int64_t max_rtt_ms) {
594 rtc::CritScope lock(&crit_); 607 rtc::CritScope lock(&crit_);
595 avg_rtt_ms_ = avg_rtt_ms; 608 avg_rtt_ms_ = avg_rtt_ms;
596 } 609 }
597 610
598 } // namespace webrtc 611 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/receive_statistics_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698