Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: webrtc/video/send_statistics_proxy.cc

Issue 2304363002: Let ViEEncoder express resolution requests as Sinkwants (Closed)
Patch Set: Rebased. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(kMinRequiredMetricsSamples);
136 int in_width = input_width_counter_.Avg(kMinRequiredSamples); 136 int in_height = input_height_counter_.Avg(kMinRequiredMetricsSamples);
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(kMinRequiredMetricsSamples);
148 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); 147 int sent_height = sent_height_counter_.Avg(kMinRequiredMetricsSamples);
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(kMinRequiredMetricsSamples);
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 =
163 key_frame_counter_.Permille(kMinRequiredMetricsSamples);
164 if (key_frames_permille != -1) { 164 if (key_frames_permille != -1) {
165 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "KeyFramesSentInPermille", 165 RTC_HISTOGRAMS_COUNTS_1000(kIndex, uma_prefix_ + "KeyFramesSentInPermille",
166 key_frames_permille); 166 key_frames_permille);
167 } 167 }
168 int quality_limited = 168 int quality_limited =
169 quality_limited_frame_counter_.Percent(kMinRequiredSamples); 169 quality_limited_frame_counter_.Percent(kMinRequiredMetricsSamples);
170 if (quality_limited != -1) { 170 if (quality_limited != -1) {
171 RTC_HISTOGRAMS_PERCENTAGE(kIndex, 171 RTC_HISTOGRAMS_PERCENTAGE(kIndex,
172 uma_prefix_ + "QualityLimitedResolutionInPercent", 172 uma_prefix_ + "QualityLimitedResolutionInPercent",
173 quality_limited); 173 quality_limited);
174 } 174 }
175 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); 175 int downscales = quality_downscales_counter_.Avg(kMinRequiredMetricsSamples);
176 if (downscales != -1) { 176 if (downscales != -1) {
177 RTC_HISTOGRAMS_ENUMERATION( 177 RTC_HISTOGRAMS_ENUMERATION(
178 kIndex, uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 178 kIndex, uma_prefix_ + "QualityLimitedResolutionDownscales", downscales,
179 20); 179 20);
180 } 180 }
181 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); 181 int cpu_limited =
182 cpu_limited_frame_counter_.Percent(kMinRequiredMetricsSamples);
183 if (cpu_limited != -1) {
184 RTC_HISTOGRAMS_PERCENTAGE(
185 kIndex, uma_prefix_ + "CpuLimitedResolutionInPercent", cpu_limited);
186 }
187 int bw_limited =
188 bw_limited_frame_counter_.Percent(kMinRequiredMetricsSamples);
182 if (bw_limited != -1) { 189 if (bw_limited != -1) {
183 RTC_HISTOGRAMS_PERCENTAGE( 190 RTC_HISTOGRAMS_PERCENTAGE(
184 kIndex, uma_prefix_ + "BandwidthLimitedResolutionInPercent", 191 kIndex, uma_prefix_ + "BandwidthLimitedResolutionInPercent",
185 bw_limited); 192 bw_limited);
186 } 193 }
187 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); 194 int num_disabled =
195 bw_resolutions_disabled_counter_.Avg(kMinRequiredMetricsSamples);
188 if (num_disabled != -1) { 196 if (num_disabled != -1) {
189 RTC_HISTOGRAMS_ENUMERATION( 197 RTC_HISTOGRAMS_ENUMERATION(
190 kIndex, uma_prefix_ + "BandwidthLimitedResolutionsDisabled", 198 kIndex, uma_prefix_ + "BandwidthLimitedResolutionsDisabled",
191 num_disabled, 10); 199 num_disabled, 10);
192 } 200 }
193 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); 201 int delay_ms = delay_counter_.Avg(kMinRequiredMetricsSamples);
194 if (delay_ms != -1) 202 if (delay_ms != -1)
195 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", 203 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs",
196 delay_ms); 204 delay_ms);
197 205
198 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); 206 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredMetricsSamples);
199 if (max_delay_ms != -1) { 207 if (max_delay_ms != -1) {
200 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", 208 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs",
201 max_delay_ms); 209 max_delay_ms);
202 } 210 }
203 211
204 for (const auto& it : qp_counters_) { 212 for (const auto& it : qp_counters_) {
205 int qp_vp8 = it.second.vp8.Avg(kMinRequiredSamples); 213 int qp_vp8 = it.second.vp8.Avg(kMinRequiredMetricsSamples);
206 if (qp_vp8 != -1) { 214 if (qp_vp8 != -1) {
207 int spatial_idx = it.first; 215 int spatial_idx = it.first;
208 if (spatial_idx == -1) { 216 if (spatial_idx == -1) {
209 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8", 217 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8",
210 qp_vp8); 218 qp_vp8);
211 } else if (spatial_idx == 0) { 219 } else if (spatial_idx == 0) {
212 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0", 220 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0",
213 qp_vp8); 221 qp_vp8);
214 } else if (spatial_idx == 1) { 222 } else if (spatial_idx == 1) {
215 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1", 223 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1",
216 qp_vp8); 224 qp_vp8);
217 } else if (spatial_idx == 2) { 225 } else if (spatial_idx == 2) {
218 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2", 226 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2",
219 qp_vp8); 227 qp_vp8);
220 } else { 228 } else {
221 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx " 229 LOG(LS_WARNING) << "QP stats not recorded for VP8 spatial idx "
222 << spatial_idx; 230 << spatial_idx;
223 } 231 }
224 } 232 }
225 int qp_vp9 = it.second.vp9.Avg(kMinRequiredSamples); 233 int qp_vp9 = it.second.vp9.Avg(kMinRequiredMetricsSamples);
226 if (qp_vp9 != -1) { 234 if (qp_vp9 != -1) {
227 int spatial_idx = it.first; 235 int spatial_idx = it.first;
228 if (spatial_idx == -1) { 236 if (spatial_idx == -1) {
229 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9", 237 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9",
230 qp_vp9); 238 qp_vp9);
231 } else if (spatial_idx == 0) { 239 } else if (spatial_idx == 0) {
232 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S0", 240 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S0",
233 qp_vp9); 241 qp_vp9);
234 } else if (spatial_idx == 1) { 242 } else if (spatial_idx == 1) {
235 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S1", 243 RTC_HISTOGRAMS_COUNTS_500(kIndex, uma_prefix_ + "Encoded.Qp.Vp9.S1",
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 int SendStatisticsProxy::GetSendFrameRate() const { 549 int SendStatisticsProxy::GetSendFrameRate() const {
542 rtc::CritScope lock(&crit_); 550 rtc::CritScope lock(&crit_);
543 return stats_.encode_frame_rate; 551 return stats_.encode_frame_rate;
544 } 552 }
545 553
546 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { 554 void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
547 rtc::CritScope lock(&crit_); 555 rtc::CritScope lock(&crit_);
548 uma_container_->input_frame_rate_tracker_.AddSamples(1); 556 uma_container_->input_frame_rate_tracker_.AddSamples(1);
549 uma_container_->input_width_counter_.Add(width); 557 uma_container_->input_width_counter_.Add(width);
550 uma_container_->input_height_counter_.Add(height); 558 uma_container_->input_height_counter_.Add(height);
559 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution);
560 }
561
562 void SendStatisticsProxy::SetCpuRestrictedResolution(
563 bool cpu_restricted_resolution) {
564 rtc::CritScope lock(&crit_);
565 stats_.cpu_limited_resolution = cpu_restricted_resolution;
566 }
567
568 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged(
569 bool cpu_restricted_resolution) {
570 rtc::CritScope lock(&crit_);
571 stats_.cpu_limited_resolution = cpu_restricted_resolution;
572 ++stats_.number_of_cpu_adapt_changes;
551 } 573 }
552 574
553 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( 575 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated(
554 uint32_t ssrc, 576 uint32_t ssrc,
555 const RtcpPacketTypeCounter& packet_counter) { 577 const RtcpPacketTypeCounter& packet_counter) {
556 rtc::CritScope lock(&crit_); 578 rtc::CritScope lock(&crit_);
557 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 579 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
558 if (!stats) 580 if (!stats)
559 return; 581 return;
560 582
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 return Fraction(min_required_samples, 1000.0f); 674 return Fraction(min_required_samples, 1000.0f);
653 } 675 }
654 676
655 int SendStatisticsProxy::BoolSampleCounter::Fraction( 677 int SendStatisticsProxy::BoolSampleCounter::Fraction(
656 int min_required_samples, float multiplier) const { 678 int min_required_samples, float multiplier) const {
657 if (num_samples < min_required_samples || num_samples == 0) 679 if (num_samples < min_required_samples || num_samples == 0)
658 return -1; 680 return -1;
659 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); 681 return static_cast<int>((sum * multiplier / num_samples) + 0.5f);
660 } 682 }
661 } // namespace webrtc 683 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698