| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 286 } |
| 287 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); | 287 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); |
| 288 if (qp_h264 != -1) { | 288 if (qp_h264 != -1) { |
| 289 int spatial_idx = it.first; | 289 int spatial_idx = it.first; |
| 290 RTC_DCHECK_EQ(-1, spatial_idx); | 290 RTC_DCHECK_EQ(-1, spatial_idx); |
| 291 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", | 291 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", |
| 292 qp_h264); | 292 qp_h264); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 296 if (first_rtp_stats_time_ms_ != -1) { |
| 297 int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; | 297 quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 298 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 298 int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; |
| 299 int quality_changes = current_stats.number_of_quality_adapt_changes - | 299 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 300 start_stats_.number_of_quality_adapt_changes; | 300 int quality_changes = current_stats.number_of_quality_adapt_changes - |
| 301 RTC_HISTOGRAMS_COUNTS_100(kIndex, | 301 start_stats_.number_of_quality_adapt_changes; |
| 302 uma_prefix_ + "AdaptChangesPerMinute.Quality", | 302 RTC_HISTOGRAMS_COUNTS_100(kIndex, |
| 303 quality_changes * 60 / elapsed_sec); | 303 uma_prefix_ + "AdaptChangesPerMinute.Quality", |
| 304 } | 304 quality_changes * 60 / elapsed_sec); |
| 305 cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 305 } |
| 306 elapsed_sec = cpu_scaling_timer_.total_ms / 1000; | 306 cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 307 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 307 elapsed_sec = cpu_scaling_timer_.total_ms / 1000; |
| 308 int cpu_changes = current_stats.number_of_cpu_adapt_changes - | 308 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 309 start_stats_.number_of_cpu_adapt_changes; | 309 int cpu_changes = current_stats.number_of_cpu_adapt_changes - |
| 310 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "AdaptChangesPerMinute.Cpu", | 310 start_stats_.number_of_cpu_adapt_changes; |
| 311 cpu_changes * 60 / elapsed_sec); | 311 RTC_HISTOGRAMS_COUNTS_100(kIndex, |
| 312 uma_prefix_ + "AdaptChangesPerMinute.Cpu", |
| 313 cpu_changes * 60 / elapsed_sec); |
| 314 } |
| 312 } | 315 } |
| 313 | 316 |
| 314 if (first_rtcp_stats_time_ms_ != -1) { | 317 if (first_rtcp_stats_time_ms_ != -1) { |
| 315 int64_t elapsed_sec = | 318 int64_t elapsed_sec = |
| 316 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; | 319 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
| 317 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 320 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 318 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 321 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
| 319 if (fraction_lost != -1) { | 322 if (fraction_lost != -1) { |
| 320 RTC_HISTOGRAMS_PERCENTAGE( | 323 RTC_HISTOGRAMS_PERCENTAGE( |
| 321 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); | 324 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 stats_.encode_usage_percent = metrics.encode_usage_percent; | 469 stats_.encode_usage_percent = metrics.encode_usage_percent; |
| 467 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeTimeInMs", | 470 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeTimeInMs", |
| 468 "encode_time_ms", stats_.avg_encode_time_ms, | 471 "encode_time_ms", stats_.avg_encode_time_ms, |
| 469 "ssrc", rtp_config_.ssrcs[0]); | 472 "ssrc", rtp_config_.ssrcs[0]); |
| 470 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeUsagePercent", | 473 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.EncodeUsagePercent", |
| 471 "encode_usage_percent", stats_.encode_usage_percent, | 474 "encode_usage_percent", stats_.encode_usage_percent, |
| 472 "ssrc", rtp_config_.ssrcs[0]); | 475 "ssrc", rtp_config_.ssrcs[0]); |
| 473 } | 476 } |
| 474 | 477 |
| 475 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { | 478 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { |
| 479 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 476 rtc::CritScope lock(&crit_); | 480 rtc::CritScope lock(&crit_); |
| 477 stats_.suspended = is_suspended; | 481 stats_.suspended = is_suspended; |
| 478 if (is_suspended) { | 482 if (is_suspended) { |
| 479 // Pause framerate (add min pause time since there may be frames/packets | 483 // Pause framerate (add min pause time since there may be frames/packets |
| 480 // that are not yet sent). | 484 // that are not yet sent). |
| 481 const int64_t kMinMs = 500; | 485 const int64_t kMinMs = 500; |
| 482 uma_container_->input_fps_counter_.ProcessAndPauseForDuration(kMinMs); | 486 uma_container_->input_fps_counter_.ProcessAndPauseForDuration(kMinMs); |
| 483 uma_container_->sent_fps_counter_.ProcessAndPauseForDuration(kMinMs); | 487 uma_container_->sent_fps_counter_.ProcessAndPauseForDuration(kMinMs); |
| 484 // Pause bitrate stats. | 488 // Pause bitrate stats. |
| 485 uma_container_->total_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 489 uma_container_->total_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 486 uma_container_->media_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 490 uma_container_->media_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 487 uma_container_->rtx_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 491 uma_container_->rtx_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 488 uma_container_->padding_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 492 uma_container_->padding_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 489 uma_container_->retransmit_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 493 uma_container_->retransmit_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 490 uma_container_->fec_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 494 uma_container_->fec_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 495 // Stop adaptation stats. |
| 496 uma_container_->cpu_scaling_timer_.Stop(now_ms); |
| 497 uma_container_->quality_scaling_timer_.Stop(now_ms); |
| 491 } else { | 498 } else { |
| 499 // Start adaptation stats if scaling is enabled. |
| 500 if (cpu_downscales_ >= 0) |
| 501 uma_container_->cpu_scaling_timer_.Start(now_ms); |
| 502 if (quality_downscales_ >= 0) |
| 503 uma_container_->quality_scaling_timer_.Start(now_ms); |
| 492 // Stop pause explicitly for stats that may be zero/not updated for some | 504 // Stop pause explicitly for stats that may be zero/not updated for some |
| 493 // time. | 505 // time. |
| 494 uma_container_->rtx_byte_counter_.ProcessAndStopPause(); | 506 uma_container_->rtx_byte_counter_.ProcessAndStopPause(); |
| 495 uma_container_->padding_byte_counter_.ProcessAndStopPause(); | 507 uma_container_->padding_byte_counter_.ProcessAndStopPause(); |
| 496 uma_container_->retransmit_byte_counter_.ProcessAndStopPause(); | 508 uma_container_->retransmit_byte_counter_.ProcessAndStopPause(); |
| 497 uma_container_->fec_byte_counter_.ProcessAndStopPause(); | 509 uma_container_->fec_byte_counter_.ProcessAndStopPause(); |
| 498 } | 510 } |
| 499 } | 511 } |
| 500 | 512 |
| 501 VideoSendStream::Stats SendStatisticsProxy::GetStats() { | 513 VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 uma_container_->input_height_counter_.Add(height); | 709 uma_container_->input_height_counter_.Add(height); |
| 698 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); | 710 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); |
| 699 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", | 711 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", |
| 700 "frame_rate", round( | 712 "frame_rate", round( |
| 701 uma_container_->input_frame_rate_tracker_.ComputeRate()), | 713 uma_container_->input_frame_rate_tracker_.ComputeRate()), |
| 702 "ssrc", rtp_config_.ssrcs[0]); | 714 "ssrc", rtp_config_.ssrcs[0]); |
| 703 } | 715 } |
| 704 | 716 |
| 705 void SendStatisticsProxy::SetCpuScalingStats(int num_cpu_downscales) { | 717 void SendStatisticsProxy::SetCpuScalingStats(int num_cpu_downscales) { |
| 706 rtc::CritScope lock(&crit_); | 718 rtc::CritScope lock(&crit_); |
| 719 cpu_downscales_ = num_cpu_downscales; |
| 707 stats_.cpu_limited_resolution = num_cpu_downscales > 0; | 720 stats_.cpu_limited_resolution = num_cpu_downscales > 0; |
| 708 | 721 |
| 709 if (num_cpu_downscales >= 0) { | 722 if (num_cpu_downscales >= 0) { |
| 710 // Scaling enabled. | 723 // Scaling enabled. |
| 711 uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); | 724 if (!stats_.suspended) |
| 712 } else { | 725 uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); |
| 713 uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 726 return; |
| 714 } | 727 } |
| 728 uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 715 } | 729 } |
| 716 | 730 |
| 717 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { | 731 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { |
| 718 rtc::CritScope lock(&crit_); | 732 rtc::CritScope lock(&crit_); |
| 719 quality_downscales_ = num_quality_downscales; | 733 quality_downscales_ = num_quality_downscales; |
| 720 stats_.bw_limited_resolution = quality_downscales_ > 0; | 734 stats_.bw_limited_resolution = quality_downscales_ > 0; |
| 721 | 735 |
| 722 if (num_quality_downscales >= 0) { | 736 if (num_quality_downscales >= 0) { |
| 723 // Scaling enabled. | 737 // Scaling enabled. |
| 724 uma_container_->quality_scaling_timer_.Start(clock_->TimeInMilliseconds()); | 738 if (!stats_.suspended) { |
| 725 } else { | 739 uma_container_->quality_scaling_timer_.Start( |
| 726 uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 740 clock_->TimeInMilliseconds()); |
| 741 } |
| 742 return; |
| 727 } | 743 } |
| 744 uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 728 } | 745 } |
| 729 | 746 |
| 730 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | 747 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
| 731 bool cpu_restricted_resolution) { | 748 bool cpu_restricted_resolution) { |
| 732 rtc::CritScope lock(&crit_); | 749 rtc::CritScope lock(&crit_); |
| 733 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 750 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
| 734 ++stats_.number_of_cpu_adapt_changes; | 751 ++stats_.number_of_cpu_adapt_changes; |
| 735 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges"); | 752 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges"); |
| 736 } | 753 } |
| 737 | 754 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 } | 923 } |
| 907 | 924 |
| 908 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 925 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 909 int64_t min_required_samples, | 926 int64_t min_required_samples, |
| 910 float multiplier) const { | 927 float multiplier) const { |
| 911 if (num_samples < min_required_samples || num_samples == 0) | 928 if (num_samples < min_required_samples || num_samples == 0) |
| 912 return -1; | 929 return -1; |
| 913 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 930 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 914 } | 931 } |
| 915 } // namespace webrtc | 932 } // namespace webrtc |
| OLD | NEW |