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 |
11 #include "webrtc/video/send_statistics_proxy.h" | 11 #include "webrtc/video/send_statistics_proxy.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <cmath> | 14 #include <cmath> |
15 #include <map> | 15 #include <map> |
16 #include <vector> | |
16 | 17 |
17 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
19 #include "webrtc/system_wrappers/include/metrics.h" | 20 #include "webrtc/system_wrappers/include/metrics.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace { | 23 namespace { |
23 const float kEncodeTimeWeigthFactor = 0.5f; | 24 const float kEncodeTimeWeigthFactor = 0.5f; |
24 | 25 |
25 // Used by histograms. Values of entries should not be changed. | 26 // Used by histograms. Values of entries should not be changed. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 if (delay_ms != -1) | 186 if (delay_ms != -1) |
186 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", | 187 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", |
187 delay_ms); | 188 delay_ms); |
188 | 189 |
189 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 190 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
190 if (max_delay_ms != -1) { | 191 if (max_delay_ms != -1) { |
191 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", | 192 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", |
192 max_delay_ms); | 193 max_delay_ms); |
193 } | 194 } |
194 | 195 |
196 for (const auto& it : qp_counters_) { | |
197 int qp = it.second.vp8.Avg(kMinRequiredSamples); | |
198 if (qp != -1) { | |
199 int spatial_idx = it.first; | |
200 if (spatial_idx == -1) { | |
mflodman
2016/03/23 12:25:20
I think it would be nice to rather build a string
pbos-webrtc
2016/03/23 12:34:03
We can't since RTC_HISTOGRAMS_COUNTS requires the
åsapersson
2016/03/23 13:09:26
Right the name should not vary for a macro.
| |
201 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8", qp); | |
202 } else if (spatial_idx == 0) { | |
203 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S0", | |
204 qp); | |
205 } else if (spatial_idx == 1) { | |
206 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S1", | |
207 qp); | |
208 } else if (spatial_idx == 2) { | |
209 RTC_HISTOGRAMS_COUNTS_200(kIndex, uma_prefix_ + "Encoded.Qp.Vp8.S2", | |
210 qp); | |
211 } | |
pbos-webrtc
2016/03/23 12:34:03
Should we have an else case here that should do so
åsapersson
2016/03/23 13:09:26
Added a warning...
| |
212 } | |
213 } | |
214 | |
195 if (first_rtcp_stats_time_ms_ != -1) { | 215 if (first_rtcp_stats_time_ms_ != -1) { |
196 int64_t elapsed_sec = | 216 int64_t elapsed_sec = |
197 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; | 217 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
198 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 218 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
199 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 219 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
200 if (fraction_lost != -1) { | 220 if (fraction_lost != -1) { |
201 RTC_HISTOGRAMS_PERCENTAGE( | 221 RTC_HISTOGRAMS_PERCENTAGE( |
202 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); | 222 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
203 } | 223 } |
204 | 224 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 } | 439 } |
420 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 440 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
421 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 441 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
422 uma_container_->bw_limited_frame_counter_.Add(bw_limited); | 442 uma_container_->bw_limited_frame_counter_.Add(bw_limited); |
423 if (bw_limited) { | 443 if (bw_limited) { |
424 uma_container_->bw_resolutions_disabled_counter_.Add( | 444 uma_container_->bw_resolutions_disabled_counter_.Add( |
425 encoded_image.adapt_reason_.bw_resolutions_disabled); | 445 encoded_image.adapt_reason_.bw_resolutions_disabled); |
426 } | 446 } |
427 } | 447 } |
428 | 448 |
449 if (encoded_image.qp_ != -1 && rtp_video_header != nullptr) { | |
450 if (rtp_video_header->codec == kRtpVideoVp8) { | |
mflodman
2016/03/23 12:25:20
This can be an additional condition in the if abov
pbos-webrtc
2016/03/23 12:34:03
I think so as well, if ssrcs.size() is 1 then we i
åsapersson
2016/03/23 13:09:26
-1 might be used when not using spatial layers for
åsapersson
2016/03/23 13:09:26
Done.
| |
451 int spatial_idx = (config_.rtp.ssrcs.size() == 1) | |
452 ? -1 | |
453 : static_cast<int>(simulcast_idx); | |
454 uma_container_->qp_counters_[spatial_idx].vp8.Add(encoded_image.qp_); | |
455 } | |
456 } | |
457 | |
429 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 458 // TODO(asapersson): This is incorrect if simulcast layers are encoded on |
430 // different threads and there is no guarantee that one frame of all layers | 459 // different threads and there is no guarantee that one frame of all layers |
431 // are encoded before the next start. | 460 // are encoded before the next start. |
432 if (last_sent_frame_timestamp_ > 0 && | 461 if (last_sent_frame_timestamp_ > 0 && |
433 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 462 encoded_image._timeStamp != last_sent_frame_timestamp_) { |
434 uma_container_->sent_frame_rate_tracker_.AddSamples(1); | 463 uma_container_->sent_frame_rate_tracker_.AddSamples(1); |
435 uma_container_->sent_width_counter_.Add( | 464 uma_container_->sent_width_counter_.Add( |
436 uma_container_->max_sent_width_per_timestamp_); | 465 uma_container_->max_sent_width_per_timestamp_); |
437 uma_container_->sent_height_counter_.Add( | 466 uma_container_->sent_height_counter_.Add( |
438 uma_container_->max_sent_height_per_timestamp_); | 467 uma_container_->max_sent_height_per_timestamp_); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 return Fraction(min_required_samples, 1000.0f); | 586 return Fraction(min_required_samples, 1000.0f); |
558 } | 587 } |
559 | 588 |
560 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 589 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
561 int min_required_samples, float multiplier) const { | 590 int min_required_samples, float multiplier) const { |
562 if (num_samples < min_required_samples || num_samples == 0) | 591 if (num_samples < min_required_samples || num_samples == 0) |
563 return -1; | 592 return -1; |
564 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 593 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
565 } | 594 } |
566 } // namespace webrtc | 595 } // namespace webrtc |
OLD | NEW |