diff --git a/src/modules/rtp_rtcp/source/bandwidth_management.cc b/src/modules/rtp_rtcp/source/bandwidth_management.cc index 74038372a..1d18e8fa3 100644 --- a/src/modules/rtp_rtcp/source/bandwidth_management.cc +++ b/src/modules/rtp_rtcp/source/bandwidth_management.cc @@ -12,10 +12,12 @@ #include "trace.h" #include "rtp_utility.h" #include "rtp_rtcp_config.h" +#include "tick_util.h" #include // sqrt() namespace webrtc { + BandwidthManagement::BandwidthManagement(const WebRtc_Word32 id) : _id(id), _critsect(*CriticalSectionWrapper::CreateCriticalSection()), @@ -31,7 +33,8 @@ BandwidthManagement::BandwidthManagement(const WebRtc_Word32 id) : _last_round_trip_time(0), _bwEstimateIncoming(0), _smoothedFractionLostQ4(-1), // indicate uninitialized - _sFLFactorQ4(14) // 0.875 in Q4 + _sFLFactorQ4(14), // 0.875 in Q4 + _timeLastIncrease(0) { } @@ -157,9 +160,9 @@ WebRtc_Word32 BandwidthManagement::UpdatePacketLoss( } else { - // Report same loss as before and keep the accumulators until - // the next report. - *loss = _lastLoss; + // Report zero loss until we have enough data to estimate + // the loss rate. + *loss = 0; } } } @@ -218,6 +221,17 @@ WebRtc_UWord32 BandwidthManagement::ShapeSimple(WebRtc_Word32 packetLoss, WebRtc_UWord32 newBitRate = 0; bool reducing = false; + // Limit the rate increases to once a second. + if (packetLoss <= 5) + { + if ((TickTime::MillisecondTimestamp() - _timeLastIncrease) < + kBWEUpdateIntervalMs) + { + return _bitRate; + } + _timeLastIncrease = TickTime::MillisecondTimestamp(); + } + if (packetLoss > 5 && packetLoss <= 26) { // 2% - 10% diff --git a/src/modules/rtp_rtcp/source/bandwidth_management.h b/src/modules/rtp_rtcp/source/bandwidth_management.h index 77e39fad5..1c1372f3b 100644 --- a/src/modules/rtp_rtcp/source/bandwidth_management.h +++ b/src/modules/rtp_rtcp/source/bandwidth_management.h @@ -58,6 +58,8 @@ protected: WebRtc_Word32 packetLoss); private: + enum { kBWEUpdateIntervalMs = 1000 }; + WebRtc_Word32 _id; CriticalSectionWrapper& _critsect; @@ -81,6 +83,7 @@ private: WebRtc_UWord32 _bwEstimateIncoming; WebRtc_Word16 _smoothedFractionLostQ4; WebRtc_Word16 _sFLFactorQ4; // forgetting factor for _smoothedFractionLostQ4 + WebRtc_Word64 _timeLastIncrease; }; } // namespace webrtc