diff --git a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.cc b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.cc index 5c2d05ad62..7301e9726c 100644 --- a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.cc +++ b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.cc @@ -38,7 +38,7 @@ void BitRateStats::Init() } } -void BitRateStats::Update(WebRtc_UWord32 packetSizeBytes, WebRtc_Word64 nowMs) +void BitRateStats::Update(uint32_t packetSizeBytes, int64_t nowMs) { // Find an empty slot for storing the new sample and at the same time // accumulate the history. @@ -47,7 +47,7 @@ void BitRateStats::Update(WebRtc_UWord32 packetSizeBytes, WebRtc_Word64 nowMs) EraseOld(nowMs); } -void BitRateStats::EraseOld(WebRtc_Word64 nowMs) +void BitRateStats::EraseOld(int64_t nowMs) { while (_dataSamples.size() > 0) { @@ -66,12 +66,12 @@ void BitRateStats::EraseOld(WebRtc_Word64 nowMs) } } -WebRtc_UWord32 BitRateStats::BitRate(WebRtc_Word64 nowMs) +uint32_t BitRateStats::BitRate(int64_t nowMs) { // Calculate the average bit rate the past BITRATE_AVERAGE_WINDOW ms. // Removes any old samples from the list. EraseOld(nowMs); - return static_cast(_accumulatedBytes * 8.0f * 1000.0f / + return static_cast(_accumulatedBytes * 8.0f * 1000.0f / kBitrateAverageWindow + 0.5f); } diff --git a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.h b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.h index a3622a75c2..a2a0efcf2d 100644 --- a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.h +++ b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator.h @@ -24,8 +24,8 @@ public: ~BitRateStats(); void Init(); - void Update(WebRtc_UWord32 packetSizeBytes, WebRtc_Word64 nowMs); - WebRtc_UWord32 BitRate(WebRtc_Word64 nowMs); + void Update(uint32_t packetSizeBytes, int64_t nowMs); + uint32_t BitRate(int64_t nowMs); private: struct DataTimeSizeTuple @@ -35,14 +35,14 @@ private: _sizeBytes(sizeBytes), _timeCompleteMs(timeCompleteMs) {} - WebRtc_UWord32 _sizeBytes; - WebRtc_Word64 _timeCompleteMs; + uint32_t _sizeBytes; + int64_t _timeCompleteMs; }; - void EraseOld(WebRtc_Word64 nowMs); + void EraseOld(int64_t nowMs); std::list _dataSamples; - WebRtc_UWord32 _accumulatedBytes; + uint32_t _accumulatedBytes; }; } // namespace webrtc diff --git a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator_unittest.cc b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator_unittest.cc index 2a3a225107..ddc9e59983 100644 --- a/webrtc/modules/remote_bitrate_estimator/bitrate_estimator_unittest.cc +++ b/webrtc/modules/remote_bitrate_estimator/bitrate_estimator_unittest.cc @@ -30,7 +30,7 @@ protected: TEST_F(BitRateStatsTest, TestStrictMode) { - WebRtc_Word64 nowMs = 0; + int64_t nowMs = 0; // Should be initialized to 0. EXPECT_EQ(0u, bitRate.BitRate(nowMs)); bitRate.Update(1500, nowMs); diff --git a/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h b/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h index 0ad64ddccf..6c3dc40042 100644 --- a/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h +++ b/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h @@ -42,14 +42,14 @@ class RateControlInput { public: RateControlInput(BandwidthUsage bwState, - WebRtc_UWord32 incomingBitRate, + uint32_t incomingBitRate, double noiseVar) : _bwState(bwState), _incomingBitRate(incomingBitRate), _noiseVar(noiseVar) {} BandwidthUsage _bwState; - WebRtc_UWord32 _incomingBitRate; + uint32_t _incomingBitRate; double _noiseVar; }; } //namespace webrtc diff --git a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc index eb293bb3ba..fd54980d43 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc @@ -103,8 +103,8 @@ bool RemoteRateControl::TimeToReduceFurther( return false; } -WebRtc_Word32 RemoteRateControl::SetConfiguredBitRates( - WebRtc_UWord32 minBitRateBps, WebRtc_UWord32 maxBitRateBps) +int32_t RemoteRateControl::SetConfiguredBitRates( + uint32_t minBitRateBps, uint32_t maxBitRateBps) { if (minBitRateBps > maxBitRateBps) { @@ -117,11 +117,11 @@ WebRtc_Word32 RemoteRateControl::SetConfiguredBitRates( return 0; } -WebRtc_UWord32 RemoteRateControl::LatestEstimate() const { +uint32_t RemoteRateControl::LatestEstimate() const { return _currentBitRate; } -WebRtc_UWord32 RemoteRateControl::UpdateBandwidthEstimate(WebRtc_Word64 nowMS) +uint32_t RemoteRateControl::UpdateBandwidthEstimate(int64_t nowMS) { _currentBitRate = ChangeBitRate(_currentBitRate, _currentInput._incomingBitRate, @@ -135,7 +135,7 @@ void RemoteRateControl::SetRtt(unsigned int rtt) { } RateControlRegion RemoteRateControl::Update(const RateControlInput* input, - WebRtc_Word64 nowMS) + int64_t nowMS) { assert(input); #ifdef MATLAB @@ -192,10 +192,10 @@ RateControlRegion RemoteRateControl::Update(const RateControlInput* input, return _rcRegion; } -WebRtc_UWord32 RemoteRateControl::ChangeBitRate(WebRtc_UWord32 currentBitRate, - WebRtc_UWord32 incomingBitRate, +uint32_t RemoteRateControl::ChangeBitRate(uint32_t currentBitRate, + uint32_t incomingBitRate, double noiseVar, - WebRtc_Word64 nowMS) + int64_t nowMS) { if (!_updated) { @@ -234,17 +234,17 @@ WebRtc_UWord32 RemoteRateControl::ChangeBitRate(WebRtc_UWord32 currentBitRate, WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1, "BWE: Response time: %f + %i + 10*33\n", _avgChangePeriod, _rtt); - const WebRtc_UWord32 responseTime = static_cast(_avgChangePeriod + 0.5f) + _rtt + 300; + const uint32_t responseTime = static_cast(_avgChangePeriod + 0.5f) + _rtt + 300; double alpha = RateIncreaseFactor(nowMS, _lastBitRateChange, responseTime, noiseVar); WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1, "BWE: _avgChangePeriod = %f ms; RTT = %u ms", _avgChangePeriod, _rtt); - currentBitRate = static_cast(currentBitRate * alpha) + 1000; + currentBitRate = static_cast(currentBitRate * alpha) + 1000; if (_maxHoldRate > 0 && _beta * _maxHoldRate > currentBitRate) { - currentBitRate = static_cast(_beta * _maxHoldRate); + currentBitRate = static_cast(_beta * _maxHoldRate); _avgMaxBitRate = _beta * _maxHoldRate / 1000.0f; ChangeRegion(kRcNearMax); recovery = true; @@ -268,13 +268,13 @@ WebRtc_UWord32 RemoteRateControl::ChangeBitRate(WebRtc_UWord32 currentBitRate, { // Set bit rate to something slightly lower than max // to get rid of any self-induced delay. - currentBitRate = static_cast(_beta * incomingBitRate + 0.5); + currentBitRate = static_cast(_beta * incomingBitRate + 0.5); if (currentBitRate > _currentBitRate) { // Avoid increasing the rate when over-using. if (_rcRegion != kRcMaxUnknown) { - currentBitRate = static_cast(_beta * _avgMaxBitRate * 1000 + 0.5f); + currentBitRate = static_cast(_beta * _avgMaxBitRate * 1000 + 0.5f); } currentBitRate = BWE_MIN(currentBitRate, _currentBitRate); } @@ -321,7 +321,7 @@ WebRtc_UWord32 RemoteRateControl::ChangeBitRate(WebRtc_UWord32 currentBitRate, return currentBitRate; } -double RemoteRateControl::RateIncreaseFactor(WebRtc_Word64 nowMs, WebRtc_Word64 lastMs, WebRtc_UWord32 reactionTimeMs, double noiseVar) const +double RemoteRateControl::RateIncreaseFactor(int64_t nowMs, int64_t lastMs, uint32_t reactionTimeMs, double noiseVar) const { // alpha = 1.02 + B ./ (1 + exp(b*(tr - (c1*s2 + c2)))) // Parameters @@ -368,9 +368,9 @@ double RemoteRateControl::RateIncreaseFactor(WebRtc_Word64 nowMs, WebRtc_Word64 return alpha; } -void RemoteRateControl::UpdateChangePeriod(WebRtc_Word64 nowMs) +void RemoteRateControl::UpdateChangePeriod(int64_t nowMs) { - WebRtc_Word64 changePeriod = 0; + int64_t changePeriod = 0; if (_lastChangeMs > -1) { changePeriod = nowMs - _lastChangeMs; @@ -410,7 +410,7 @@ void RemoteRateControl::UpdateMaxBitRateEstimate(float incomingBitRateKbps) } } -void RemoteRateControl::ChangeState(const RateControlInput& input, WebRtc_Word64 nowMs) +void RemoteRateControl::ChangeState(const RateControlInput& input, int64_t nowMs) { switch (_currentInput._bwState) { diff --git a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h index 51391988b2..273305d002 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h +++ b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h @@ -24,13 +24,13 @@ class RemoteRateControl public: RemoteRateControl(); ~RemoteRateControl(); - WebRtc_Word32 SetConfiguredBitRates(WebRtc_UWord32 minBitRate, - WebRtc_UWord32 maxBitRate); - WebRtc_UWord32 LatestEstimate() const; - WebRtc_UWord32 UpdateBandwidthEstimate(WebRtc_Word64 nowMS); + int32_t SetConfiguredBitRates(uint32_t minBitRate, + uint32_t maxBitRate); + uint32_t LatestEstimate() const; + uint32_t UpdateBandwidthEstimate(int64_t nowMS); void SetRtt(unsigned int rtt); RateControlRegion Update(const RateControlInput* input, - WebRtc_Word64 nowMS); + int64_t nowMS); void Reset(); // Returns true if there is a valid estimate of the incoming bitrate, false @@ -44,39 +44,39 @@ public: unsigned int incoming_bitrate) const; private: - WebRtc_UWord32 ChangeBitRate(WebRtc_UWord32 currentBitRate, - WebRtc_UWord32 incomingBitRate, + uint32_t ChangeBitRate(uint32_t currentBitRate, + uint32_t incomingBitRate, double delayFactor, - WebRtc_Word64 nowMS); - double RateIncreaseFactor(WebRtc_Word64 nowMs, - WebRtc_Word64 lastMs, - WebRtc_UWord32 reactionTimeMs, + int64_t nowMS); + double RateIncreaseFactor(int64_t nowMs, + int64_t lastMs, + uint32_t reactionTimeMs, double noiseVar) const; - void UpdateChangePeriod(WebRtc_Word64 nowMs); + void UpdateChangePeriod(int64_t nowMs); void UpdateMaxBitRateEstimate(float incomingBitRateKbps); - void ChangeState(const RateControlInput& input, WebRtc_Word64 nowMs); + void ChangeState(const RateControlInput& input, int64_t nowMs); void ChangeState(RateControlState newState); void ChangeRegion(RateControlRegion region); static void StateStr(RateControlState state, char* str); static void StateStr(BandwidthUsage state, char* str); - WebRtc_UWord32 _minConfiguredBitRate; - WebRtc_UWord32 _maxConfiguredBitRate; - WebRtc_UWord32 _currentBitRate; - WebRtc_UWord32 _maxHoldRate; + uint32_t _minConfiguredBitRate; + uint32_t _maxConfiguredBitRate; + uint32_t _currentBitRate; + uint32_t _maxHoldRate; float _avgMaxBitRate; float _varMaxBitRate; RateControlState _rcState; RateControlState _cameFromState; RateControlRegion _rcRegion; - WebRtc_Word64 _lastBitRateChange; + int64_t _lastBitRateChange; RateControlInput _currentInput; bool _updated; - WebRtc_Word64 _timeFirstIncomingEstimate; + int64_t _timeFirstIncomingEstimate; bool _initializedBitRate; float _avgChangePeriod; - WebRtc_Word64 _lastChangeMs; + int64_t _lastChangeMs; float _beta; unsigned int _rtt; #ifdef MATLAB