Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Include packet header in rexmit BW calculation. #3008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions srtcore/buffer_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void CSndRateEstimator::addSample(const time_point& ts, int pkts, size_t bytes)
}
else
{
m_iRateBps = sum.m_iBytesCount * 1000 / (iNumPeriods * SAMPLE_DURATION_MS);
m_iRateBps = (sum.m_iBytesCount + CPacket::HDR_SIZE * sum.m_iPktsCount) * 1000 / (iNumPeriods * SAMPLE_DURATION_MS);
}

HLOGC(bslog.Note,
Expand All @@ -260,7 +260,8 @@ void CSndRateEstimator::addSample(const time_point& ts, int pkts, size_t bytes)
int CSndRateEstimator::getCurrentRate() const
{
SRT_ASSERT(m_iCurSampleIdx >= 0 && m_iCurSampleIdx < NUM_PERIODS);
return (int) avg_iir<16, unsigned long long>(m_iRateBps, m_Samples[m_iCurSampleIdx].m_iBytesCount * 1000 / SAMPLE_DURATION_MS);
const Sample& s = m_Samples[m_iCurSampleIdx];
return (int) avg_iir<16, unsigned long long>(m_iRateBps, (CPacket::HDR_SIZE * s.m_iPktsCount + s.m_iBytesCount) * 1000 / SAMPLE_DURATION_MS);
}

int CSndRateEstimator::incSampleIdx(int val, int inc) const
Expand Down
9 changes: 5 additions & 4 deletions srtcore/buffer_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ class CSndRateEstimator
/// @param [in] bytes number of payload bytes in the sample.
void addSample(const time_point& time, int pkts = 0, size_t bytes = 0);

/// Retrieve estimated bitrate in bytes per second
/// Retrieve estimated bitrate in bytes per second with 16-byte packet header.
int getRate() const { return m_iRateBps; }

/// Retrieve estimated bitrate in bytes per second inluding the current sampling interval.
/// Retrieve estimated bitrate in bytes per second (with 16-byte packet header)
/// including the current sampling interval.
int getCurrentRate() const;

private:
Expand Down Expand Up @@ -191,10 +192,10 @@ class CSndRateEstimator

Sample m_Samples[NUM_PERIODS];

time_point m_tsFirstSampleTime; //< Start time of the first sameple.
time_point m_tsFirstSampleTime; //< Start time of the first sample.
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
int m_iRateBps; //< Rate in Bytes/sec.
};

} // namespace srt
Expand Down
Loading