| 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 | 24 |
| 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* kRealtimePrefix = "WebRTC.Video."; |
| 35 const char* kScreenPrefix = "WebRTC.Video.Screenshare."; |
| 36 |
| 34 const char* GetUmaPrefix(VideoEncoderConfig::ContentType content_type) { | 37 const char* GetUmaPrefix(VideoEncoderConfig::ContentType content_type) { |
| 35 switch (content_type) { | 38 switch (content_type) { |
| 36 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 39 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
| 37 return "WebRTC.Video."; | 40 return kRealtimePrefix; |
| 38 case VideoEncoderConfig::ContentType::kScreen: | 41 case VideoEncoderConfig::ContentType::kScreen: |
| 39 return "WebRTC.Video.Screenshare."; | 42 return kScreenPrefix; |
| 40 } | 43 } |
| 41 RTC_NOTREACHED(); | 44 RTC_NOTREACHED(); |
| 42 return nullptr; | 45 return nullptr; |
| 43 } | 46 } |
| 44 | 47 |
| 45 HistogramCodecType PayloadNameToHistogramCodecType( | 48 HistogramCodecType PayloadNameToHistogramCodecType( |
| 46 const std::string& payload_name) { | 49 const std::string& payload_name) { |
| 47 if (payload_name == "VP8") { | 50 if (payload_name == "VP8") { |
| 48 return kVideoVp8; | 51 return kVideoVp8; |
| 49 } else if (payload_name == "VP9") { | 52 } else if (payload_name == "VP9") { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 max_sent_width_per_timestamp_(0), | 89 max_sent_width_per_timestamp_(0), |
| 87 max_sent_height_per_timestamp_(0), | 90 max_sent_height_per_timestamp_(0), |
| 88 input_frame_rate_tracker_(100u, 10u), | 91 input_frame_rate_tracker_(100u, 10u), |
| 89 sent_frame_rate_tracker_(100u, 10u) {} | 92 sent_frame_rate_tracker_(100u, 10u) {} |
| 90 | 93 |
| 91 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { | 94 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { |
| 92 UpdateHistograms(); | 95 UpdateHistograms(); |
| 93 } | 96 } |
| 94 | 97 |
| 95 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { | 98 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { |
| 99 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); |
| 100 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; |
| 96 const int kMinRequiredSamples = 200; | 101 const int kMinRequiredSamples = 200; |
| 97 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 102 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
| 98 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 103 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
| 99 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | 104 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); |
| 100 if (in_width != -1) { | 105 if (in_width != -1) { |
| 101 RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "InputWidthInPixels", | 106 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputWidthInPixels", |
| 102 in_width); | 107 in_width); |
| 103 RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "InputHeightInPixels", | 108 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputHeightInPixels", |
| 104 in_height); | 109 in_height); |
| 105 RTC_HISTOGRAM_COUNTS_SPARSE_100(uma_prefix_ + "InputFramesPerSecond", | 110 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "InputFramesPerSecond", |
| 106 in_fps); | 111 in_fps); |
| 107 } | 112 } |
| 108 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 113 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
| 109 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 114 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
| 110 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); | 115 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); |
| 111 if (sent_width != -1) { | 116 if (sent_width != -1) { |
| 112 RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "SentWidthInPixels", | 117 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentWidthInPixels", |
| 113 sent_width); | 118 sent_width); |
| 114 RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "SentHeightInPixels", | 119 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentHeightInPixels", |
| 115 sent_height); | 120 sent_height); |
| 116 RTC_HISTOGRAM_COUNTS_SPARSE_100(uma_prefix_ + "SentFramesPerSecond", | 121 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "SentFramesPerSecond", |
| 117 sent_fps); | 122 sent_fps); |
| 118 } | 123 } |
| 119 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 124 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
| 120 if (encode_ms != -1) | 125 if (encode_ms != -1) { |
| 121 RTC_HISTOGRAM_COUNTS_SPARSE_1000(uma_prefix_ + "EncodeTimeInMs", encode_ms); | 126 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "EncodeTimeInMs", |
| 122 | 127 encode_ms); |
| 128 } |
| 123 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); | 129 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
| 124 if (key_frames_permille != -1) { | 130 if (key_frames_permille != -1) { |
| 125 RTC_HISTOGRAM_COUNTS_SPARSE_1000(uma_prefix_ + "KeyFramesSentInPermille", | 131 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "KeyFramesSentInPermille", |
| 126 key_frames_permille); | 132 key_frames_permille); |
| 127 } | 133 } |
| 128 int quality_limited = | 134 int quality_limited = |
| 129 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 135 quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
| 130 if (quality_limited != -1) { | 136 if (quality_limited != -1) { |
| 131 RTC_HISTOGRAM_PERCENTAGE_SPARSE( | 137 RTC_HISTOGRAMS_PERCENTAGE(kIndex, |
| 132 uma_prefix_ + "QualityLimitedResolutionInPercent", quality_limited); | 138 uma_prefix_ + "QualityLimitedResolutionInPercent", |
| 139 quality_limited); |
| 133 } | 140 } |
| 134 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 141 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
| 135 if (downscales != -1) { | 142 if (downscales != -1) { |
| 136 RTC_HISTOGRAM_ENUMERATION_SPARSE( | 143 RTC_HISTOGRAMS_ENUMERATION( |
| 137 uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 20); | 144 kIndex, uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, |
| 145 20); |
| 138 } | 146 } |
| 139 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); | 147 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
| 140 if (bw_limited != -1) { | 148 if (bw_limited != -1) { |
| 141 RTC_HISTOGRAM_PERCENTAGE_SPARSE( | 149 RTC_HISTOGRAMS_PERCENTAGE( |
| 142 uma_prefix_ + "BandwidthLimitedResolutionInPercent", bw_limited); | 150 kIndex, uma_prefix_ + "BandwidthLimitedResolutionInPercent", |
| 151 bw_limited); |
| 143 } | 152 } |
| 144 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); | 153 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
| 145 if (num_disabled != -1) { | 154 if (num_disabled != -1) { |
| 146 RTC_HISTOGRAM_ENUMERATION_SPARSE( | 155 RTC_HISTOGRAMS_ENUMERATION( |
| 147 uma_prefix_ + "BandwidthLimitedResolutionsDisabled", num_disabled, 10); | 156 kIndex, uma_prefix_ + "BandwidthLimitedResolutionsDisabled", |
| 157 num_disabled, 10); |
| 148 } | 158 } |
| 149 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 159 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
| 150 if (delay_ms != -1) | 160 if (delay_ms != -1) |
| 151 RTC_HISTOGRAM_COUNTS_SPARSE_100000(uma_prefix_ + "SendSideDelayInMs", | 161 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", |
| 152 delay_ms); | 162 delay_ms); |
| 153 | 163 |
| 154 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 164 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
| 155 if (max_delay_ms != -1) { | 165 if (max_delay_ms != -1) { |
| 156 RTC_HISTOGRAM_COUNTS_SPARSE_100000(uma_prefix_ + "SendSideDelayMaxInMs", | 166 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", |
| 157 max_delay_ms); | 167 max_delay_ms); |
| 158 } | 168 } |
| 159 } | 169 } |
| 160 | 170 |
| 161 void SendStatisticsProxy::SetContentType( | 171 void SendStatisticsProxy::SetContentType( |
| 162 VideoEncoderConfig::ContentType content_type) { | 172 VideoEncoderConfig::ContentType content_type) { |
| 163 rtc::CritScope lock(&crit_); | 173 rtc::CritScope lock(&crit_); |
| 164 if (content_type_ != content_type) { | 174 if (content_type_ != content_type) { |
| 165 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); | 175 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); |
| 166 content_type_ = content_type; | 176 content_type_ = content_type; |
| 167 } | 177 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return Fraction(min_required_samples, 1000.0f); | 436 return Fraction(min_required_samples, 1000.0f); |
| 427 } | 437 } |
| 428 | 438 |
| 429 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 439 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 430 int min_required_samples, float multiplier) const { | 440 int min_required_samples, float multiplier) const { |
| 431 if (num_samples < min_required_samples || num_samples == 0) | 441 if (num_samples < min_required_samples || num_samples == 0) |
| 432 return -1; | 442 return -1; |
| 433 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 443 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 434 } | 444 } |
| 435 } // namespace webrtc | 445 } // namespace webrtc |
| OLD | NEW |