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

Added new option: SRTO_SNDDROPDELAY #375

Merged
merged 3 commits into from
Jun 22, 2018
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
1 change: 1 addition & 0 deletions apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const SocketOption srt_options [] {
{ "latency", 0, SRTO_LATENCY, SocketOption::PRE, SocketOption::INT, nullptr},
{ "tsbpddelay", 0, SRTO_TSBPDDELAY, SocketOption::PRE, SocketOption::INT, nullptr},
{ "tlpktdrop", 0, SRTO_TLPKTDROP, SocketOption::PRE, SocketOption::BOOL, nullptr},
{ "snddropdelay", 0, SRTO_SNDDROPDELAY, SocketOption::POST, SocketOption::INT, nullptr},
{ "nakreport", 0, SRTO_NAKREPORT, SocketOption::PRE, SocketOption::BOOL, nullptr},
{ "conntimeo", 0, SRTO_CONNTIMEO, SocketOption::PRE, SocketOption::INT, nullptr},
{ "lossmaxttl", 0, SRTO_LOSSMAXTTL, SocketOption::PRE, SocketOption::INT, nullptr},
Expand Down
24 changes: 22 additions & 2 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ CUDT::CUDT()
m_iOPT_TsbPdDelay = SRT_LIVE_DEF_LATENCY_MS;
m_iOPT_PeerTsbPdDelay = 0; //Peer's TsbPd delay as receiver (here is its minimum value, if used)
m_bOPT_TLPktDrop = true;
m_iOPT_SndDropDelay = 0;
m_bTLPktDrop = true; //Too-late Packet Drop
m_bMessageAPI = true;
m_zOPT_ExpPayloadSize = SRT_LIVE_DEF_PLSIZE;
Expand Down Expand Up @@ -303,6 +304,7 @@ CUDT::CUDT(const CUDT& ancestor)
m_iOPT_TsbPdDelay = ancestor.m_iOPT_TsbPdDelay;
m_iOPT_PeerTsbPdDelay = ancestor.m_iOPT_PeerTsbPdDelay;
m_bOPT_TLPktDrop = ancestor.m_bOPT_TLPktDrop;
m_iOPT_SndDropDelay = ancestor.m_iOPT_SndDropDelay;
m_zOPT_ExpPayloadSize = ancestor.m_zOPT_ExpPayloadSize;
m_bTLPktDrop = ancestor.m_bTLPktDrop;
m_bMessageAPI = ancestor.m_bMessageAPI;
Expand Down Expand Up @@ -581,6 +583,12 @@ void CUDT::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen)
m_bOPT_TLPktDrop = bool_int_value(optval, optlen);
break;

case SRTO_SNDDROPDELAY:
// Surprise: you may be connected to alter this option.
// The application may manipulate this option on sender while transmitting.
m_iOPT_SndDropDelay = *(int*)optval;
break;

case SRTO_PASSPHRASE:
if (m_bConnected)
throw CUDTException(MJ_NOTSUP, MN_ISCONNECTED, 0);
Expand Down Expand Up @@ -749,6 +757,7 @@ void CUDT::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen)
m_iOPT_TsbPdDelay = SRT_LIVE_DEF_LATENCY_MS;
m_iOPT_PeerTsbPdDelay = 0;
m_bOPT_TLPktDrop = true;
m_iOPT_SndDropDelay = 0;
m_bMessageAPI = true;
m_bRcvNakReport = true;
m_zOPT_ExpPayloadSize = SRT_LIVE_DEF_PLSIZE;
Expand All @@ -765,6 +774,7 @@ void CUDT::setOpt(SRT_SOCKOPT optName, const void* optval, int optlen)
m_iOPT_TsbPdDelay = 0;
m_iOPT_PeerTsbPdDelay = 0;
m_bOPT_TLPktDrop = false;
m_iOPT_SndDropDelay = -1;
m_bMessageAPI = false;
m_bRcvNakReport = false;
m_zOPT_ExpPayloadSize = 0; // use maximum
Expand Down Expand Up @@ -985,6 +995,11 @@ void CUDT::getOpt(SRT_SOCKOPT optName, void* optval, int& optlen)
optlen = sizeof(int32_t);
break;

