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

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

Issue 1726503003: Move histograms for rtp receive counters to ReceiveStatisticsProxy (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 | « webrtc/video/receive_statistics_proxy.h ('k') | webrtc/video/video_receive_stream.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
11 #include "webrtc/video/receive_statistics_proxy.h" 11 #include "webrtc/video/receive_statistics_proxy.h"
12 12
13 #include <cmath> 13 #include <cmath>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 16 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
17 #include "webrtc/system_wrappers/include/clock.h" 17 #include "webrtc/system_wrappers/include/clock.h"
18 #include "webrtc/system_wrappers/include/metrics.h" 18 #include "webrtc/system_wrappers/include/metrics.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) 22 ReceiveStatisticsProxy::ReceiveStatisticsProxy(
23 const VideoReceiveStream::Config& config,
24 Clock* clock)
23 : clock_(clock), 25 : clock_(clock),
26 config_(config),
24 // 1000ms window, scale 1000 for ms to s. 27 // 1000ms window, scale 1000 for ms to s.
25 decode_fps_estimator_(1000, 1000), 28 decode_fps_estimator_(1000, 1000),
26 renders_fps_estimator_(1000, 1000), 29 renders_fps_estimator_(1000, 1000),
27 render_fps_tracker_(100u, 10u), 30 render_fps_tracker_(100u, 10u),
28 render_pixel_tracker_(100u, 10u) { 31 render_pixel_tracker_(100u, 10u) {
29 stats_.ssrc = ssrc; 32 stats_.ssrc = config.rtp.remote_ssrc;
33 for (auto it : config.rtp.rtx)
34 rtx_stats_[it.second.ssrc] = StreamDataCounters();
30 } 35 }
31 36
32 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { 37 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() {
33 UpdateHistograms(); 38 UpdateHistograms();
34 } 39 }
35 40
36 void ReceiveStatisticsProxy::UpdateHistograms() { 41 void ReceiveStatisticsProxy::UpdateHistograms() {
37 int fraction_lost = report_block_stats_.FractionLostInPercent(); 42 int fraction_lost = report_block_stats_.FractionLostInPercent();
38 if (fraction_lost != -1) { 43 if (fraction_lost != -1) {
39 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", 44 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent",
(...skipping 21 matching lines...) Expand all
61 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and 66 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and
62 // not per frame. Change decode time to include every frame. 67 // not per frame. Change decode time to include every frame.
63 const int kMinRequiredDecodeSamples = 5; 68 const int kMinRequiredDecodeSamples = 5;
64 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); 69 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples);
65 if (decode_ms != -1) 70 if (decode_ms != -1)
66 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); 71 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms);
67 72
68 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); 73 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples);
69 if (delay_ms != -1) 74 if (delay_ms != -1)
70 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); 75 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms);
76
77 StreamDataCounters rtp = stats_.rtp_stats;
78 StreamDataCounters rtx;
79 for (auto it : rtx_stats_)
80 rtx.Add(it.second);
81 StreamDataCounters rtp_rtx = rtp;
82 rtp_rtx.Add(rtx);
83 int64_t elapsed_sec =
84 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000;
85 if (elapsed_sec > metrics::kMinRunTimeInSeconds) {
86 RTC_HISTOGRAM_COUNTS_10000(
87 "WebRTC.Video.BitrateReceivedInKbps",
88 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
89 1000));
90 RTC_HISTOGRAM_COUNTS_10000(
91 "WebRTC.Video.MediaBitrateReceivedInKbps",
92 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000));
93 RTC_HISTOGRAM_COUNTS_10000(
94 "WebRTC.Video.PaddingBitrateReceivedInKbps",
95 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec /
96 1000));
97 RTC_HISTOGRAM_COUNTS_10000(
98 "WebRTC.Video.RetransmittedBitrateReceivedInKbps",
99 static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / elapsed_sec /
100 1000));
101 if (!rtx_stats_.empty()) {
102 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateReceivedInKbps",
103 static_cast<int>(rtx.transmitted.TotalBytes() *
104 8 / elapsed_sec / 1000));
105 }
106 if (config_.rtp.fec.ulpfec_payload_type != -1) {
107 RTC_HISTOGRAM_COUNTS_10000(
108 "WebRTC.Video.FecBitrateReceivedInKbps",
109 static_cast<int>(rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000));
110 }
111 }
71 } 112 }
72 113
73 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { 114 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
74 rtc::CritScope lock(&crit_); 115 rtc::CritScope lock(&crit_);
75 return stats_; 116 return stats_;
76 } 117 }
77 118
78 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) { 119 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) {
79 rtc::CritScope lock(&crit_); 120 rtc::CritScope lock(&crit_);
80 stats_.current_payload_type = payload_type; 121 stats_.current_payload_type = payload_type;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // receive stats from one of them. 182 // receive stats from one of them.
142 if (stats_.ssrc != ssrc) 183 if (stats_.ssrc != ssrc)
143 return; 184 return;
144 stats_.c_name = cname; 185 stats_.c_name = cname;
145 } 186 }
146 187
147 void ReceiveStatisticsProxy::DataCountersUpdated( 188 void ReceiveStatisticsProxy::DataCountersUpdated(
148 const webrtc::StreamDataCounters& counters, 189 const webrtc::StreamDataCounters& counters,
149 uint32_t ssrc) { 190 uint32_t ssrc) {
150 rtc::CritScope lock(&crit_); 191 rtc::CritScope lock(&crit_);
151 if (stats_.ssrc != ssrc) 192 if (ssrc == stats_.ssrc) {
152 return; 193 stats_.rtp_stats = counters;
153 stats_.rtp_stats = counters; 194 } else {
195 auto it = rtx_stats_.find(ssrc);
196 if (it != rtx_stats_.end()) {
197 it->second = counters;
198 } else {
199 RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc;
200 }
201 }
154 } 202 }
155 203
156 void ReceiveStatisticsProxy::OnDecodedFrame() { 204 void ReceiveStatisticsProxy::OnDecodedFrame() {
157 uint64_t now = clock_->TimeInMilliseconds(); 205 uint64_t now = clock_->TimeInMilliseconds();
158 206
159 rtc::CritScope lock(&crit_); 207 rtc::CritScope lock(&crit_);
160 decode_fps_estimator_.Update(1, now); 208 decode_fps_estimator_.Update(1, now);
161 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); 209 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now);
162 } 210 }
163 211
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ++num_samples; 254 ++num_samples;
207 } 255 }
208 256
209 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { 257 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const {
210 if (num_samples < min_required_samples || num_samples == 0) 258 if (num_samples < min_required_samples || num_samples == 0)
211 return -1; 259 return -1;
212 return sum / num_samples; 260 return sum / num_samples;
213 } 261 }
214 262
215 } // namespace webrtc 263 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/receive_statistics_proxy.h ('k') | webrtc/video/video_receive_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698