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}
diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc
index 996ea99..d133159 100644
--- a/p2p/base/connection.cc
+++ b/p2p/base/connection.cc
@@ -144,12 +144,6 @@
 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 @@
   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 @@
   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;
   }
diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc
index 84cbe5f..5aca40c 100644
--- a/rtc_base/helpers.cc
+++ b/rtc_base/helpers.cc
@@ -224,8 +224,4 @@
                              std::numeric_limits<double>::epsilon());
 }
 
-double GetNextMovingAverage(double prev_average, double cur, double ratio) {
-  return (ratio * prev_average + cur) / (ratio + 1);
-}
-
 }  // namespace rtc
diff --git a/rtc_base/helpers.h b/rtc_base/helpers.h
index 51ca672..095a645 100644
--- a/rtc_base/helpers.h
+++ b/rtc_base/helpers.h
@@ -83,10 +83,6 @@
 // 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_