Move moving average helper out of ssl target
to the only place where it is used. BUG=webrtc:339300437 Change-Id: I0d4124b95d19a11578efaf7e8e0a1ff1d39eb59b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/351581 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Philipp Hancke <phancke@meta.com> Cr-Commit-Position: refs/heads/main@{#42383}
This commit is contained in:
parent
ae5d50320d
commit
7b087121b5
@ -144,12 +144,6 @@ const int MINIMUM_RTT = 100; // 0.1 seconds
|
||||
const int MAXIMUM_RTT = 60000; // 60 seconds
|
||||
|
||||
const int DEFAULT_RTT_ESTIMATE_HALF_TIME_MS = 500;
|
||||
|
||||
// Computes our estimate of the RTT given the current estimate.
|
||||
inline int ConservativeRTTEstimate(int rtt) {
|
||||
return rtc::SafeClamp(2 * rtt, MINIMUM_RTT, MAXIMUM_RTT);
|
||||
}
|
||||
|
||||
// Weighting of the old rtt value to new data.
|
||||
const int RTT_RATIO = 3; // 3 : 1
|
||||
|
||||
@ -919,7 +913,8 @@ void Connection::UpdateState(int64_t now) {
|
||||
if (!port_)
|
||||
return;
|
||||
|
||||
int rtt = ConservativeRTTEstimate(rtt_);
|
||||
// Computes our estimate of the RTT given the current estimate.
|
||||
int rtt = rtc::SafeClamp(2 * rtt_, MINIMUM_RTT, MAXIMUM_RTT);
|
||||
|
||||
if (RTC_LOG_CHECK_LEVEL(LS_VERBOSE)) {
|
||||
std::string pings;
|
||||
@ -1183,8 +1178,10 @@ void Connection::ReceivedPingResponse(
|
||||
UpdateReceiving(last_ping_response_received_);
|
||||
set_write_state(STATE_WRITABLE);
|
||||
set_state(IceCandidatePairState::SUCCEEDED);
|
||||
|
||||
// Smooth the RTT estimate using a moving average.
|
||||
if (rtt_samples_ > 0) {
|
||||
rtt_ = rtc::GetNextMovingAverage(rtt_, rtt, RTT_RATIO);
|
||||
rtt_ = (RTT_RATIO * rtt_ + rtt) / (RTT_RATIO + 1);
|
||||
} else {
|
||||
rtt_ = rtt;
|
||||
}
|
||||
|
||||
@ -224,8 +224,4 @@ double CreateRandomDouble() {
|
||||
std::numeric_limits<double>::epsilon());
|
||||
}
|
||||
|
||||
double GetNextMovingAverage(double prev_average, double cur, double ratio) {
|
||||
return (ratio * prev_average + cur) / (ratio + 1);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
@ -83,10 +83,6 @@ uint32_t CreateRandomNonZeroId();
|
||||
// Generates a random double between 0.0 (inclusive) and 1.0 (exclusive).
|
||||
double CreateRandomDouble();
|
||||
|
||||
// Compute moving average with the given ratio between the previous average
|
||||
// value and the current value.
|
||||
double GetNextMovingAverage(double prev_average, double cur, double ratio);
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_HELPERS_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user