Skip to content

Commit

Permalink
[core] Restoring CSndRateEstimator
Browse files Browse the repository at this point in the history
  • Loading branch information
npanhaleux committed Aug 22, 2024
1 parent a3c8a82 commit 0eb1cf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions srtcore/buffer_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
Expand Down
20 changes: 9 additions & 11 deletions srtcore/buffer_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -190,14 +188,14 @@ class CSndRateEstimator
bool empty() const { return m_iPktsCount == 0; }
};

srt::FixedArray<Sample> 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
Expand Down

0 comments on commit 0eb1cf7

Please sign in to comment.