diff --git a/srtcore/buffer_tools.cpp b/srtcore/buffer_tools.cpp index 194c49c09..bbe9da046 100644 --- a/srtcore/buffer_tools.cpp +++ b/srtcore/buffer_tools.cpp @@ -157,10 +157,9 @@ void CRateEstimator::updateInputRate(const time_point& time, int pkts, int bytes CSndRateEstimator::CSndRateEstimator(const time_point& tsNow) : m_tsFirstSampleTime(tsNow) + , m_iFirstSampleIdx(0) , m_iCurSampleIdx(0) , m_iRateBps(0) - , m_Samples(NUM_PERIODS) - , m_iFirstSampleIdx(0) { } diff --git a/srtcore/buffer_tools.h b/srtcore/buffer_tools.h index 0be738da6..a4d552c29 100644 --- a/srtcore/buffer_tools.h +++ b/srtcore/buffer_tools.h @@ -148,11 +148,9 @@ class CSndRateEstimator /// including the current sampling interval. int getCurrentRate() const; -protected: - time_point m_tsFirstSampleTime; //< Start time of the first sample. - int m_iCurSampleIdx; //< Index of the current sample being collected. - int m_iRateBps; //< Rate in Bytes/sec. - +private: + static const int NUM_PERIODS = 10; + static const int SAMPLE_DURATION_MS = 100; // 100 ms struct Sample { int m_iPktsCount; // number of payload packets @@ -190,14 +188,14 @@ class CSndRateEstimator bool empty() const { return m_iPktsCount == 0; } }; - srt::FixedArray m_Samples; // Table of stored data + int incSampleIdx(int val, int inc = 1) const; -private: - static const int NUM_PERIODS = 10; - static const int SAMPLE_DURATION_MS = 100; // 100 ms - int m_iFirstSampleIdx; //< Index of the first sample. + Sample m_Samples[NUM_PERIODS]; - int incSampleIdx(int val, int inc = 1) const; + time_point m_tsFirstSampleTime; //< Start time of the first sameple. + int m_iFirstSampleIdx; //< Index of the first sample. + int m_iCurSampleIdx; //< Index of the current sample being collected. + int m_iRateBps; // Input Rate in Bytes/sec }; class CMovingRateEstimator