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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 total_rtp_stats->Add(it.second.rtp_stats); | 125 total_rtp_stats->Add(it.second.rtp_stats); |
126 } | 126 } |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( | 130 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( |
131 const VideoSendStream::Config::Rtp& rtp_config, | 131 const VideoSendStream::Config::Rtp& rtp_config, |
132 const VideoSendStream::Stats& current_stats) { | 132 const VideoSendStream::Stats& current_stats) { |
133 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); | 133 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); |
134 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; | 134 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; |
135 const int kMinRequiredSamples = 200; | 135 int in_width = input_width_counter_.Avg(kMinRequiredUMASamples); |
136 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 136 int in_height = input_height_counter_.Avg(kMinRequiredUMASamples); |
137 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | |
138 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | 137 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); |
139 if (in_width != -1) { | 138 if (in_width != -1) { |
140 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputWidthInPixels", | 139 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputWidthInPixels", |
141 in_width); | 140 in_width); |
142 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputHeightInPixels", | 141 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputHeightInPixels", |
143 in_height); | 142 in_height); |
144 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "InputFramesPerSecond", | 143 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "InputFramesPerSecond", |
145 in_fps); | 144 in_fps); |
146 } | 145 } |
147 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 146 int sent_width = sent_width_counter_.Avg(kMinRequiredUMASamples); |
148 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 147 int sent_height = sent_height_counter_.Avg(kMinRequiredUMASamples); |
149 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); | 148 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); |
150 if (sent_width != -1) { | 149 if (sent_width != -1) { |
151 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentWidthInPixels", | 150 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentWidthInPixels", |
152 sent_width); | 151 sent_width); |
153 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentHeightInPixels", | 152 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "SentHeightInPixels", |
154 sent_height); | 153 sent_height); |
155 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "SentFramesPerSecond", | 154 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "SentFramesPerSecond", |
156 sent_fps); | 155 sent_fps); |
157 } | 156 } |
158 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 157 int encode_ms = encode_time_counter_.Avg(kMinRequiredUMASamples); |
159 if (encode_ms != -1) { | 158 if (encode_ms != -1) { |
160 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "EncodeTimeInMs", | 159 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "EncodeTimeInMs", |
161 encode_ms); | 160 encode_ms); |
162 } | 161 } |
163 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); | 162 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredUMASamples); |
164 if (key_frames_permille != -1) { | 163 if (key_frames_permille != -1) { |
165 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "KeyFramesSentInPermille", | 164 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "KeyFramesSentInPermille", |
166 key_frames_permille); | 165 key_frames_permille); |
167 } | 166 } |
168 int quality_limited = | 167 int quality_limited = |
169 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 168 quality_limited_frame_counter_.Percent(kMinRequiredUMASamples); |
170 if (quality_limited != -1) { | 169 if (quality_limited != -1) { |
171 RTC_HISTOGRAMS_PERCENTAGE(kIndex, | 170 RTC_HISTOGRAMS_PERCENTAGE(kIndex, |
172 uma_prefix_ + "QualityLimitedResolutionInPercent", | 171 uma_prefix_ + "QualityLimitedResolutionInPercent", |
173 quality_limited); | 172 quality_limited); |
174 } | 173 } |
175 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 174 int downscales = quality_downscales_counter_.Avg(kMinRequiredUMASamples); |
176 if (downscales != -1) { | 175 if (downscales != -1) { |
177 RTC_HISTOGRAMS_ENUMERATION( | 176 RTC_HISTOGRAMS_ENUMERATION( |
178 kIndex, uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, | 177 kIndex, uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, |
179 20); | 178 20); |
180 } | 179 } |
181 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); | 180 int cpu_limited = cpu_limited_frame_counter_.Percent(kMinRequiredUMASamples); |
| 181 if (cpu_limited != -1) { |
| 182 RTC_HISTOGRAMS_PERCENTAGE( |
| 183 kIndex, uma_prefix_ + "CpuLimitedResolutionInPercent", cpu_limited); |
| 184 } |
| 185 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredUMASamples); |
182 if (bw_limited != -1) { | 186 if (bw_limited != -1) { |
183 RTC_HISTOGRAMS_PERCENTAGE( | 187 RTC_HISTOGRAMS_PERCENTAGE( |
184 kIndex, uma_prefix_ + "BandwidthLimitedResolutionInPercent", | 188 kIndex, uma_prefix_ + "BandwidthLimitedResolutionInPercent", |
185 bw_limited); | 189 bw_limited); |
186 } | 190 } |
187 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); | 191 int num_disabled = |
| 192 bw_resolutions_disabled_counter_.Avg(kMinRequiredUMASamples); |
188 if (num_disabled != -1) { | 193 if (num_disabled != -1) { |
189 RTC_HISTOGRAMS_ENUMERATION( | 194 RTC_HISTOGRAMS_ENUMERATION( |
190 kIndex, uma_prefix_ + "BandwidthLimitedResolutionsDisabled", | 195 kIndex, uma_prefix_ + "BandwidthLimitedResolutionsDisabled", |
191 num_disabled, 10); | 196 num_disabled, 10); |
192 } | 197 } |
193 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 198 int delay_ms = delay_counter_.Avg(kMinRequiredUMASamples); |
194 if (delay_ms != -1) | 199 if (delay_ms != -1) |
195 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", | 200 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", |
196 delay_ms); | 201 delay_ms); |
197 | 202 |
198 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 203 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredUMASamples); |
199 if (max_delay_ms != -1) { | 204 if (max_delay_ms != -1) { |
200 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", | 205 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", |
201 max_delay_ms); | 206 max_delay_ms); |
202 } | 207 } |
203 | 208 |
204 for (const auto& it : qp_counters_) { | 209 for (const auto& it : qp_counters_) { |
205 int qp_vp8 = it.second.vp8.Avg(kMinRequiredSamples); | 210 int qp_vp8 = it.second.vp8.Avg(kMinRequiredUMASamples); |
206 if (qp_vp8 != -1) { | 211 if (qp_vp8 != -1) { |
207 int spatial_idx = it.first; | 212 int spatial_idx = it.first; |
208 if (spatial_idx == -1) { | 213 if (spatial_idx == -1) { |
209 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8", | 214 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8", |
210 qp_vp8); | 215 qp_vp8); |
211 } else if (spatial_idx == 0) { | 216 } else if (spatial_idx == 0) { |
212 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0", | 217 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0", |
213 qp_vp8); | 218 qp_vp8); |
214 } else if (spatial_idx == 1) { | 219 } else if (spatial_idx == 1) { |
215 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1", | 220 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1", |
216 qp_vp8); | 221 qp_vp8); |
217 } else if (spatial_idx == 2) { | 222 } else if (spatial_idx == 2) { |
218 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2", | 223 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2", |
219 qp_vp8); | 224 qp_vp8); |
220 } else { | 225 } else { |
221 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx " | 226 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx " |
222 << spatial_idx; | 227 << spatial_idx; |
223 } | 228 } |
224 } | 229 } |
225 int qp_vp9 = it.second.vp9.Avg(kMinRequiredSamples); | 230 int qp_vp9 = it.second.vp9.Avg(kMinRequiredUMASamples); |
226 if (qp_vp9 != -1) { | 231 if (qp_vp9 != -1) { |
227 int spatial_idx = it.first; | 232 int spatial_idx = it.first; |
228 if (spatial_idx == -1) { | 233 if (spatial_idx == -1) { |
229 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9", | 234 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9", |
230 qp_vp9); | 235 qp_vp9); |
231 } else if (spatial_idx == 0) { | 236 } else if (spatial_idx == 0) { |
232 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S0", | 237 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S0", |
233 qp_vp9); | 238 qp_vp9); |
234 } else if (spatial_idx == 1) { | 239 } else if (spatial_idx == 1) { |
235 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S1", | 240 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S1", |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 uma_container_->max_sent_height_per_timestamp_ = | 533 uma_container_->max_sent_height_per_timestamp_ = |
529 std::max(uma_container_->max_sent_height_per_timestamp_, | 534 std::max(uma_container_->max_sent_height_per_timestamp_, |
530 static_cast<int>(encoded_image._encodedHeight)); | 535 static_cast<int>(encoded_image._encodedHeight)); |
531 } | 536 } |
532 | 537 |
533 int SendStatisticsProxy::GetSendFrameRate() const { | 538 int SendStatisticsProxy::GetSendFrameRate() const { |
534 rtc::CritScope lock(&crit_); | 539 rtc::CritScope lock(&crit_); |
535 return stats_.encode_frame_rate; | 540 return stats_.encode_frame_rate; |
536 } | 541 } |
537 | 542 |
538 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { | 543 void SendStatisticsProxy::OnIncomingFrame(int width, |
| 544 int height, |
| 545 bool is_cpu_restricted) { |
539 rtc::CritScope lock(&crit_); | 546 rtc::CritScope lock(&crit_); |
540 uma_container_->input_frame_rate_tracker_.AddSamples(1); | 547 uma_container_->input_frame_rate_tracker_.AddSamples(1); |
541 uma_container_->input_width_counter_.Add(width); | 548 uma_container_->input_width_counter_.Add(width); |
542 uma_container_->input_height_counter_.Add(height); | 549 uma_container_->input_height_counter_.Add(height); |
| 550 uma_container_->cpu_limited_frame_counter_.Add(is_cpu_restricted); |
| 551 } |
| 552 |
| 553 void SendStatisticsProxy::SetCpuRestrictedResolution( |
| 554 bool cpu_restricted_resolution) { |
| 555 rtc::CritScope lock(&crit_); |
| 556 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
| 557 } |
| 558 |
| 559 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
| 560 bool cpu_restricted_resolution) { |
| 561 rtc::CritScope lock(&crit_); |
| 562 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
| 563 ++stats_.number_of_cpu_adapt_changes; |
543 } | 564 } |
544 | 565 |
545 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 566 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
546 uint32_t ssrc, | 567 uint32_t ssrc, |
547 const RtcpPacketTypeCounter& packet_counter) { | 568 const RtcpPacketTypeCounter& packet_counter) { |
548 rtc::CritScope lock(&crit_); | 569 rtc::CritScope lock(&crit_); |
549 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 570 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
550 if (!stats) | 571 if (!stats) |
551 return; | 572 return; |
552 | 573 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 return Fraction(min_required_samples, 1000.0f); | 665 return Fraction(min_required_samples, 1000.0f); |
645 } | 666 } |
646 | 667 |
647 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 668 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
648 int min_required_samples, float multiplier) const { | 669 int min_required_samples, float multiplier) const { |
649 if (num_samples < min_required_samples || num_samples == 0) | 670 if (num_samples < min_required_samples || num_samples == 0) |
650 return -1; | 671 return -1; |
651 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 672 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
652 } | 673 } |
653 } // namespace webrtc | 674 } // namespace webrtc |
OLD | NEW |