Skip to content

Commit

Permalink
[core] Added SRTO_ESTINPUTBW option
Browse files Browse the repository at this point in the history
to get estimated input bitrate
  • Loading branch information
maxsharabayko committed Sep 10, 2020
1 parent a95a6a4 commit 6cafbfa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/APISocketOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ The following table lists SRT socket options in alphabetical order. Option detai
| [`SRTO_CONNTIMEO`](#SRTO_CONNTIMEO) | 1.1.2 | pre | `int32_t` | msec | 3000 | 0.. | W | GSD+ |
| [`SRTO_DRIFTTRACER`](#SRTO_DRIFTTRACER) | 1.5.0 | post | `bool` | | true | | RW | GSD |
| [`SRTO_ENFORCEDENCRYPTION`](#SRTO_ENFORCEDENCRYPTION) | 1.3.2 | pre | `bool` | | true | | W | GSD |
| [`SRTO_ESTINPUTBW`](#SRTO_ESTINPUTBW) | 1.5.0 | | `int64_t` | B/s | | | R | S |
| [`SRTO_EVENT`](#SRTO_EVENT) | | | `int32_t` | flags | | | R | S |
| [`SRTO_FC`](#SRTO_FC) | | pre | `int32_t` | pkts | 25600 | 32.. | RW | GSD |
| [`SRTO_GROUPCONNECT`](#SRTO_GROUPCONNECT) | 1.5.0 | pre | `int32_t` | | 0 | 0...1 | W | S |
Expand Down Expand Up @@ -373,10 +374,20 @@ seconds). It is therefore strongly recommended that you only set this flag to
FALSE on the listener when you are able to ensure that it is also set to FALSE
on the caller side.


[Return to list](#list-of-options)

#### SRTO_ESTINPUTBW

| Option Name | Since | Binding | Type | Units | Default | Range | Dir |Entity |
| :------------------ | :---: | :-----: | :-------: | :-----: | :--------: | :------: |:---:|:-----:|
| `SRTO_ESTINPUTBW` | 1.5.0 | | `int64_t` | B/s | | | R | S |

- Returns estimated input bitrate in Bytes per second (B/s).

- Input bitrate is only estimated when the corresponding mode is selected
(`SRTO_MAXBW = 0` and `SRTO_INPUTBW = 0`). See [SRTO_INPUTBW](#SRTO_INPUTBW) and [SRTO_MAXBW](#SRTO_MAXBW).

[Return to list](#list-of-options)

#### SRTO_EVENT

Expand Down
11 changes: 11 additions & 0 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,17 @@ void CUDT::getOpt(SRT_SOCKOPT optName, void *optval, int &optlen)
optlen = sizeof(int64_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);
Expand Down
1 change: 1 addition & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,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)
Expand Down
1 change: 1 addition & 0 deletions srtcore/srt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cafbfa

Please sign in to comment.