From ac0cfdb4858b82d8f84d66725712ab81373ee9c5 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Thu, 10 Sep 2020 15:08:56 +0200 Subject: [PATCH] [core] Added SRTO_ESTINPUTBW option to get estimated input bitrate Co-authored-by: duB --- srtcore/core.cpp | 11 +++++++++++ srtcore/core.h | 1 + srtcore/srt.h | 1 + 3 files changed, 13 insertions(+) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index e292c642c..db666499e 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -1060,6 +1060,17 @@ void CUDT::getOpt(SRT_SOCKOPT optName, void *optval, int &optlen) optlen = sizeof(int32_t); break; + case SRTO_ESTINPUTBW: + *(int64_t*)optval = 0LL; + if (m_pSndBuffer && m_pSndBuffer->getInRatePeriod() != 0) + { + // return sampled internally measured input bw + const int rate = m_pSndBuffer->getInputRate(); + *(int64_t*)optval = rate; + } + optlen = sizeof(int64_t); + break; + case SRTO_STATE: *(int32_t *)optval = s_UDTUnited.getStatus(m_SocketID); optlen = sizeof(int32_t); diff --git a/srtcore/core.h b/srtcore/core.h index 1f7de081e..4e5f35fc9 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -770,6 +770,7 @@ class CUDT int m_iPeerTsbPdDelay_ms; // Tx delay that the peer uses to absorb burst in milliseconds bool m_bTLPktDrop; // Enable Too-late Packet Drop int64_t m_llInputBW; // Input stream rate (bytes/sec) + // 0: use internally estimated input bandwidth int m_iOverheadBW; // Percent above input stream rate (applies if m_llMaxBW == 0) bool m_bRcvNakReport; // Enable Receiver Periodic NAK Reports int m_iIpV6Only; // IPV6_V6ONLY option (-1 if not set) diff --git a/srtcore/srt.h b/srtcore/srt.h index dcc78c8c7..ba9965e62 100644 --- a/srtcore/srt.h +++ b/srtcore/srt.h @@ -218,6 +218,7 @@ typedef enum SRT_SOCKOPT { SRTO_PEERVERSION, // Peer SRT Version (from SRT Handshake) SRTO_CONNTIMEO = 36, // Connect timeout in msec. Caller default: 3000, rendezvous (x 10) SRTO_DRIFTTRACER = 37, // Enable or disable drift tracer + SRTO_ESTINPUTBW = 38, // Internally estimated input rate // (some space left) SRTO_SNDKMSTATE = 40, // (GET) the current state of the encryption at the peer side SRTO_RCVKMSTATE, // (GET) the current state of the encryption at the agent side