OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 namespace { | 24 namespace { |
25 // Used by histograms. Values of entries should not be changed. | 25 // Used by histograms. Values of entries should not be changed. |
26 enum HistogramCodecType { | 26 enum HistogramCodecType { |
27 kVideoUnknown = 0, | 27 kVideoUnknown = 0, |
28 kVideoVp8 = 1, | 28 kVideoVp8 = 1, |
29 kVideoVp9 = 2, | 29 kVideoVp9 = 2, |
30 kVideoH264 = 3, | 30 kVideoH264 = 3, |
31 kVideoMax = 64, | 31 kVideoMax = 64, |
32 }; | 32 }; |
33 | 33 |
| 34 const char* GetUmaPrefix(VideoEncoderConfig::ContentType content_type) { |
| 35 switch (content_type) { |
| 36 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
| 37 return "WebRTC.Video."; |
| 38 case VideoEncoderConfig::ContentType::kScreen: |
| 39 return "WebRTC.Video.Screenshare."; |
| 40 } |
| 41 RTC_NOTREACHED(); |
| 42 return nullptr; |
| 43 } |
| 44 |
34 HistogramCodecType PayloadNameToHistogramCodecType( | 45 HistogramCodecType PayloadNameToHistogramCodecType( |
35 const std::string& payload_name) { | 46 const std::string& payload_name) { |
36 if (payload_name == "VP8") { | 47 if (payload_name == "VP8") { |
37 return kVideoVp8; | 48 return kVideoVp8; |
38 } else if (payload_name == "VP9") { | 49 } else if (payload_name == "VP9") { |
39 return kVideoVp9; | 50 return kVideoVp9; |
40 } else if (payload_name == "H264") { | 51 } else if (payload_name == "H264") { |
41 return kVideoH264; | 52 return kVideoH264; |
42 } else { | 53 } else { |
43 return kVideoUnknown; | 54 return kVideoUnknown; |
44 } | 55 } |
45 } | 56 } |
46 | 57 |
47 void UpdateCodecTypeHistogram(const std::string& payload_name) { | 58 void UpdateCodecTypeHistogram(const std::string& payload_name) { |
48 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", | 59 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", |
49 PayloadNameToHistogramCodecType(payload_name), kVideoMax); | 60 PayloadNameToHistogramCodecType(payload_name), kVideoMax); |
50 } | 61 } |
51 } // namespace | 62 } // namespace |
52 | 63 |
53 | 64 |
54 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; | 65 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
55 | 66 |
56 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, | 67 SendStatisticsProxy::SendStatisticsProxy( |
57 const VideoSendStream::Config& config) | 68 Clock* clock, |
| 69 const VideoSendStream::Config& config, |
| 70 VideoEncoderConfig::ContentType content_type) |
58 : clock_(clock), | 71 : clock_(clock), |
59 config_(config), | 72 config_(config), |
60 input_frame_rate_tracker_(100u, 10u), | 73 content_type_(content_type), |
61 sent_frame_rate_tracker_(100u, 10u), | |
62 last_sent_frame_timestamp_(0), | 74 last_sent_frame_timestamp_(0), |
63 max_sent_width_per_timestamp_(0), | 75 uma_container_(new UmaSamplesContainer(GetUmaPrefix(content_type_))) { |
64 max_sent_height_per_timestamp_(0) { | |
65 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | 76 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); |
66 } | 77 } |
67 | 78 |
68 SendStatisticsProxy::~SendStatisticsProxy() { | 79 SendStatisticsProxy::~SendStatisticsProxy() {} |
| 80 |
| 81 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( |
| 82 const char* prefix) |
| 83 : uma_prefix_(prefix), |
| 84 max_sent_width_per_timestamp_(0), |
| 85 max_sent_height_per_timestamp_(0), |
| 86 input_frame_rate_tracker_(100u, 10u), |
| 87 sent_frame_rate_tracker_(100u, 10u) {} |
| 88 |
| 89 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { |
69 UpdateHistograms(); | 90 UpdateHistograms(); |
70 } | 91 } |
71 | 92 |
72 void SendStatisticsProxy::UpdateHistograms() { | 93 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { |
73 const int kMinRequiredSamples = 200; | 94 const int kMinRequiredSamples = 200; |
74 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 95 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
75 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 96 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
76 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | 97 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); |
77 if (in_width != -1) { | 98 if (in_width != -1) { |
78 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); | 99 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputWidthInPixels", in_width); |
79 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); | 100 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputHeightInPixels", in_height); |
80 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", in_fps); | 101 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "InputFramesPerSecond", in_fps); |
81 } | 102 } |
82 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 103 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
83 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 104 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
84 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); | 105 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); |
85 if (sent_width != -1) { | 106 if (sent_width != -1) { |
86 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); | 107 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentWidthInPixels", sent_width); |
87 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); | 108 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentHeightInPixels", sent_height); |
88 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); | 109 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "SentFramesPerSecond", sent_fps); |
89 } | 110 } |
90 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 111 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
91 if (encode_ms != -1) | 112 if (encode_ms != -1) |
92 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); | 113 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "EncodeTimeInMs", encode_ms); |
93 | 114 |
94 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); | 115 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
95 if (key_frames_permille != -1) { | 116 if (key_frames_permille != -1) { |
96 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", | 117 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "KeyFramesSentInPermille", |
97 key_frames_permille); | 118 key_frames_permille); |
98 } | 119 } |
99 int quality_limited = | 120 int quality_limited = |
100 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 121 quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
101 if (quality_limited != -1) { | 122 if (quality_limited != -1) { |
102 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", | 123 RTC_HISTOGRAM_PERCENTAGE(uma_prefix_ + "QualityLimitedResolutionInPercent", |
103 quality_limited); | 124 quality_limited); |
104 } | 125 } |
105 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 126 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
106 if (downscales != -1) { | 127 if (downscales != -1) { |
107 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", | 128 RTC_HISTOGRAM_ENUMERATION( |
108 downscales, 20); | 129 uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 20); |
109 } | 130 } |
110 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); | 131 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
111 if (bw_limited != -1) { | 132 if (bw_limited != -1) { |
112 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", | 133 RTC_HISTOGRAM_PERCENTAGE( |
113 bw_limited); | 134 uma_prefix_ + "BandwidthLimitedResolutionInPercent", bw_limited); |
114 } | 135 } |
115 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); | 136 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
116 if (num_disabled != -1) { | 137 if (num_disabled != -1) { |
117 RTC_HISTOGRAM_ENUMERATION( | 138 RTC_HISTOGRAM_ENUMERATION( |
118 "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); | 139 uma_prefix_ + "BandwidthLimitedResolutionsDisabled", num_disabled, 10); |
119 } | 140 } |
120 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 141 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
121 if (delay_ms != -1) | 142 if (delay_ms != -1) |
122 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.SendSideDelayInMs", delay_ms); | 143 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayInMs", delay_ms); |
123 | 144 |
124 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 145 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
125 if (max_delay_ms != -1) { | 146 if (max_delay_ms != -1) { |
126 RTC_HISTOGRAM_COUNTS_100000( | 147 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayMaxInMs", |
127 "WebRTC.Video.SendSideDelayMaxInMs", max_delay_ms); | 148 max_delay_ms); |
128 } | 149 } |
129 } | 150 } |
130 | 151 |
| 152 void SendStatisticsProxy::SetContentType( |
| 153 VideoEncoderConfig::ContentType content_type) { |
| 154 rtc::CritScope lock(&crit_); |
| 155 if (content_type_ != content_type) { |
| 156 uma_container_->UpdateHistograms(); |
| 157 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); |
| 158 content_type_ = content_type; |
| 159 } |
| 160 } |
| 161 |
131 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { | 162 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { |
132 rtc::CritScope lock(&crit_); | 163 rtc::CritScope lock(&crit_); |
133 stats_.encode_frame_rate = framerate; | 164 stats_.encode_frame_rate = framerate; |
134 stats_.media_bitrate_bps = bitrate; | 165 stats_.media_bitrate_bps = bitrate; |
135 } | 166 } |
136 | 167 |
137 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 168 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
138 const CpuOveruseMetrics& metrics) { | 169 const CpuOveruseMetrics& metrics) { |
139 rtc::CritScope lock(&crit_); | 170 rtc::CritScope lock(&crit_); |
140 // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. | 171 // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. |
141 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; | 172 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; |
142 stats_.encode_usage_percent = metrics.encode_usage_percent; | 173 stats_.encode_usage_percent = metrics.encode_usage_percent; |
143 } | 174 } |
144 | 175 |
145 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { | 176 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { |
146 rtc::CritScope lock(&crit_); | 177 rtc::CritScope lock(&crit_); |
147 stats_.suspended = is_suspended; | 178 stats_.suspended = is_suspended; |
148 } | 179 } |
149 | 180 |
150 VideoSendStream::Stats SendStatisticsProxy::GetStats() { | 181 VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
151 rtc::CritScope lock(&crit_); | 182 rtc::CritScope lock(&crit_); |
152 PurgeOldStats(); | 183 PurgeOldStats(); |
153 stats_.input_frame_rate = | 184 stats_.input_frame_rate = |
154 round(input_frame_rate_tracker_.ComputeRate()); | 185 round(uma_container_->input_frame_rate_tracker_.ComputeRate()); |
155 return stats_; | 186 return stats_; |
156 } | 187 } |
157 | 188 |
158 void SendStatisticsProxy::PurgeOldStats() { | 189 void SendStatisticsProxy::PurgeOldStats() { |
159 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs; | 190 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs; |
160 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = | 191 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = |
161 stats_.substreams.begin(); | 192 stats_.substreams.begin(); |
162 it != stats_.substreams.end(); ++it) { | 193 it != stats_.substreams.end(); ++it) { |
163 uint32_t ssrc = it->first; | 194 uint32_t ssrc = it->first; |
164 if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) { | 195 if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 248 |
218 rtc::CritScope lock(&crit_); | 249 rtc::CritScope lock(&crit_); |
219 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 250 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
220 if (stats == nullptr) | 251 if (stats == nullptr) |
221 return; | 252 return; |
222 | 253 |
223 stats->width = encoded_image._encodedWidth; | 254 stats->width = encoded_image._encodedWidth; |
224 stats->height = encoded_image._encodedHeight; | 255 stats->height = encoded_image._encodedHeight; |
225 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 256 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
226 | 257 |
227 key_frame_counter_.Add(encoded_image._frameType == kVideoFrameKey); | 258 uma_container_->key_frame_counter_.Add(encoded_image._frameType == |
| 259 kVideoFrameKey); |
228 | 260 |
229 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { | 261 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { |
230 bool downscaled = | 262 bool downscaled = |
231 encoded_image.adapt_reason_.quality_resolution_downscales > 0; | 263 encoded_image.adapt_reason_.quality_resolution_downscales > 0; |
232 quality_limited_frame_counter_.Add(downscaled); | 264 uma_container_->quality_limited_frame_counter_.Add(downscaled); |
233 if (downscaled) { | 265 if (downscaled) { |
234 quality_downscales_counter_.Add( | 266 uma_container_->quality_downscales_counter_.Add( |
235 encoded_image.adapt_reason_.quality_resolution_downscales); | 267 encoded_image.adapt_reason_.quality_resolution_downscales); |
236 } | 268 } |
237 } | 269 } |
238 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 270 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
239 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 271 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
240 bw_limited_frame_counter_.Add(bw_limited); | 272 uma_container_->bw_limited_frame_counter_.Add(bw_limited); |
241 if (bw_limited) { | 273 if (bw_limited) { |
242 bw_resolutions_disabled_counter_.Add( | 274 uma_container_->bw_resolutions_disabled_counter_.Add( |
243 encoded_image.adapt_reason_.bw_resolutions_disabled); | 275 encoded_image.adapt_reason_.bw_resolutions_disabled); |
244 } | 276 } |
245 } | 277 } |
246 | 278 |
247 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 279 // TODO(asapersson): This is incorrect if simulcast layers are encoded on |
248 // different threads and there is no guarantee that one frame of all layers | 280 // different threads and there is no guarantee that one frame of all layers |
249 // are encoded before the next start. | 281 // are encoded before the next start. |
250 if (last_sent_frame_timestamp_ > 0 && | 282 if (last_sent_frame_timestamp_ > 0 && |
251 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 283 encoded_image._timeStamp != last_sent_frame_timestamp_) { |
252 sent_frame_rate_tracker_.AddSamples(1); | 284 uma_container_->sent_frame_rate_tracker_.AddSamples(1); |
253 sent_width_counter_.Add(max_sent_width_per_timestamp_); | 285 uma_container_->sent_width_counter_.Add( |
254 sent_height_counter_.Add(max_sent_height_per_timestamp_); | 286 uma_container_->max_sent_width_per_timestamp_); |
255 max_sent_width_per_timestamp_ = 0; | 287 uma_container_->sent_height_counter_.Add( |
256 max_sent_height_per_timestamp_ = 0; | 288 uma_container_->max_sent_height_per_timestamp_); |
| 289 uma_container_->max_sent_width_per_timestamp_ = 0; |
| 290 uma_container_->max_sent_height_per_timestamp_ = 0; |
257 } | 291 } |
258 last_sent_frame_timestamp_ = encoded_image._timeStamp; | 292 last_sent_frame_timestamp_ = encoded_image._timeStamp; |
259 max_sent_width_per_timestamp_ = | 293 uma_container_->max_sent_width_per_timestamp_ = |
260 std::max(max_sent_width_per_timestamp_, | 294 std::max(uma_container_->max_sent_width_per_timestamp_, |
261 static_cast<int>(encoded_image._encodedWidth)); | 295 static_cast<int>(encoded_image._encodedWidth)); |
262 max_sent_height_per_timestamp_ = | 296 uma_container_->max_sent_height_per_timestamp_ = |
263 std::max(max_sent_height_per_timestamp_, | 297 std::max(uma_container_->max_sent_height_per_timestamp_, |
264 static_cast<int>(encoded_image._encodedHeight)); | 298 static_cast<int>(encoded_image._encodedHeight)); |
265 } | 299 } |
266 | 300 |
267 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { | 301 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
268 rtc::CritScope lock(&crit_); | 302 rtc::CritScope lock(&crit_); |
269 input_frame_rate_tracker_.AddSamples(1); | 303 uma_container_->input_frame_rate_tracker_.AddSamples(1); |
270 input_width_counter_.Add(width); | 304 uma_container_->input_width_counter_.Add(width); |
271 input_height_counter_.Add(height); | 305 uma_container_->input_height_counter_.Add(height); |
272 } | 306 } |
273 | 307 |
274 void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { | 308 void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { |
275 rtc::CritScope lock(&crit_); | 309 rtc::CritScope lock(&crit_); |
276 encode_time_counter_.Add(encode_time_ms); | 310 uma_container_->encode_time_counter_.Add(encode_time_ms); |
277 } | 311 } |
278 | 312 |
279 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 313 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
280 uint32_t ssrc, | 314 uint32_t ssrc, |
281 const RtcpPacketTypeCounter& packet_counter) { | 315 const RtcpPacketTypeCounter& packet_counter) { |
282 rtc::CritScope lock(&crit_); | 316 rtc::CritScope lock(&crit_); |
283 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 317 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
284 if (stats == nullptr) | 318 if (stats == nullptr) |
285 return; | 319 return; |
286 | 320 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, | 370 void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, |
337 int max_delay_ms, | 371 int max_delay_ms, |
338 uint32_t ssrc) { | 372 uint32_t ssrc) { |
339 rtc::CritScope lock(&crit_); | 373 rtc::CritScope lock(&crit_); |
340 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 374 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
341 if (stats == nullptr) | 375 if (stats == nullptr) |
342 return; | 376 return; |
343 stats->avg_delay_ms = avg_delay_ms; | 377 stats->avg_delay_ms = avg_delay_ms; |
344 stats->max_delay_ms = max_delay_ms; | 378 stats->max_delay_ms = max_delay_ms; |
345 | 379 |
346 delay_counter_.Add(avg_delay_ms); | 380 uma_container_->delay_counter_.Add(avg_delay_ms); |
347 max_delay_counter_.Add(max_delay_ms); | 381 uma_container_->max_delay_counter_.Add(max_delay_ms); |
348 } | 382 } |
349 | 383 |
350 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 384 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
351 sum += sample; | 385 sum += sample; |
352 ++num_samples; | 386 ++num_samples; |
353 } | 387 } |
354 | 388 |
355 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 389 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
356 if (num_samples < min_required_samples || num_samples == 0) | 390 if (num_samples < min_required_samples || num_samples == 0) |
357 return -1; | 391 return -1; |
(...skipping 15 matching lines...) Expand all Loading... |
373 int min_required_samples) const { | 407 int min_required_samples) const { |
374 return Fraction(min_required_samples, 1000.0f); | 408 return Fraction(min_required_samples, 1000.0f); |
375 } | 409 } |
376 | 410 |
377 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 411 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
378 int min_required_samples, float multiplier) const { | 412 int min_required_samples, float multiplier) const { |
379 if (num_samples < min_required_samples || num_samples == 0) | 413 if (num_samples < min_required_samples || num_samples == 0) |
380 return -1; | 414 return -1; |
381 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 415 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
382 } | 416 } |
383 | |
384 } // namespace webrtc | 417 } // namespace webrtc |
OLD | NEW |