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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 74 quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
75 if (quality_limited != -1) { | 75 if (quality_limited != -1) { |
76 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", | 76 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", |
77 quality_limited); | 77 quality_limited); |
78 } | 78 } |
79 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 79 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
80 if (downscales != -1) { | 80 if (downscales != -1) { |
81 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", | 81 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", |
82 downscales, 20); | 82 downscales, 20); |
83 } | 83 } |
| 84 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
| 85 if (bw_limited != -1) { |
| 86 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", |
| 87 bw_limited); |
| 88 } |
| 89 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
| 90 if (num_disabled != -1) { |
| 91 RTC_HISTOGRAM_ENUMERATION( |
| 92 "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); |
| 93 } |
84 } | 94 } |
85 | 95 |
86 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { | 96 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { |
87 rtc::CritScope lock(&crit_); | 97 rtc::CritScope lock(&crit_); |
88 stats_.encode_frame_rate = framerate; | 98 stats_.encode_frame_rate = framerate; |
89 stats_.media_bitrate_bps = bitrate; | 99 stats_.media_bitrate_bps = bitrate; |
90 } | 100 } |
91 | 101 |
92 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 102 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
93 const CpuOveruseMetrics& metrics) { | 103 const CpuOveruseMetrics& metrics) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 193 |
184 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { | 194 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { |
185 bool downscaled = | 195 bool downscaled = |
186 encoded_image.adapt_reason_.quality_resolution_downscales > 0; | 196 encoded_image.adapt_reason_.quality_resolution_downscales > 0; |
187 quality_limited_frame_counter_.Add(downscaled); | 197 quality_limited_frame_counter_.Add(downscaled); |
188 if (downscaled) { | 198 if (downscaled) { |
189 quality_downscales_counter_.Add( | 199 quality_downscales_counter_.Add( |
190 encoded_image.adapt_reason_.quality_resolution_downscales); | 200 encoded_image.adapt_reason_.quality_resolution_downscales); |
191 } | 201 } |
192 } | 202 } |
| 203 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
| 204 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
| 205 bw_limited_frame_counter_.Add(bw_limited); |
| 206 if (bw_limited) { |
| 207 bw_resolutions_disabled_counter_.Add( |
| 208 encoded_image.adapt_reason_.bw_resolutions_disabled); |
| 209 } |
| 210 } |
193 | 211 |
194 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 212 // TODO(asapersson): This is incorrect if simulcast layers are encoded on |
195 // different threads and there is no guarantee that one frame of all layers | 213 // different threads and there is no guarantee that one frame of all layers |
196 // are encoded before the next start. | 214 // are encoded before the next start. |
197 if (last_sent_frame_timestamp_ > 0 && | 215 if (last_sent_frame_timestamp_ > 0 && |
198 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 216 encoded_image._timeStamp != last_sent_frame_timestamp_) { |
199 sent_frame_rate_tracker_.AddSamples(1); | 217 sent_frame_rate_tracker_.AddSamples(1); |
200 sent_width_counter_.Add(max_sent_width_per_timestamp_); | 218 sent_width_counter_.Add(max_sent_width_per_timestamp_); |
201 sent_height_counter_.Add(max_sent_height_per_timestamp_); | 219 sent_height_counter_.Add(max_sent_height_per_timestamp_); |
202 max_sent_width_per_timestamp_ = 0; | 220 max_sent_width_per_timestamp_ = 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 310 } |
293 | 311 |
294 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 312 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
295 sum += sample; | 313 sum += sample; |
296 ++num_samples; | 314 ++num_samples; |
297 } | 315 } |
298 | 316 |
299 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 317 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
300 if (num_samples < min_required_samples || num_samples == 0) | 318 if (num_samples < min_required_samples || num_samples == 0) |
301 return -1; | 319 return -1; |
302 return sum / num_samples; | 320 return (sum + (num_samples / 2)) / num_samples; |
303 } | 321 } |
304 | 322 |
305 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { | 323 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { |
306 if (sample) | 324 if (sample) |
307 ++sum; | 325 ++sum; |
308 ++num_samples; | 326 ++num_samples; |
309 } | 327 } |
310 | 328 |
311 int SendStatisticsProxy::BoolSampleCounter::Percent( | 329 int SendStatisticsProxy::BoolSampleCounter::Percent( |
312 int min_required_samples) const { | 330 int min_required_samples) const { |
313 return Fraction(min_required_samples, 100.0f); | 331 return Fraction(min_required_samples, 100.0f); |
314 } | 332 } |
315 | 333 |
316 int SendStatisticsProxy::BoolSampleCounter::Permille( | 334 int SendStatisticsProxy::BoolSampleCounter::Permille( |
317 int min_required_samples) const { | 335 int min_required_samples) const { |
318 return Fraction(min_required_samples, 1000.0f); | 336 return Fraction(min_required_samples, 1000.0f); |
319 } | 337 } |
320 | 338 |
321 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 339 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
322 int min_required_samples, float multiplier) const { | 340 int min_required_samples, float multiplier) const { |
323 if (num_samples < min_required_samples || num_samples == 0) | 341 if (num_samples < min_required_samples || num_samples == 0) |
324 return -1; | 342 return -1; |
325 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 343 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
326 } | 344 } |
327 | 345 |
328 } // namespace webrtc | 346 } // namespace webrtc |
OLD | NEW |