From a52e9bd913bd5127200460fc9d5ef88772e9da7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Fri, 9 Aug 2019 08:31:50 +0200 Subject: [PATCH] Use StreamStatistician::BitrateReceived to produce total_bitrate_bps for GetStats. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:10679 Change-Id: I15d1b6d50cf61718de21554da4c676f352d5422c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148522 Reviewed-by: Erik Språng Reviewed-by: Danil Chapovalov Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#28819} --- video/receive_statistics_proxy.cc | 11 ----------- video/receive_statistics_proxy.h | 1 - video/video_receive_stream.cc | 11 ++++++++++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 139ba69991..aaeed1b5c8 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -105,7 +105,6 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy( renders_fps_estimator_(1000, 1000), render_fps_tracker_(100, 10u), render_pixel_tracker_(100, 10u), - total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count video_quality_observer_( new VideoQualityObserver(VideoContentType::UNSPECIFIED)), interframe_delay_max_moving_(kMovingMaxWindowMs), @@ -571,8 +570,6 @@ VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { UpdateFramerate(now_ms); stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0); stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0); - stats_.total_bitrate_bps = - static_cast(total_byte_tracker_.ComputeRate() * 8); stats_.interframe_delay_max_ms = interframe_delay_max_moving_.Max(now_ms).value_or(-1); stats_.freeze_count = video_quality_observer_->NumFreezes(); @@ -673,25 +670,17 @@ void ReceiveStatisticsProxy::OnCname(uint32_t ssrc, absl::string_view cname) { void ReceiveStatisticsProxy::DataCountersUpdated( const webrtc::StreamDataCounters& counters, uint32_t ssrc) { - size_t last_total_bytes = 0; - size_t total_bytes = 0; rtc::CritScope lock(&crit_); if (ssrc == stats_.ssrc) { - last_total_bytes = stats_.rtp_stats.transmitted.TotalBytes(); - total_bytes = counters.transmitted.TotalBytes(); stats_.rtp_stats = counters; } else { auto it = rtx_stats_.find(ssrc); if (it != rtx_stats_.end()) { - last_total_bytes = it->second.transmitted.TotalBytes(); - total_bytes = counters.transmitted.TotalBytes(); it->second = counters; } else { RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc; } } - if (total_bytes > last_total_bytes) - total_byte_tracker_.AddSamples(total_bytes - last_total_bytes); } void ReceiveStatisticsProxy::OnDecodedFrame(const VideoFrame& frame, diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h index 715f9b4673..fe93030a7b 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h @@ -152,7 +152,6 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, RateStatistics renders_fps_estimator_ RTC_GUARDED_BY(crit_); rtc::RateTracker render_fps_tracker_ RTC_GUARDED_BY(crit_); rtc::RateTracker render_pixel_tracker_ RTC_GUARDED_BY(crit_); - rtc::RateTracker total_byte_tracker_ RTC_GUARDED_BY(crit_); rtc::SampleCounter sync_offset_counter_ RTC_GUARDED_BY(crit_); rtc::SampleCounter decode_time_counter_ RTC_GUARDED_BY(crit_); rtc::SampleCounter jitter_buffer_delay_counter_ RTC_GUARDED_BY(crit_); diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index f56906d10e..3a50bc9134 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -459,10 +459,19 @@ void VideoReceiveStream::Stop() { VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { VideoReceiveStream::Stats stats = stats_proxy_.GetStats(); + stats.total_bitrate_bps = 0; StreamStatistician* statistician = rtp_receive_statistics_->GetStatistician(stats.ssrc); - if (statistician) + if (statistician) { statistician->GetStatistics(&stats.rtcp_stats, /*reset=*/false); + stats.total_bitrate_bps = statistician->BitrateReceived(); + } + if (config_.rtp.rtx_ssrc) { + StreamStatistician* rtx_statistician = + rtp_receive_statistics_->GetStatistician(config_.rtp.rtx_ssrc); + if (rtx_statistician) + stats.total_bitrate_bps += rtx_statistician->BitrateReceived(); + } return stats; }