| 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(const VideoEncoderConfig& config) { |
| 35 switch (config.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), |
| 74 uma_prefix_(GetUmaPrefix(encoder_config)), |
| 60 input_frame_rate_tracker_(100u, 10u), | 75 input_frame_rate_tracker_(100u, 10u), |
| 61 sent_frame_rate_tracker_(100u, 10u), | 76 sent_frame_rate_tracker_(100u, 10u), |
| 62 last_sent_frame_timestamp_(0), | 77 last_sent_frame_timestamp_(0), |
| 63 max_sent_width_per_timestamp_(0), | 78 max_sent_width_per_timestamp_(0), |
| 64 max_sent_height_per_timestamp_(0) { | 79 max_sent_height_per_timestamp_(0) { |
| 65 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | 80 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); |
| 66 } | 81 } |
| 67 | 82 |
| 68 SendStatisticsProxy::~SendStatisticsProxy() { | 83 SendStatisticsProxy::~SendStatisticsProxy() { |
| 69 UpdateHistograms(); | 84 UpdateHistograms(); |
| 70 } | 85 } |
| 71 | 86 |
| 72 void SendStatisticsProxy::UpdateHistograms() { | 87 void SendStatisticsProxy::UpdateHistograms() { |
| 73 const int kMinRequiredSamples = 200; | 88 const int kMinRequiredSamples = 200; |
| 74 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 89 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
| 75 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 90 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
| 76 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | 91 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); |
| 77 if (in_width != -1) { | 92 if (in_width != -1) { |
| 78 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); | 93 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputWidthInPixels", in_width); |
| 79 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); | 94 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputHeightInPixels", in_height); |
| 80 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", in_fps); | 95 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "InputFramesPerSecond", in_fps); |
| 81 } | 96 } |
| 82 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 97 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
| 83 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 98 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
| 84 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); | 99 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); |
| 85 if (sent_width != -1) { | 100 if (sent_width != -1) { |
| 86 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); | 101 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentWidthInPixels", sent_width); |
| 87 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); | 102 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentHeightInPixels", sent_height); |
| 88 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); | 103 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "SentFramesPerSecond", sent_fps); |
| 89 } | 104 } |
| 90 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 105 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
| 91 if (encode_ms != -1) | 106 if (encode_ms != -1) |
| 92 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); | 107 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "EncodeTimeInMs", encode_ms); |
| 93 | 108 |
| 94 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); | 109 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
| 95 if (key_frames_permille != -1) { | 110 if (key_frames_permille != -1) { |
| 96 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", | 111 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "KeyFramesSentInPermille", |
| 97 key_frames_permille); | 112 key_frames_permille); |
| 98 } | 113 } |
| 99 int quality_limited = | 114 int quality_limited = |
| 100 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 115 quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
| 101 if (quality_limited != -1) { | 116 if (quality_limited != -1) { |
| 102 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", | 117 RTC_HISTOGRAM_PERCENTAGE(uma_prefix_ + "QualityLimitedResolutionInPercent", |
| 103 quality_limited); | 118 quality_limited); |
| 104 } | 119 } |
| 105 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 120 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
| 106 if (downscales != -1) { | 121 if (downscales != -1) { |
| 107 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", | 122 RTC_HISTOGRAM_ENUMERATION( |
| 108 downscales, 20); | 123 uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 20); |
| 109 } | 124 } |
| 110 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); | 125 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
| 111 if (bw_limited != -1) { | 126 if (bw_limited != -1) { |
| 112 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", | 127 RTC_HISTOGRAM_PERCENTAGE( |
| 113 bw_limited); | 128 uma_prefix_ + "BandwidthLimitedResolutionInPercent", bw_limited); |
| 114 } | 129 } |
| 115 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); | 130 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
| 116 if (num_disabled != -1) { | 131 if (num_disabled != -1) { |
| 117 RTC_HISTOGRAM_ENUMERATION( | 132 RTC_HISTOGRAM_ENUMERATION( |
| 118 "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); | 133 uma_prefix_ + "BandwidthLimitedResolutionsDisabled", num_disabled, 10); |
| 119 } | 134 } |
| 120 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 135 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
| 121 if (delay_ms != -1) | 136 if (delay_ms != -1) |
| 122 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.SendSideDelayInMs", delay_ms); | 137 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayInMs", delay_ms); |
| 123 | 138 |
| 124 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 139 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
| 125 if (max_delay_ms != -1) { | 140 if (max_delay_ms != -1) { |
| 126 RTC_HISTOGRAM_COUNTS_100000( | 141 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayMaxInMs", |
| 127 "WebRTC.Video.SendSideDelayMaxInMs", max_delay_ms); | 142 max_delay_ms); |
| 128 } | 143 } |
| 129 } | 144 } |
| 130 | 145 |
| 131 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { | 146 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { |
| 132 rtc::CritScope lock(&crit_); | 147 rtc::CritScope lock(&crit_); |
| 133 stats_.encode_frame_rate = framerate; | 148 stats_.encode_frame_rate = framerate; |
| 134 stats_.media_bitrate_bps = bitrate; | 149 stats_.media_bitrate_bps = bitrate; |
| 135 } | 150 } |
| 136 | 151 |
| 137 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 152 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (downscaled) { | 248 if (downscaled) { |
| 234 quality_downscales_counter_.Add( | 249 quality_downscales_counter_.Add( |
| 235 encoded_image.adapt_reason_.quality_resolution_downscales); | 250 encoded_image.adapt_reason_.quality_resolution_downscales); |
| 236 } | 251 } |
| 237 } | 252 } |
| 238 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 253 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
| 239 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 254 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
| 240 bw_limited_frame_counter_.Add(bw_limited); | 255 bw_limited_frame_counter_.Add(bw_limited); |
| 241 if (bw_limited) { | 256 if (bw_limited) { |
| 242 bw_resolutions_disabled_counter_.Add( | 257 bw_resolutions_disabled_counter_.Add( |
| 243 encoded_image.adapt_reason_.bw_resolutions_disabled); | 258 encoded_image.adapt_reason_.bw_resolutions_disabled); |
| 244 } | 259 } |
| 245 } | 260 } |
| 246 | 261 |
| 247 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 262 // 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 | 263 // different threads and there is no guarantee that one frame of all layers |
| 249 // are encoded before the next start. | 264 // are encoded before the next start. |
| 250 if (last_sent_frame_timestamp_ > 0 && | 265 if (last_sent_frame_timestamp_ > 0 && |
| 251 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 266 encoded_image._timeStamp != last_sent_frame_timestamp_) { |
| 252 sent_frame_rate_tracker_.AddSamples(1); | 267 sent_frame_rate_tracker_.AddSamples(1); |
| 253 sent_width_counter_.Add(max_sent_width_per_timestamp_); | 268 sent_width_counter_.Add(max_sent_width_per_timestamp_); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 int min_required_samples) const { | 388 int min_required_samples) const { |
| 374 return Fraction(min_required_samples, 1000.0f); | 389 return Fraction(min_required_samples, 1000.0f); |
| 375 } | 390 } |
| 376 | 391 |
| 377 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 392 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 378 int min_required_samples, float multiplier) const { | 393 int min_required_samples, float multiplier) const { |
| 379 if (num_samples < min_required_samples || num_samples == 0) | 394 if (num_samples < min_required_samples || num_samples == 0) |
| 380 return -1; | 395 return -1; |
| 381 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 396 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 382 } | 397 } |
| 383 | |
| 384 } // namespace webrtc | 398 } // namespace webrtc |
| OLD | NEW |