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