Skip to content

Commit

Permalink
Used constants for input rate. Fixed after-start rate sampling period…
Browse files Browse the repository at this point in the history
… to 1s (Haivision#315)
  • Loading branch information
ethouris authored and rndi committed Mar 23, 2018
1 parent 692f331 commit 5dff5d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
12 changes: 6 additions & 6 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ m_iCount(0)
,m_iInRatePktsCount(0)
,m_iInRateBytesCount(0)
,m_InRateStartTime(0)
,m_InRatePeriod(500000) // 0.5 sec (fast start)
,m_iInRateBps(10000000/8) // 10 Mbps (1.25 MBps)
,m_iAvgPayloadSz(7*188)
,m_InRatePeriod(CUDT::SND_INPUTRATE_FAST_START_US) // 0.5 sec (fast start)
,m_iInRateBps(CUDT::SND_INPUTRATE_INITIAL_BPS)
,m_iAvgPayloadSz(SRT_LIVE_DEF_PLSIZE)
{
// initial physical buffer of "size"
m_pBuffer = new Buffer;
Expand Down Expand Up @@ -267,10 +267,10 @@ void CSndBuffer::updInputRate(uint64_t time, int pkts, int bytes)
}
}

int CSndBuffer::getInputRate(ref_t<int> r_payloadsz, ref_t<int> r_period)
int CSndBuffer::getInputRate(ref_t<int> r_payloadsz, ref_t<uint64_t> r_period)
{
int& payloadsz = *r_payloadsz;
int& period = *r_period;
uint64_t& period = *r_period;
uint64_t time = CTimer::getTime();

if ((m_InRatePeriod != 0)
Expand All @@ -292,7 +292,7 @@ int CSndBuffer::getInputRate(ref_t<int> r_payloadsz, ref_t<int> r_period)
m_InRateStartTime = time;
}
payloadsz = m_iAvgPayloadSz;
period = (int)m_InRatePeriod;
period = m_InRatePeriod;
return(m_iInRateBps);
}

Expand Down
2 changes: 1 addition & 1 deletion srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CSndBuffer
#endif /* SRT_ENABLE_SNDBUFSZ_MAVG */
int getCurrBufSize(ref_t<int> bytes, ref_t<int> timespan);

int getInputRate(ref_t<int> payloadtsz, ref_t<int> period);
int getInputRate(ref_t<int> payloadtsz, ref_t<uint64_t> period);
void updInputRate(uint64_t time, int pkts, int bytes);
void setInputRateSmpPeriod(int period);

Expand Down
9 changes: 4 additions & 5 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5594,8 +5594,7 @@ void CUDT::updateCC(ETransmissionEvent evt, EventVariant arg)
}
else
{
// XXX Use constant for this 500000
m_pSndBuffer->setInputRateSmpPeriod(bw == 0 ? 500000 : 0);
m_pSndBuffer->setInputRateSmpPeriod(bw == 0 ? SND_INPUTRATE_FAST_START_US: 0);
}

HLOGC(mglog.Debug, log << "updateCC/TEV_INIT: updating BW=" << m_llMaxBW
Expand All @@ -5612,7 +5611,7 @@ void CUDT::updateCC(ETransmissionEvent evt, EventVariant arg)
// This requests internal input rate sampling.
if (m_llMaxBW == 0 && m_llInputBW == 0)
{
int period;
uint64_t period;
int payloadsz; //CC will use its own average payload size
int64_t inputbw = m_pSndBuffer->getInputRate(Ref(payloadsz), Ref(period)); //Auto input rate

Expand All @@ -5630,8 +5629,8 @@ void CUDT::updateCC(ETransmissionEvent evt, EventVariant arg)
if (inputbw != 0)
m_Smoother->updateBandwidth(0, withOverhead(inputbw)); //Bytes/sec

if ((m_llSentTotal > 2000) && (period < 5000000))
m_pSndBuffer->setInputRateSmpPeriod(5000000); //5 sec period after fast start
if ((m_llSentTotal > SND_INPUTRATE_MAX_PACKETS) && (period < SND_INPUTRATE_RUNNING_US))
m_pSndBuffer->setInputRateSmpPeriod(SND_INPUTRATE_RUNNING_US); //1 sec period after fast start
}
}

Expand Down
7 changes: 7 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ class CUDT
static const uint64_t COMM_KEEPALIVE_PERIOD_US = 1*1000*1000;
static const int32_t COMM_SYN_INTERVAL_US = 10*1000;

// Input rate constants
static const uint64_t
SND_INPUTRATE_FAST_START_US = 500*1000,
SND_INPUTRATE_RUNNING_US = 1*1000*1000;
static const int64_t SND_INPUTRATE_MAX_PACKETS = 2000;
static const int SND_INPUTRATE_INITIAL_BPS = 10000000/8; // 10 Mbps (1.25 MBps)

int handshakeVersion()
{
return m_ConnRes.m_iVersion;
Expand Down

0 comments on commit 5dff5d8

Please sign in to comment.