diff --git a/webrtc/base/ratetracker.cc b/webrtc/base/ratetracker.cc index 5cb449016e..35521a8d3d 100644 --- a/webrtc/base/ratetracker.cc +++ b/webrtc/base/ratetracker.cc @@ -73,8 +73,9 @@ double RateTracker::ComputeRateForInterval( size_t start_bucket = NextBucketIndex(current_bucket_ + buckets_to_skip); // Only count a portion of the first bucket according to how much of the // first bucket is within the current interval. - size_t total_samples = sample_buckets_[start_bucket] * - (bucket_milliseconds_ - milliseconds_to_skip) / + size_t total_samples = ((sample_buckets_[start_bucket] * + (bucket_milliseconds_ - milliseconds_to_skip)) + + (bucket_milliseconds_ >> 1)) / bucket_milliseconds_; // All other buckets in the interval are counted in their entirety. for (size_t i = NextBucketIndex(start_bucket); diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc index d34b05f8e9..69dff9483b 100644 --- a/webrtc/p2p/base/port.cc +++ b/webrtc/p2p/base/port.cc @@ -1308,7 +1308,7 @@ uint32_t Connection::last_received() { } size_t Connection::recv_bytes_second() { - return recv_rate_tracker_.ComputeRate(); + return round(recv_rate_tracker_.ComputeRate()); } size_t Connection::recv_total_bytes() { @@ -1316,7 +1316,7 @@ size_t Connection::recv_total_bytes() { } size_t Connection::sent_bytes_second() { - return send_rate_tracker_.ComputeRate(); + return round(send_rate_tracker_.ComputeRate()); } size_t Connection::sent_total_bytes() { diff --git a/webrtc/video/receive_statistics_proxy.cc b/webrtc/video/receive_statistics_proxy.cc index eec2bc8301..879a33ded2 100644 --- a/webrtc/video/receive_statistics_proxy.cc +++ b/webrtc/video/receive_statistics_proxy.cc @@ -44,9 +44,9 @@ void ReceiveStatisticsProxy::UpdateHistograms() { int samples = static_cast(render_fps_tracker_.TotalSampleCount()); if (samples > kMinRequiredSamples) { RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", - static_cast(render_fps_tracker_.ComputeTotalRate())); + round(render_fps_tracker_.ComputeTotalRate())); RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.RenderSqrtPixelsPerSecond", - static_cast(render_pixel_tracker_.ComputeTotalRate())); + round(render_pixel_tracker_.ComputeTotalRate())); } int width = render_width_counter_.Avg(kMinRequiredSamples); int height = render_height_counter_.Avg(kMinRequiredSamples); diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc index 916ffb3baa..57189f3175 100644 --- a/webrtc/video/send_statistics_proxy.cc +++ b/webrtc/video/send_statistics_proxy.cc @@ -11,6 +11,7 @@ #include "webrtc/video/send_statistics_proxy.h" #include +#include #include #include "webrtc/base/checks.h" @@ -70,11 +71,11 @@ SendStatisticsProxy::~SendStatisticsProxy() { void SendStatisticsProxy::UpdateHistograms() { int input_fps = - static_cast(input_frame_rate_tracker_.ComputeTotalRate()); + round(input_frame_rate_tracker_.ComputeTotalRate()); if (input_fps > 0) RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); int sent_fps = - static_cast(sent_frame_rate_tracker_.ComputeTotalRate()); + round(sent_frame_rate_tracker_.ComputeTotalRate()); if (sent_fps > 0) RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); @@ -155,7 +156,7 @@ VideoSendStream::Stats SendStatisticsProxy::GetStats() { rtc::CritScope lock(&crit_); PurgeOldStats(); stats_.input_frame_rate = - static_cast(input_frame_rate_tracker_.ComputeRate()); + round(input_frame_rate_tracker_.ComputeRate()); return stats_; }