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

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

Issue 1734933002: Move RTP stats histograms from VieChannel to SendStatisticsProxy. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Assert diff of RtpPacketCounter is valid Created 4 years, 9 months 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const char* prefix, 91 const char* prefix,
92 const VideoSendStream::Stats& stats, 92 const VideoSendStream::Stats& stats,
93 Clock* const clock) 93 Clock* const clock)
94 : uma_prefix_(prefix), 94 : uma_prefix_(prefix),
95 clock_(clock), 95 clock_(clock),
96 max_sent_width_per_timestamp_(0), 96 max_sent_width_per_timestamp_(0),
97 max_sent_height_per_timestamp_(0), 97 max_sent_height_per_timestamp_(0),
98 input_frame_rate_tracker_(100u, 10u), 98 input_frame_rate_tracker_(100u, 10u),
99 sent_frame_rate_tracker_(100u, 10u), 99 sent_frame_rate_tracker_(100u, 10u),
100 first_rtcp_stats_time_ms_(-1), 100 first_rtcp_stats_time_ms_(-1),
101 first_rtp_stats_time_ms_(-1),
101 start_stats_(stats) {} 102 start_stats_(stats) {}
102 103
103 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() {} 104 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() {}
104 105
106 void AccumulateRtpStats(const VideoSendStream::Stats& stats,
107 const VideoSendStream::Config& config,
108 StreamDataCounters* total_rtp_stats,
109 StreamDataCounters* rtx_stats) {
110 for (auto it : stats.substreams) {
111 const std::vector<uint32_t> rtx_ssrcs = config.rtp.rtx.ssrcs;
112 if (std::find(rtx_ssrcs.begin(), rtx_ssrcs.end(), it.first) !=
113 rtx_ssrcs.end()) {
114 rtx_stats->Add(it.second.rtp_stats);
115 } else {
116 total_rtp_stats->Add(it.second.rtp_stats);
117 }
118 }
119 }
120
105 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( 121 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms(
106 const VideoSendStream::Config& config, 122 const VideoSendStream::Config& config,
107 const VideoSendStream::Stats& current_stats) { 123 const VideoSendStream::Stats& current_stats) {
108 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); 124 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix);
109 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; 125 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0;
110 const int kMinRequiredSamples = 200; 126 const int kMinRequiredSamples = 200;
111 int in_width = input_width_counter_.Avg(kMinRequiredSamples); 127 int in_width = input_width_counter_.Avg(kMinRequiredSamples);
112 int in_height = input_height_counter_.Avg(kMinRequiredSamples); 128 int in_height = input_height_counter_.Avg(kMinRequiredSamples);
113 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); 129 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate());
114 if (in_width != -1) { 130 if (in_width != -1) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 RTC_HISTOGRAMS_COUNTS_10000(kIndex, 232 RTC_HISTOGRAMS_COUNTS_10000(kIndex,
217 uma_prefix_ + "PliPacketsReceivedPerMinute", 233 uma_prefix_ + "PliPacketsReceivedPerMinute",
218 counters.pli_packets * 60 / elapsed_sec); 234 counters.pli_packets * 60 / elapsed_sec);
219 if (counters.nack_requests > 0) { 235 if (counters.nack_requests > 0) {
220 RTC_HISTOGRAMS_PERCENTAGE( 236 RTC_HISTOGRAMS_PERCENTAGE(
221 kIndex, uma_prefix_ + "UniqueNackRequestsReceivedInPercent", 237 kIndex, uma_prefix_ + "UniqueNackRequestsReceivedInPercent",
222 counters.UniqueNackRequestsInPercent()); 238 counters.UniqueNackRequestsInPercent());
223 } 239 }
224 } 240 }
225 } 241 }
242
243 if (first_rtp_stats_time_ms_ != -1) {
244 int64_t elapsed_sec =
245 (clock_->TimeInMilliseconds() - first_rtp_stats_time_ms_) / 1000;
246 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) {
247 StreamDataCounters rtp;
248 StreamDataCounters rtx;
249 AccumulateRtpStats(current_stats, config, &rtp, &rtx);
250 StreamDataCounters start_rtp;
251 StreamDataCounters start_rtx;
252 AccumulateRtpStats(start_stats_, config, &start_rtp, &start_rtx);
253 rtp.Subtract(start_rtp);
254 rtx.Subtract(start_rtx);
255 StreamDataCounters rtp_rtx = rtp;
256 rtp_rtx.Add(rtx);
257
258 RTC_HISTOGRAMS_COUNTS_10000(
259 kIndex, uma_prefix_ + "BitrateSentInKbps",
260 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
261 1000));
262 RTC_HISTOGRAMS_COUNTS_10000(
263 kIndex, uma_prefix_ + "MediaBitrateSentInKbps",
264 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000));
265 RTC_HISTOGRAMS_COUNTS_10000(
266 kIndex, uma_prefix_ + "PaddingBitrateSentInKbps",
267 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec /
268 1000));
269 RTC_HISTOGRAMS_COUNTS_10000(
270 kIndex, uma_prefix_ + "RetransmittedBitrateSentInKbps",
271 static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 /
272 elapsed_sec / 1000));
273 if (!config.rtp.rtx.ssrcs.empty()) {
274 RTC_HISTOGRAMS_COUNTS_10000(
275 kIndex, uma_prefix_ + "RtxBitrateSentInKbps",
276 static_cast<int>(rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
277 1000));
278 }
279 if (config.rtp.fec.red_payload_type != -1) {
280 RTC_HISTOGRAMS_COUNTS_10000(kIndex,
281 uma_prefix_ + "FecBitrateSentInKbps",
282 static_cast<int>(rtp_rtx.fec.TotalBytes() *
283 8 / elapsed_sec / 1000));
284 }
285 }
286 }
226 } 287 }
227 288
228 void SendStatisticsProxy::SetContentType( 289 void SendStatisticsProxy::SetContentType(
229 VideoEncoderConfig::ContentType content_type) { 290 VideoEncoderConfig::ContentType content_type) {
230 rtc::CritScope lock(&crit_); 291 rtc::CritScope lock(&crit_);
231 if (content_type_ != content_type) { 292 if (content_type_ != content_type) {
232 uma_container_->UpdateHistograms(config_, stats_); 293 uma_container_->UpdateHistograms(config_, stats_);
233 uma_container_.reset( 294 uma_container_.reset(
234 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_)); 295 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_));
235 content_type_ = content_type; 296 content_type_ = content_type;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 483
423 void SendStatisticsProxy::DataCountersUpdated( 484 void SendStatisticsProxy::DataCountersUpdated(
424 const StreamDataCounters& counters, 485 const StreamDataCounters& counters,
425 uint32_t ssrc) { 486 uint32_t ssrc) {
426 rtc::CritScope lock(&crit_); 487 rtc::CritScope lock(&crit_);
427 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 488 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
428 RTC_DCHECK(stats != nullptr) 489 RTC_DCHECK(stats != nullptr)
429 << "DataCountersUpdated reported for unknown ssrc: " << ssrc; 490 << "DataCountersUpdated reported for unknown ssrc: " << ssrc;
430 491
431 stats->rtp_stats = counters; 492 stats->rtp_stats = counters;
493 if (uma_container_->first_rtp_stats_time_ms_ == -1)
494 uma_container_->first_rtp_stats_time_ms_ = clock_->TimeInMilliseconds();
432 } 495 }
433 496
434 void SendStatisticsProxy::Notify(const BitrateStatistics& total_stats, 497 void SendStatisticsProxy::Notify(const BitrateStatistics& total_stats,
435 const BitrateStatistics& retransmit_stats, 498 const BitrateStatistics& retransmit_stats,
436 uint32_t ssrc) { 499 uint32_t ssrc) {
437 rtc::CritScope lock(&crit_); 500 rtc::CritScope lock(&crit_);
438 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 501 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
439 if (stats == nullptr) 502 if (stats == nullptr)
440 return; 503 return;
441 504
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return Fraction(min_required_samples, 1000.0f); 557 return Fraction(min_required_samples, 1000.0f);
495 } 558 }
496 559
497 int SendStatisticsProxy::BoolSampleCounter::Fraction( 560 int SendStatisticsProxy::BoolSampleCounter::Fraction(
498 int min_required_samples, float multiplier) const { 561 int min_required_samples, float multiplier) const {
499 if (num_samples < min_required_samples || num_samples == 0) 562 if (num_samples < min_required_samples || num_samples == 0)
500 return -1; 563 return -1;
501 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); 564 return static_cast<int>((sum * multiplier / num_samples) + 0.5f);
502 } 565 }
503 } // namespace webrtc 566 } // 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