| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 SendStatisticsProxy::~SendStatisticsProxy() {} | 84 SendStatisticsProxy::~SendStatisticsProxy() {} |
| 85 | 85 |
| 86 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( | 86 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( |
| 87 const char* prefix) | 87 const char* prefix) |
| 88 : uma_prefix_(prefix), | 88 : uma_prefix_(prefix), |
| 89 max_sent_width_per_timestamp_(0), | 89 max_sent_width_per_timestamp_(0), |
| 90 max_sent_height_per_timestamp_(0), | 90 max_sent_height_per_timestamp_(0), |
| 91 input_frame_rate_tracker_(100u, 10u), | 91 input_frame_rate_tracker_(100u, 10u), |
| 92 sent_frame_rate_tracker_(100u, 10u) {} | 92 sent_frame_rate_tracker_(100u, 10u), |
| 93 first_rtcp_stats_time_ms_(-1) {} |
| 93 | 94 |
| 94 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { | 95 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { |
| 95 UpdateHistograms(); | 96 UpdateHistograms(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { | 99 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { |
| 99 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); | 100 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); |
| 100 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; | 101 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; |
| 101 const int kMinRequiredSamples = 200; | 102 const int kMinRequiredSamples = 200; |
| 102 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 103 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 160 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
| 160 if (delay_ms != -1) | 161 if (delay_ms != -1) |
| 161 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", | 162 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", |
| 162 delay_ms); | 163 delay_ms); |
| 163 | 164 |
| 164 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 165 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
| 165 if (max_delay_ms != -1) { | 166 if (max_delay_ms != -1) { |
| 166 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", | 167 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", |
| 167 max_delay_ms); | 168 max_delay_ms); |
| 168 } | 169 } |
| 170 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
| 171 if (first_rtcp_stats_time_ms_ != -1) { |
| 172 int64_t elapsed_time_ms = Clock::GetRealTimeClock()->TimeInMilliseconds() - |
| 173 first_rtcp_stats_time_ms_; |
| 174 if (elapsed_time_ms / 1000 >= metrics::kMinRunTimeInSeconds && |
| 175 fraction_lost != -1) { |
| 176 RTC_HISTOGRAMS_PERCENTAGE( |
| 177 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
| 178 } |
| 179 } |
| 169 } | 180 } |
| 170 | 181 |
| 171 void SendStatisticsProxy::SetContentType( | 182 void SendStatisticsProxy::SetContentType( |
| 172 VideoEncoderConfig::ContentType content_type) { | 183 VideoEncoderConfig::ContentType content_type) { |
| 173 rtc::CritScope lock(&crit_); | 184 rtc::CritScope lock(&crit_); |
| 174 if (content_type_ != content_type) { | 185 if (content_type_ != content_type) { |
| 175 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); | 186 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); |
| 176 content_type_ = content_type; | 187 content_type_ = content_type; |
| 177 } | 188 } |
| 178 } | 189 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 358 } |
| 348 | 359 |
| 349 void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics, | 360 void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics, |
| 350 uint32_t ssrc) { | 361 uint32_t ssrc) { |
| 351 rtc::CritScope lock(&crit_); | 362 rtc::CritScope lock(&crit_); |
| 352 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 363 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 353 if (stats == nullptr) | 364 if (stats == nullptr) |
| 354 return; | 365 return; |
| 355 | 366 |
| 356 stats->rtcp_stats = statistics; | 367 stats->rtcp_stats = statistics; |
| 368 uma_container_->report_block_stats_.Store(statistics, 0, ssrc); |
| 369 if (uma_container_->first_rtcp_stats_time_ms_ == -1) |
| 370 uma_container_->first_rtcp_stats_time_ms_ = clock_->TimeInMilliseconds(); |
| 357 } | 371 } |
| 358 | 372 |
| 359 void SendStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { | 373 void SendStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { |
| 360 } | 374 } |
| 361 | 375 |
| 362 void SendStatisticsProxy::DataCountersUpdated( | 376 void SendStatisticsProxy::DataCountersUpdated( |
| 363 const StreamDataCounters& counters, | 377 const StreamDataCounters& counters, |
| 364 uint32_t ssrc) { | 378 uint32_t ssrc) { |
| 365 rtc::CritScope lock(&crit_); | 379 rtc::CritScope lock(&crit_); |
| 366 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 380 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 return Fraction(min_required_samples, 1000.0f); | 447 return Fraction(min_required_samples, 1000.0f); |
| 434 } | 448 } |
| 435 | 449 |
| 436 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 450 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 437 int min_required_samples, float multiplier) const { | 451 int min_required_samples, float multiplier) const { |
| 438 if (num_samples < min_required_samples || num_samples == 0) | 452 if (num_samples < min_required_samples || num_samples == 0) |
| 439 return -1; | 453 return -1; |
| 440 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 454 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 441 } | 455 } |
| 442 } // namespace webrtc | 456 } // namespace webrtc |
| OLD | NEW |