Index: webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc |
index 4ec11b63452745cf1f8d772b0971575dc97e767b..932be1bb9e1c19490a397146ba96c941884ac0fd 100644 |
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc |
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc |
@@ -14,7 +14,7 @@ |
#include <cstdlib> |
-#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
+#include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
#include "webrtc/modules/rtp_rtcp/source/time_util.h" |
namespace webrtc { |
@@ -29,8 +29,7 @@ |
RtcpStatisticsCallback* rtcp_callback, |
StreamDataCountersCallback* rtp_callback) |
: clock_(clock), |
- incoming_bitrate_(kStatisticsProcessIntervalMs, |
- RateStatistics::kBpsScale), |
+ incoming_bitrate_(clock, NULL), |
ssrc_(0), |
max_reordering_threshold_(kDefaultMaxReorderingThreshold), |
jitter_q4_(0), |
@@ -62,7 +61,7 @@ |
rtc::CritScope cs(&stream_lock_); |
bool in_order = InOrderPacketInternal(header.sequenceNumber); |
ssrc_ = header.ssrc; |
- incoming_bitrate_.Update(packet_length, clock_->TimeInMilliseconds()); |
+ incoming_bitrate_.Update(packet_length); |
receive_counters_.transmitted.AddPacket(packet_length, header); |
if (!in_order && retransmitted) { |
receive_counters_.retransmitted.AddPacket(packet_length, header); |
@@ -301,7 +300,12 @@ |
uint32_t StreamStatisticianImpl::BitrateReceived() const { |
rtc::CritScope cs(&stream_lock_); |
- return incoming_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); |
+ return incoming_bitrate_.BitrateNow(); |
+} |
+ |
+void StreamStatisticianImpl::ProcessBitrate() { |
+ rtc::CritScope cs(&stream_lock_); |
+ incoming_bitrate_.Process(); |
} |
void StreamStatisticianImpl::LastReceiveTimeNtp(uint32_t* secs, |
@@ -372,6 +376,7 @@ |
ReceiveStatisticsImpl::ReceiveStatisticsImpl(Clock* clock) |
: clock_(clock), |
+ last_rate_update_ms_(0), |
rtcp_stats_callback_(NULL), |
rtp_stats_callback_(NULL) {} |
@@ -447,6 +452,23 @@ |
} |
} |
+void ReceiveStatisticsImpl::Process() { |
+ rtc::CritScope cs(&receive_statistics_lock_); |
+ for (StatisticianImplMap::iterator it = statisticians_.begin(); |
+ it != statisticians_.end(); ++it) { |
+ it->second->ProcessBitrate(); |
+ } |
+ last_rate_update_ms_ = clock_->TimeInMilliseconds(); |
+} |
+ |
+int64_t ReceiveStatisticsImpl::TimeUntilNextProcess() { |
+ rtc::CritScope cs(&receive_statistics_lock_); |
+ int64_t time_since_last_update = clock_->TimeInMilliseconds() - |
+ last_rate_update_ms_; |
+ return std::max<int64_t>( |
+ kStatisticsProcessIntervalMs - time_since_last_update, 0); |
+} |
+ |
void ReceiveStatisticsImpl::RegisterRtcpStatisticsCallback( |
RtcpStatisticsCallback* callback) { |
rtc::CritScope cs(&receive_statistics_lock_); |
@@ -503,6 +525,10 @@ |
void NullReceiveStatistics::SetMaxReorderingThreshold( |
int max_reordering_threshold) {} |
+int64_t NullReceiveStatistics::TimeUntilNextProcess() { return 0; } |
+ |
+void NullReceiveStatistics::Process() {} |
+ |
void NullReceiveStatistics::RegisterRtcpStatisticsCallback( |
RtcpStatisticsCallback* callback) {} |