case SRTO_SNDDROPDELAY:
*(int32_t*)optval = m_iOPT_SndDropDelay;
optlen = sizeof(int32_t);
break;

case SRTO_PBKEYLEN:
if (m_pCryptoControl)
*(int32_t*)optval = m_pCryptoControl->KeyLen(); // Running Key length.
Expand Down Expand Up @@ -4979,8 +4994,13 @@ void CUDT::checkNeedDrop(ref_t<bool> bCongestion)
// >>using 1 sec for worse case 1 frame using all bit budget.
// picture rate would be useful in auto SRT setting for min latency
// XXX Make SRT_TLPKTDROP_MINTHRESHOLD_MS option-configurable
int threshold_ms = std::max(m_iPeerTsbPdDelay_ms, +SRT_TLPKTDROP_MINTHRESHOLD_MS) + (2*COMM_SYN_INTERVAL_US/1000);
if (timespan_ms > threshold_ms)
int threshold_ms = 0;
if (m_iOPT_SndDropDelay >= 0)
{
threshold_ms = std::max(m_iPeerTsbPdDelay_ms + m_iOPT_SndDropDelay, +SRT_TLPKTDROP_MINTHRESHOLD_MS) + (2*COMM_SYN_INTERVAL_US/1000);
}

if (threshold_ms && timespan_ms > threshold_ms)
{
// protect packet retransmission
CGuard::enterCS(m_AckLock);
Expand Down
3 changes: 2 additions & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ class CUDT
bool m_bOPT_TsbPd; // Whether AGENT will do TSBPD Rx (whether peer does, is not agent's problem)
int m_iOPT_TsbPdDelay; // Agent's Rx latency
int m_iOPT_PeerTsbPdDelay; // Peer's Rx latency for the traffic made by Agent's Tx.
bool m_bOPT_TLPktDrop; // Whether Agent WILL DO TLPKTDROP on Rx.
bool m_bOPT_TLPktDrop; // Whether Agent WILL DO TLPKTDROP on Rx.
int m_iOPT_SndDropDelay; // Extra delay when deciding to snd-drop for TLPKTDROP, -1 to off
std::string m_sStreamName;

int m_iTsbPdDelay_ms; // Rx delay to absorb burst in milliseconds
Expand Down
3 changes: 2 additions & 1 deletion srtcore/srt.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ typedef enum SRT_SOCKOPT {
SRTO_IPTTL = 29, // IP Time To Live (passthru for system sockopt IPPROTO_IP/IP_TTL)
SRTO_IPTOS, // IP Type of Service (passthru for system sockopt IPPROTO_IP/IP_TOS)
SRTO_TLPKTDROP = 31, // Enable receiver pkt drop
// deprecated: SRTO_TSBPDMAXLAG (@c below)
SRTO_SNDDROPDELAY = 32, // Extra delay towards latency for sender TLPKTDROP decision (-1 to off)
SRTO_NAKREPORT = 33, // Enable receiver to send periodic NAK reports
SRTO_VERSION = 34, // Local SRT Version
SRTO_PEERVERSION, // Peer SRT Version (from SRT Handshake)
Expand Down Expand Up @@ -193,6 +193,7 @@ typedef enum SRT_SOCKOPT {
static const SRT_SOCKOPT SRTO_TWOWAYDATA SRT_ATR_DEPRECATED = (SRT_SOCKOPT)37;

// This has been deprecated a long time ago, treat this as never implemented.
// The value is also already reused for another option.
static const SRT_SOCKOPT SRTO_TSBPDMAXLAG SRT_ATR_DEPRECATED = (SRT_SOCKOPT)32;

// This option is a derivative from UDT; the mechanism that uses it is now
Expand Down