mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 (#3362)
Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
7a56208f2f
commit
fe086dfc31
143 changed files with 38185 additions and 15108 deletions
600
trunk/3rdparty/srt-1-fit/srtcore/srt.h
vendored
600
trunk/3rdparty/srt-1-fit/srtcore/srt.h
vendored
|
@ -13,8 +13,8 @@ written by
|
|||
Haivision Systems Inc.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef INC__SRTC_H
|
||||
#define INC__SRTC_H
|
||||
#ifndef INC_SRTC_H
|
||||
#define INC_SRTC_H
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
@ -23,7 +23,6 @@ written by
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "srt4udt.h"
|
||||
#include "logging_api.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -36,7 +35,7 @@ written by
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef __MINGW__
|
||||
#ifndef __MINGW32__
|
||||
// Explicitly define 32-bit and 64-bit numbers
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
|
@ -47,17 +46,14 @@ written by
|
|||
// VC 6.0 does not support unsigned __int64: may cause potential problems.
|
||||
typedef __int64 uint64_t;
|
||||
#endif
|
||||
|
||||
#ifdef SRT_DYNAMIC
|
||||
#ifdef SRT_EXPORTS
|
||||
#define SRT_API __declspec(dllexport)
|
||||
#else
|
||||
#define SRT_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SRT_DYNAMIC
|
||||
#ifdef SRT_EXPORTS
|
||||
#define SRT_API __declspec(dllexport)
|
||||
#else
|
||||
#define SRT_API
|
||||
#define SRT_API __declspec(dllimport)
|
||||
#endif
|
||||
#else // __MINGW__
|
||||
#else // !SRT_DYNAMIC
|
||||
#define SRT_API
|
||||
#endif
|
||||
#else
|
||||
|
@ -69,48 +65,99 @@ written by
|
|||
// You can use these constants with SRTO_MINVERSION option.
|
||||
#define SRT_VERSION_FEAT_HSv5 0x010300
|
||||
|
||||
#if defined(__cplusplus) && __cplusplus > 201406
|
||||
#define SRT_HAVE_CXX17 1
|
||||
#else
|
||||
#define SRT_HAVE_CXX17 0
|
||||
#endif
|
||||
|
||||
|
||||
// Stadnard attributes
|
||||
|
||||
// When compiling in C++17 mode, use the standard C++17 attributes
|
||||
// (out of these, only [[deprecated]] is supported in C++14, so
|
||||
// for all lesser standard use compiler-specific attributes).
|
||||
#if defined(SRT_NO_DEPRECATED)
|
||||
|
||||
#define SRT_ATR_UNUSED
|
||||
#define SRT_ATR_DEPRECATED
|
||||
#define SRT_ATR_NODISCARD
|
||||
|
||||
#elif defined(__cplusplus) && __cplusplus > 201406
|
||||
#if SRT_HAVE_CXX17
|
||||
|
||||
// Unused: DO NOT issue a warning if this entity is unused.
|
||||
#define SRT_ATR_UNUSED [[maybe_unused]]
|
||||
#define SRT_ATR_DEPRECATED [[deprecated]]
|
||||
|
||||
// Nodiscard: issue a warning if the return value was discarded.
|
||||
#define SRT_ATR_NODISCARD [[nodiscard]]
|
||||
|
||||
// GNUG is GNU C/C++; this syntax is also supported by Clang
|
||||
#elif defined( __GNUC__)
|
||||
#elif defined(__GNUC__)
|
||||
#define SRT_ATR_UNUSED __attribute__((unused))
|
||||
#define SRT_ATR_DEPRECATED __attribute__((deprecated))
|
||||
#define SRT_ATR_NODISCARD __attribute__((warn_unused_result))
|
||||
#elif defined(_MSC_VER)
|
||||
#define SRT_ATR_UNUSED __pragma(warning(suppress: 4100 4101))
|
||||
#define SRT_ATR_NODISCARD _Check_return_
|
||||
#else
|
||||
#define SRT_ATR_UNUSED
|
||||
#define SRT_ATR_DEPRECATED
|
||||
#define SRT_ATR_NODISCARD
|
||||
#endif
|
||||
|
||||
|
||||
// DEPRECATED attributes
|
||||
|
||||
// There's needed DEPRECATED and DEPRECATED_PX, as some compilers require them
|
||||
// before the entity, others after the entity.
|
||||
// The *_PX version is the prefix attribute, which applies only
|
||||
// to functions (Microsoft compilers).
|
||||
|
||||
// When deprecating a function, mark it:
|
||||
//
|
||||
// SRT_ATR_DEPRECATED_PX retval function(arguments) SRT_ATR_DEPRECATED;
|
||||
//
|
||||
|
||||
// When SRT_NO_DEPRECATED defined, do not issue any deprecation warnings.
|
||||
// Regardless of the compiler type.
|
||||
#if defined(SRT_NO_DEPRECATED)
|
||||
|
||||
#define SRT_ATR_DEPRECATED
|
||||
#define SRT_ATR_DEPRECATED_PX
|
||||
|
||||
#elif SRT_HAVE_CXX17
|
||||
|
||||
#define SRT_ATR_DEPRECATED
|
||||
#define SRT_ATR_DEPRECATED_PX [[deprecated]]
|
||||
|
||||
// GNUG is GNU C/C++; this syntax is also supported by Clang
|
||||
#elif defined(__GNUC__)
|
||||
#define SRT_ATR_DEPRECATED_PX
|
||||
#define SRT_ATR_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define SRT_ATR_DEPRECATED_PX __declspec(deprecated)
|
||||
#define SRT_ATR_DEPRECATED // no postfix-type modifier
|
||||
#else
|
||||
#define SRT_ATR_DEPRECATED_PX
|
||||
#define SRT_ATR_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int SRTSOCKET; // SRTSOCKET is a typedef to int anyway, and it's not even in UDT namespace :)
|
||||
typedef int32_t SRTSOCKET;
|
||||
|
||||
// The most significant bit 31 (sign bit actually) is left unused,
|
||||
// so that all people who check the value for < 0 instead of -1
|
||||
// still get what they want. The bit 30 is reserved for marking
|
||||
// the "socket group". Most of the API functions should work
|
||||
// transparently with the socket descriptor designating a single
|
||||
// socket or a socket group.
|
||||
static const int32_t SRTGROUP_MASK = (1 << 30);
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef __MINGW__
|
||||
typedef SOCKET SYSSOCKET;
|
||||
#else
|
||||
typedef int SYSSOCKET;
|
||||
#endif
|
||||
typedef SOCKET SYSSOCKET;
|
||||
#else
|
||||
typedef int SYSSOCKET;
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_BONDING
|
||||
#define ENABLE_BONDING 0
|
||||
#endif
|
||||
|
||||
typedef SYSSOCKET UDPSOCKET;
|
||||
|
||||
|
||||
|
@ -141,8 +188,7 @@ typedef enum SRT_SOCKOPT {
|
|||
SRTO_LINGER = 7, // waiting for unsent data when closing
|
||||
SRTO_UDP_SNDBUF = 8, // UDP sending buffer size
|
||||
SRTO_UDP_RCVBUF = 9, // UDP receiving buffer size
|
||||
// XXX Free space for 2 options
|
||||
// after deprecated ones are removed
|
||||
// (some space left)
|
||||
SRTO_RENDEZVOUS = 12, // rendezvous connection mode
|
||||
SRTO_SNDTIMEO = 13, // send() timeout
|
||||
SRTO_RCVTIMEO = 14, // recv() timeout
|
||||
|
@ -155,11 +201,10 @@ typedef enum SRT_SOCKOPT {
|
|||
SRTO_SENDER = 21, // Sender mode (independent of conn mode), for encryption, tsbpd handshake.
|
||||
SRTO_TSBPDMODE = 22, // Enable/Disable TsbPd. Enable -> Tx set origin timestamp, Rx deliver packet at origin time + delay
|
||||
SRTO_LATENCY = 23, // NOT RECOMMENDED. SET: to both SRTO_RCVLATENCY and SRTO_PEERLATENCY. GET: same as SRTO_RCVLATENCY.
|
||||
SRTO_TSBPDDELAY = 23, // DEPRECATED. ALIAS: SRTO_LATENCY
|
||||
SRTO_INPUTBW = 24, // Estimated input stream rate.
|
||||
SRTO_OHEADBW, // MaxBW ceiling based on % over input stream rate. Applies when UDT_MAXBW=0 (auto).
|
||||
SRTO_PASSPHRASE = 26, // Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto
|
||||
SRTO_PBKEYLEN, // Crypto key len in bytes {16,24,32} Default: 16 (128-bit)
|
||||
SRTO_PASSPHRASE = 26, // Crypto PBKDF2 Passphrase (must be 10..79 characters, or empty to disable encryption)
|
||||
SRTO_PBKEYLEN, // Crypto key len in bytes {16,24,32} Default: 16 (AES-128)
|
||||
SRTO_KMSTATE, // Key Material exchange status (UDT_SRTKmState)
|
||||
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)
|
||||
|
@ -168,10 +213,10 @@ typedef enum SRT_SOCKOPT {
|
|||
SRTO_NAKREPORT = 33, // Enable receiver to send periodic NAK reports
|
||||
SRTO_VERSION = 34, // Local SRT Version
|
||||
SRTO_PEERVERSION, // Peer SRT Version (from SRT Handshake)
|
||||
SRTO_CONNTIMEO = 36, // Connect timeout in msec. Ccaller default: 3000, rendezvous (x 10)
|
||||
// deprecated: SRTO_TWOWAYDATA, SRTO_SNDPBKEYLEN, SRTO_RCVPBKEYLEN (@c below)
|
||||
_DEPRECATED_SRTO_SNDPBKEYLEN = 38, // (needed to use inside the code without generating -Wswitch)
|
||||
//
|
||||
SRTO_CONNTIMEO = 36, // Connect timeout in msec. Caller default: 3000, rendezvous (x 10)
|
||||
SRTO_DRIFTTRACER = 37, // Enable or disable drift tracer
|
||||
SRTO_MININPUTBW = 38, // Minimum estimate of input stream 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
|
||||
SRTO_LOSSMAXTTL, // Maximum possible packet reorder tolerance (number of packets to receive after loss to send lossreport)
|
||||
|
@ -188,15 +233,34 @@ typedef enum SRT_SOCKOPT {
|
|||
SRTO_ENFORCEDENCRYPTION, // Connection to be rejected or quickly broken when one side encryption set or bad password
|
||||
SRTO_IPV6ONLY, // IPV6_V6ONLY mode
|
||||
SRTO_PEERIDLETIMEO, // Peer-idle timeout (max time of silence heard from peer) in [ms]
|
||||
// (some space left)
|
||||
SRTO_PACKETFILTER = 60 // Add and configure a packet filter
|
||||
SRTO_BINDTODEVICE, // Forward the SOL_SOCKET/SO_BINDTODEVICE option on socket (pass packets only from that device)
|
||||
SRTO_GROUPCONNECT, // Set on a listener to allow group connection (ENABLE_BONDING)
|
||||
SRTO_GROUPMINSTABLETIMEO, // Minimum Link Stability timeout (backup mode) in milliseconds (ENABLE_BONDING)
|
||||
SRTO_GROUPTYPE, // Group type to which an accepted socket is about to be added, available in the handshake (ENABLE_BONDING)
|
||||
SRTO_PACKETFILTER = 60, // Add and configure a packet filter
|
||||
SRTO_RETRANSMITALGO = 61, // An option to select packet retransmission algorithm
|
||||
|
||||
SRTO_E_SIZE // Always last element, not a valid option.
|
||||
} SRT_SOCKOPT;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
typedef SRT_ATR_DEPRECATED SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED;
|
||||
|
||||
#if __cplusplus > 199711L // C++11
|
||||
// Newer compilers report error when [[deprecated]] is applied to types,
|
||||
// and C++11 and higher uses this.
|
||||
// Note that this doesn't exactly use the 'deprecated' attribute,
|
||||
// as it's introduced in C++14. What is actually used here is the
|
||||
// fact that unknown attributes are ignored, but still warned about.
|
||||
// This should only catch an eye - and that's what it does.
|
||||
#define SRT_DEPRECATED_OPTION(value) ((SRT_SOCKOPT [[deprecated]])value)
|
||||
#else
|
||||
// Older (pre-C++11) compilers use gcc deprecated applied to a typedef
|
||||
typedef SRT_ATR_DEPRECATED_PX SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED SRT_ATR_DEPRECATED;
|
||||
#define SRT_DEPRECATED_OPTION(value) ((SRT_SOCKOPT_DEPRECATED)value)
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
@ -213,46 +277,9 @@ enum SRT_ATR_DEPRECATED SRT_SOCKOPT_DEPRECATED
|
|||
#define SRT_DEPRECATED_OPTION(value) ((enum SRT_SOCKOPT_DEPRECATED)value)
|
||||
#endif
|
||||
|
||||
// DEPRECATED OPTIONS:
|
||||
|
||||
// SRTO_TWOWAYDATA: not to be used. SRT connection is always bidirectional if
|
||||
// both clients support HSv5 - that is, since version 1.3.0. This flag was
|
||||
// introducted around 1.2.0 version when full bidirectional support was added,
|
||||
// but the bidirectional feature was decided no to be enabled due to huge
|
||||
// differences between bidirectional support (especially concerning encryption)
|
||||
// with HSv4 and HSv5 (that is, HSv4 was decided to remain unidirectional only,
|
||||
// even though partial support is already provided in this version).
|
||||
|
||||
#define SRTO_TWOWAYDATA SRT_DEPRECATED_OPTION(37)
|
||||
|
||||
// This has been deprecated a long time ago, treat this as never implemented.
|
||||
// The value is also already reused for another option.
|
||||
#define SRTO_TSBPDMAXLAG SRT_DEPRECATED_OPTION(32)
|
||||
|
||||
// This option is a derivative from UDT; the mechanism that uses it is now
|
||||
// settable by SRTO_CONGESTION, or more generally by SRTO_TRANSTYPE. The freed
|
||||
// number has been reused for a read-only option SRTO_ISN. This option should
|
||||
// have never been used anywhere, just for safety this is temporarily declared
|
||||
// as deprecated.
|
||||
#define SRTO_CC SRT_DEPRECATED_OPTION(3)
|
||||
|
||||
// These two flags were derived from UDT, but they were never used.
|
||||
// Probably it didn't make sense anyway. The maximum size of the message
|
||||
// in File/Message mode is defined by SRTO_SNDBUF, and the MSGTTL is
|
||||
// a parameter used in `srt_sendmsg` and `srt_sendmsg2`.
|
||||
#define SRTO_MAXMSG SRT_DEPRECATED_OPTION(10)
|
||||
#define SRTO_MSGTTL SRT_DEPRECATED_OPTION(11)
|
||||
|
||||
// These flags come from an older experimental implementation of bidirectional
|
||||
// encryption support, which were used two different SEKs, KEKs and passphrases
|
||||
// per direction. The current implementation uses just one in both directions,
|
||||
// so SRTO_PBKEYLEN should be used for both cases.
|
||||
#define SRTO_SNDPBKEYLEN SRT_DEPRECATED_OPTION(38)
|
||||
#define SRTO_RCVPBKEYLEN SRT_DEPRECATED_OPTION(39)
|
||||
|
||||
// Keeping old name for compatibility (deprecated)
|
||||
#define SRTO_SMOOTHER SRT_DEPRECATED_OPTION(47)
|
||||
#define SRTO_STRICTENC SRT_DEPRECATED_OPTION(53)
|
||||
// Note that there are no deprecated options at the moment, but the mechanism
|
||||
// stays so that it can be used in future. Example:
|
||||
// #define SRTO_STRICTENC SRT_DEPRECATED_OPTION(53)
|
||||
|
||||
typedef enum SRT_TRANSTYPE
|
||||
{
|
||||
|
@ -295,9 +322,7 @@ struct CBytePerfMon
|
|||
int pktRcvUndecryptTotal; // number of undecrypted packets
|
||||
uint64_t byteSentTotal; // total number of sent data bytes, including retransmissions
|
||||
uint64_t byteRecvTotal; // total number of received bytes
|
||||
#ifdef SRT_ENABLE_LOSTBYTESCOUNT
|
||||
uint64_t byteRcvLossTotal; // total number of lost bytes
|
||||
#endif
|
||||
uint64_t byteRetransTotal; // total number of retransmitted bytes
|
||||
uint64_t byteSndDropTotal; // number of too-late-to-send dropped bytes
|
||||
uint64_t byteRcvDropTotal; // number of too-late-to play missing bytes (estimate based on average packet size)
|
||||
|
@ -327,9 +352,7 @@ struct CBytePerfMon
|
|||
int pktRcvUndecrypt; // number of undecrypted packets
|
||||
uint64_t byteSent; // number of sent data bytes, including retransmissions
|
||||
uint64_t byteRecv; // number of received bytes
|
||||
#ifdef SRT_ENABLE_LOSTBYTESCOUNT
|
||||
uint64_t byteRcvLoss; // number of retransmitted bytes
|
||||
#endif
|
||||
uint64_t byteRetrans; // number of retransmitted bytes
|
||||
uint64_t byteSndDrop; // number of too-late-to-send dropped bytes
|
||||
uint64_t byteRcvDrop; // number of too-late-to play missing bytes (estimate based on average packet size)
|
||||
|
@ -370,6 +393,20 @@ struct CBytePerfMon
|
|||
int pktRcvFilterLoss; // number of packet loss not coverable by filter
|
||||
int pktReorderTolerance; // packet reorder tolerance value
|
||||
//<
|
||||
|
||||
// New stats in 1.5.0
|
||||
|
||||
// Total
|
||||
int64_t pktSentUniqueTotal; // total number of data packets sent by the application
|
||||
int64_t pktRecvUniqueTotal; // total number of packets to be received by the application
|
||||
uint64_t byteSentUniqueTotal; // total number of data bytes, sent by the application
|
||||
uint64_t byteRecvUniqueTotal; // total number of data bytes to be received by the application
|
||||
|
||||
// Local
|
||||
int64_t pktSentUnique; // number of data packets sent by the application
|
||||
int64_t pktRecvUnique; // number of packets to be received by the application
|
||||
uint64_t byteSentUnique; // number of data bytes, sent by the application
|
||||
uint64_t byteRecvUnique; // number of data bytes to be received by the application
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -399,12 +436,14 @@ enum CodeMinor
|
|||
MN_REJECTED = 2,
|
||||
MN_NORES = 3,
|
||||
MN_SECURITY = 4,
|
||||
MN_CLOSED = 5,
|
||||
// MJ_CONNECTION
|
||||
MN_CONNLOST = 1,
|
||||
MN_NOCONN = 2,
|
||||
// MJ_SYSTEMRES
|
||||
MN_THREAD = 1,
|
||||
MN_MEMORY = 2,
|
||||
MN_OBJECT = 3,
|
||||
// MJ_FILESYSTEM
|
||||
MN_SEEKGFAIL = 1,
|
||||
MN_READFAIL = 2,
|
||||
|
@ -424,6 +463,8 @@ enum CodeMinor
|
|||
MN_BUSY = 11,
|
||||
MN_XSIZE = 12,
|
||||
MN_EIDINVAL = 13,
|
||||
MN_EEMPTY = 14,
|
||||
MN_BUSYPORT = 15,
|
||||
// MJ_AGAIN
|
||||
MN_WRAVAIL = 1,
|
||||
MN_RDAVAIL = 2,
|
||||
|
@ -431,12 +472,10 @@ enum CodeMinor
|
|||
MN_CONGESTION = 4
|
||||
};
|
||||
|
||||
static const enum CodeMinor MN_ISSTREAM SRT_ATR_DEPRECATED = (enum CodeMinor)(9);
|
||||
static const enum CodeMinor MN_ISDGRAM SRT_ATR_DEPRECATED = (enum CodeMinor)(10);
|
||||
|
||||
// Stupid, but effective. This will be #undefined, so don't worry.
|
||||
#define MJ(major) (1000 * MJ_##major)
|
||||
#define MN(major, minor) (1000 * MJ_##major + MN_##minor)
|
||||
#define SRT_EMJ(major) (1000 * MJ_##major)
|
||||
#define SRT_EMN(major, minor) (1000 * MJ_##major + MN_##minor)
|
||||
|
||||
// Some better way to define it, and better for C language.
|
||||
typedef enum SRT_ERRNO
|
||||
|
@ -444,55 +483,56 @@ typedef enum SRT_ERRNO
|
|||
SRT_EUNKNOWN = -1,
|
||||
SRT_SUCCESS = MJ_SUCCESS,
|
||||
|
||||
SRT_ECONNSETUP = MJ(SETUP),
|
||||
SRT_ENOSERVER = MN(SETUP, TIMEOUT),
|
||||
SRT_ECONNREJ = MN(SETUP, REJECTED),
|
||||
SRT_ESOCKFAIL = MN(SETUP, NORES),
|
||||
SRT_ESECFAIL = MN(SETUP, SECURITY),
|
||||
SRT_ECONNSETUP = SRT_EMJ(SETUP),
|
||||
SRT_ENOSERVER = SRT_EMN(SETUP, TIMEOUT),
|
||||
SRT_ECONNREJ = SRT_EMN(SETUP, REJECTED),
|
||||
SRT_ESOCKFAIL = SRT_EMN(SETUP, NORES),
|
||||
SRT_ESECFAIL = SRT_EMN(SETUP, SECURITY),
|
||||
SRT_ESCLOSED = SRT_EMN(SETUP, CLOSED),
|
||||
|
||||
SRT_ECONNFAIL = MJ(CONNECTION),
|
||||
SRT_ECONNLOST = MN(CONNECTION, CONNLOST),
|
||||
SRT_ENOCONN = MN(CONNECTION, NOCONN),
|
||||
SRT_ECONNFAIL = SRT_EMJ(CONNECTION),
|
||||
SRT_ECONNLOST = SRT_EMN(CONNECTION, CONNLOST),
|
||||
SRT_ENOCONN = SRT_EMN(CONNECTION, NOCONN),
|
||||
|
||||
SRT_ERESOURCE = MJ(SYSTEMRES),
|
||||
SRT_ETHREAD = MN(SYSTEMRES, THREAD),
|
||||
SRT_ENOBUF = MN(SYSTEMRES, MEMORY),
|
||||
SRT_ERESOURCE = SRT_EMJ(SYSTEMRES),
|
||||
SRT_ETHREAD = SRT_EMN(SYSTEMRES, THREAD),
|
||||
SRT_ENOBUF = SRT_EMN(SYSTEMRES, MEMORY),
|
||||
SRT_ESYSOBJ = SRT_EMN(SYSTEMRES, OBJECT),
|
||||
|
||||
SRT_EFILE = MJ(FILESYSTEM),
|
||||
SRT_EINVRDOFF = MN(FILESYSTEM, SEEKGFAIL),
|
||||
SRT_ERDPERM = MN(FILESYSTEM, READFAIL),
|
||||
SRT_EINVWROFF = MN(FILESYSTEM, SEEKPFAIL),
|
||||
SRT_EWRPERM = MN(FILESYSTEM, WRITEFAIL),
|
||||
SRT_EFILE = SRT_EMJ(FILESYSTEM),
|
||||
SRT_EINVRDOFF = SRT_EMN(FILESYSTEM, SEEKGFAIL),
|
||||
SRT_ERDPERM = SRT_EMN(FILESYSTEM, READFAIL),
|
||||
SRT_EINVWROFF = SRT_EMN(FILESYSTEM, SEEKPFAIL),
|
||||
SRT_EWRPERM = SRT_EMN(FILESYSTEM, WRITEFAIL),
|
||||
|
||||
SRT_EINVOP = MJ(NOTSUP),
|
||||
SRT_EBOUNDSOCK = MN(NOTSUP, ISBOUND),
|
||||
SRT_ECONNSOCK = MN(NOTSUP, ISCONNECTED),
|
||||
SRT_EINVPARAM = MN(NOTSUP, INVAL),
|
||||
SRT_EINVSOCK = MN(NOTSUP, SIDINVAL),
|
||||
SRT_EUNBOUNDSOCK = MN(NOTSUP, ISUNBOUND),
|
||||
SRT_ENOLISTEN = MN(NOTSUP, NOLISTEN),
|
||||
SRT_ERDVNOSERV = MN(NOTSUP, ISRENDEZVOUS),
|
||||
SRT_ERDVUNBOUND = MN(NOTSUP, ISRENDUNBOUND),
|
||||
SRT_EINVALMSGAPI = MN(NOTSUP, INVALMSGAPI),
|
||||
SRT_EINVALBUFFERAPI = MN(NOTSUP, INVALBUFFERAPI),
|
||||
SRT_EDUPLISTEN = MN(NOTSUP, BUSY),
|
||||
SRT_ELARGEMSG = MN(NOTSUP, XSIZE),
|
||||
SRT_EINVPOLLID = MN(NOTSUP, EIDINVAL),
|
||||
SRT_EINVOP = SRT_EMJ(NOTSUP),
|
||||
SRT_EBOUNDSOCK = SRT_EMN(NOTSUP, ISBOUND),
|
||||
SRT_ECONNSOCK = SRT_EMN(NOTSUP, ISCONNECTED),
|
||||
SRT_EINVPARAM = SRT_EMN(NOTSUP, INVAL),
|
||||
SRT_EINVSOCK = SRT_EMN(NOTSUP, SIDINVAL),
|
||||
SRT_EUNBOUNDSOCK = SRT_EMN(NOTSUP, ISUNBOUND),
|
||||
SRT_ENOLISTEN = SRT_EMN(NOTSUP, NOLISTEN),
|
||||
SRT_ERDVNOSERV = SRT_EMN(NOTSUP, ISRENDEZVOUS),
|
||||
SRT_ERDVUNBOUND = SRT_EMN(NOTSUP, ISRENDUNBOUND),
|
||||
SRT_EINVALMSGAPI = SRT_EMN(NOTSUP, INVALMSGAPI),
|
||||
SRT_EINVALBUFFERAPI = SRT_EMN(NOTSUP, INVALBUFFERAPI),
|
||||
SRT_EDUPLISTEN = SRT_EMN(NOTSUP, BUSY),
|
||||
SRT_ELARGEMSG = SRT_EMN(NOTSUP, XSIZE),
|
||||
SRT_EINVPOLLID = SRT_EMN(NOTSUP, EIDINVAL),
|
||||
SRT_EPOLLEMPTY = SRT_EMN(NOTSUP, EEMPTY),
|
||||
SRT_EBINDCONFLICT = SRT_EMN(NOTSUP, BUSYPORT),
|
||||
|
||||
SRT_EASYNCFAIL = MJ(AGAIN),
|
||||
SRT_EASYNCSND = MN(AGAIN, WRAVAIL),
|
||||
SRT_EASYNCRCV = MN(AGAIN, RDAVAIL),
|
||||
SRT_ETIMEOUT = MN(AGAIN, XMTIMEOUT),
|
||||
SRT_ECONGEST = MN(AGAIN, CONGESTION),
|
||||
SRT_EASYNCFAIL = SRT_EMJ(AGAIN),
|
||||
SRT_EASYNCSND = SRT_EMN(AGAIN, WRAVAIL),
|
||||
SRT_EASYNCRCV = SRT_EMN(AGAIN, RDAVAIL),
|
||||
SRT_ETIMEOUT = SRT_EMN(AGAIN, XMTIMEOUT),
|
||||
SRT_ECONGEST = SRT_EMN(AGAIN, CONGESTION),
|
||||
|
||||
SRT_EPEERERR = MJ(PEERERROR)
|
||||
SRT_EPEERERR = SRT_EMJ(PEERERROR)
|
||||
} SRT_ERRNO;
|
||||
|
||||
static const SRT_ERRNO SRT_EISSTREAM SRT_ATR_DEPRECATED = (SRT_ERRNO) MN(NOTSUP, INVALMSGAPI);
|
||||
static const SRT_ERRNO SRT_EISDGRAM SRT_ATR_DEPRECATED = (SRT_ERRNO) MN(NOTSUP, INVALBUFFERAPI);
|
||||
|
||||
#undef MJ
|
||||
#undef MN
|
||||
#undef SRT_EMJ
|
||||
#undef SRT_EMN
|
||||
|
||||
enum SRT_REJECT_REASON
|
||||
{
|
||||
|
@ -510,33 +550,87 @@ enum SRT_REJECT_REASON
|
|||
SRT_REJ_UNSECURE, // password required or unexpected
|
||||
SRT_REJ_MESSAGEAPI, // streamapi/messageapi collision
|
||||
SRT_REJ_CONGESTION, // incompatible congestion-controller type
|
||||
SRT_REJ_FILTER, // incompatible packet filter
|
||||
SRT_REJ_FILTER, // incompatible packet filter
|
||||
SRT_REJ_GROUP, // incompatible group
|
||||
SRT_REJ_TIMEOUT, // connection timeout
|
||||
|
||||
SRT_REJ__SIZE,
|
||||
SRT_REJ_E_SIZE,
|
||||
};
|
||||
|
||||
// XXX This value remains for some time, but it's deprecated
|
||||
// Planned deprecation removal: rel1.6.0.
|
||||
#define SRT_REJ__SIZE SRT_REJ_E_SIZE
|
||||
|
||||
// Reject category codes:
|
||||
|
||||
#define SRT_REJC_VALUE(code) (1000 * (code/1000))
|
||||
#define SRT_REJC_INTERNAL 0 // Codes from above SRT_REJECT_REASON enum
|
||||
#define SRT_REJC_PREDEFINED 1000 // Standard server error codes
|
||||
#define SRT_REJC_USERDEFINED 2000 // User defined error codes
|
||||
|
||||
|
||||
// Logging API - specialization for SRT.
|
||||
|
||||
// Define logging functional areas for log selection.
|
||||
// Use values greater than 0. Value 0 is reserved for LOGFA_GENERAL,
|
||||
// which is considered always enabled.
|
||||
// WARNING: This part is generated.
|
||||
|
||||
// Logger Functional Areas
|
||||
// Note that 0 is "general".
|
||||
|
||||
// Made by #define so that it's available also for C API.
|
||||
#define SRT_LOGFA_GENERAL 0
|
||||
#define SRT_LOGFA_BSTATS 1
|
||||
#define SRT_LOGFA_CONTROL 2
|
||||
#define SRT_LOGFA_DATA 3
|
||||
#define SRT_LOGFA_TSBPD 4
|
||||
#define SRT_LOGFA_REXMIT 5
|
||||
#define SRT_LOGFA_HAICRYPT 6
|
||||
#define SRT_LOGFA_CONGEST 7
|
||||
// Values 0* - general, unqualified
|
||||
// Values 1* - control
|
||||
// Values 2* - receiving
|
||||
// Values 3* - sending
|
||||
// Values 4* - management
|
||||
|
||||
// To make a typical int32_t size, although still use std::bitset.
|
||||
// Made by #define so that it's available also for C API.
|
||||
|
||||
// Use ../scripts/generate-logging-defs.tcl to regenerate.
|
||||
|
||||
// SRT_LOGFA BEGIN GENERATED SECTION {
|
||||
|
||||
#define SRT_LOGFA_GENERAL 0 // gglog: General uncategorized log, for serious issues only
|
||||
#define SRT_LOGFA_SOCKMGMT 1 // smlog: Socket create/open/close/configure activities
|
||||
#define SRT_LOGFA_CONN 2 // cnlog: Connection establishment and handshake
|
||||
#define SRT_LOGFA_XTIMER 3 // xtlog: The checkTimer and around activities
|
||||
#define SRT_LOGFA_TSBPD 4 // tslog: The TsBPD thread
|
||||
#define SRT_LOGFA_RSRC 5 // rslog: System resource allocation and management
|
||||
|
||||
#define SRT_LOGFA_CONGEST 7 // cclog: Congestion control module
|
||||
#define SRT_LOGFA_PFILTER 8 // pflog: Packet filter module
|
||||
|
||||
#define SRT_LOGFA_API_CTRL 11 // aclog: API part for socket and library managmenet
|
||||
|
||||
#define SRT_LOGFA_QUE_CTRL 13 // qclog: Queue control activities
|
||||
|
||||
#define SRT_LOGFA_EPOLL_UPD 16 // eilog: EPoll, internal update activities
|
||||
|
||||
#define SRT_LOGFA_API_RECV 21 // arlog: API part for receiving
|
||||
#define SRT_LOGFA_BUF_RECV 22 // brlog: Buffer, receiving side
|
||||
#define SRT_LOGFA_QUE_RECV 23 // qrlog: Queue, receiving side
|
||||
#define SRT_LOGFA_CHN_RECV 24 // krlog: CChannel, receiving side
|
||||
#define SRT_LOGFA_GRP_RECV 25 // grlog: Group, receiving side
|
||||
|
||||
#define SRT_LOGFA_API_SEND 31 // aslog: API part for sending
|
||||
#define SRT_LOGFA_BUF_SEND 32 // bslog: Buffer, sending side
|
||||
#define SRT_LOGFA_QUE_SEND 33 // qslog: Queue, sending side
|
||||
#define SRT_LOGFA_CHN_SEND 34 // kslog: CChannel, sending side
|
||||
#define SRT_LOGFA_GRP_SEND 35 // gslog: Group, sending side
|
||||
|
||||
#define SRT_LOGFA_INTERNAL 41 // inlog: Internal activities not connected directly to a socket
|
||||
|
||||
#define SRT_LOGFA_QUE_MGMT 43 // qmlog: Queue, management part
|
||||
#define SRT_LOGFA_CHN_MGMT 44 // kmlog: CChannel, management part
|
||||
#define SRT_LOGFA_GRP_MGMT 45 // gmlog: Group, management part
|
||||
#define SRT_LOGFA_EPOLL_API 46 // ealog: EPoll, API part
|
||||
|
||||
#define SRT_LOGFA_HAICRYPT 6 // hclog: Haicrypt module area
|
||||
#define SRT_LOGFA_APPLOG 10 // aplog: Applications
|
||||
|
||||
// } SRT_LOGFA END GENERATED SECTION
|
||||
|
||||
// To make a typical int64_t size, although still use std::bitset.
|
||||
// C API will carry it over.
|
||||
#define SRT_LOGFA_LASTNONE 31
|
||||
#define SRT_LOGFA_LASTNONE 63
|
||||
|
||||
enum SRT_KM_STATE
|
||||
{
|
||||
|
@ -550,16 +644,73 @@ enum SRT_KM_STATE
|
|||
enum SRT_EPOLL_OPT
|
||||
{
|
||||
SRT_EPOLL_OPT_NONE = 0x0, // fallback
|
||||
// this values are defined same as linux epoll.h
|
||||
|
||||
// Values intended to be the same as in `<sys/epoll.h>`.
|
||||
// so that if system values are used by mistake, they should have the same effect
|
||||
// This applies to: IN, OUT, ERR and ET.
|
||||
|
||||
/// Ready for 'recv' operation:
|
||||
///
|
||||
/// - For stream mode it means that at least 1 byte is available.
|
||||
/// In this mode the buffer may extract only a part of the packet,
|
||||
/// leaving next data possible for extraction later.
|
||||
///
|
||||
/// - For message mode it means that there is at least one packet
|
||||
/// available (this may change in future, as it is desired that
|
||||
/// one full message should only wake up, not single packet of a
|
||||
/// not yet extractable message).
|
||||
///
|
||||
/// - For live mode it means that there's at least one packet
|
||||
/// ready to play.
|
||||
///
|
||||
/// - For listener sockets, this means that there is a new connection
|
||||
/// waiting for pickup through the `srt_accept()` call, that is,
|
||||
/// the next call to `srt_accept()` will succeed without blocking
|
||||
/// (see an alias SRT_EPOLL_ACCEPT below).
|
||||
SRT_EPOLL_IN = 0x1,
|
||||
|
||||
/// Ready for 'send' operation.
|
||||
///
|
||||
/// - For stream mode it means that there's a free space in the
|
||||
/// sender buffer for at least 1 byte of data. The next send
|
||||
/// operation will only allow to send as much data as it is free
|
||||
/// space in the buffer.
|
||||
///
|
||||
/// - For message mode it means that there's a free space for at
|
||||
/// least one UDP packet. The edge-triggered mode can be used to
|
||||
/// pick up updates as the free space in the sender buffer grows.
|
||||
///
|
||||
/// - For live mode it means that there's a free space for at least
|
||||
/// one UDP packet. On the other hand, no readiness for OUT usually
|
||||
/// means an extraordinary congestion on the link, meaning also that
|
||||
/// you should immediately slow down the sending rate or you may get
|
||||
/// a connection break soon.
|
||||
///
|
||||
/// - For non-blocking sockets used with `srt_connect*` operation,
|
||||
/// this flag simply means that the connection was established.
|
||||
SRT_EPOLL_OUT = 0x4,
|
||||
|
||||
/// The socket has encountered an error in the last operation
|
||||
/// and the next operation on that socket will end up with error.
|
||||
/// You can retry the operation, but getting the error from it
|
||||
/// is certain, so you may as well close the socket.
|
||||
SRT_EPOLL_ERR = 0x8,
|
||||
|
||||
// To avoid confusion in the internal code, the following
|
||||
// duplicates are introduced to improve clarity.
|
||||
SRT_EPOLL_CONNECT = SRT_EPOLL_OUT,
|
||||
SRT_EPOLL_ACCEPT = SRT_EPOLL_IN,
|
||||
|
||||
SRT_EPOLL_UPDATE = 0x10,
|
||||
SRT_EPOLL_ET = 1u << 31
|
||||
};
|
||||
// These are actually flags - use a bit container:
|
||||
typedef int32_t SRT_EPOLL_T;
|
||||
|
||||
// Define which epoll flags determine events. All others are special flags.
|
||||
#define SRT_EPOLL_EVENTTYPES (SRT_EPOLL_IN | SRT_EPOLL_OUT | SRT_EPOLL_UPDATE | SRT_EPOLL_ERR)
|
||||
#define SRT_EPOLL_ETONLY (SRT_EPOLL_UPDATE)
|
||||
|
||||
enum SRT_EPOLL_FLAGS
|
||||
{
|
||||
/// This allows the EID container to be empty when calling the waiting
|
||||
|
@ -582,17 +733,8 @@ inline SRT_EPOLL_OPT operator|(SRT_EPOLL_OPT a1, SRT_EPOLL_OPT a2)
|
|||
return SRT_EPOLL_OPT( (int)a1 | (int)a2 );
|
||||
}
|
||||
|
||||
inline bool operator&(int flags, SRT_EPOLL_OPT eflg)
|
||||
{
|
||||
// Using an enum prevents treating int automatically as enum,
|
||||
// requires explicit enum to be passed here, and minimizes the
|
||||
// risk that the right side value will contain multiple flags.
|
||||
return (flags & int(eflg)) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct CBytePerfMon SRT_TRACEBSTATS;
|
||||
|
||||
static const SRTSOCKET SRT_INVALID_SOCK = -1;
|
||||
|
@ -605,18 +747,32 @@ SRT_API int srt_cleanup(void);
|
|||
//
|
||||
// Socket operations
|
||||
//
|
||||
SRT_API SRTSOCKET srt_socket (int af, int type, int protocol);
|
||||
SRT_API SRTSOCKET srt_create_socket();
|
||||
// DEPRECATED: srt_socket with 3 arguments. All these arguments are ignored
|
||||
// and socket creation doesn't need any arguments. Use srt_create_socket().
|
||||
// Planned deprecation removal: rel1.6.0
|
||||
SRT_ATR_DEPRECATED_PX SRT_API SRTSOCKET srt_socket(int, int, int) SRT_ATR_DEPRECATED;
|
||||
SRT_API SRTSOCKET srt_create_socket(void);
|
||||
|
||||
SRT_API int srt_bind (SRTSOCKET u, const struct sockaddr* name, int namelen);
|
||||
SRT_API int srt_bind_peerof (SRTSOCKET u, UDPSOCKET udpsock);
|
||||
SRT_API int srt_bind_acquire (SRTSOCKET u, UDPSOCKET sys_udp_sock);
|
||||
// Old name of srt_bind_acquire(), please don't use
|
||||
// Planned deprecation removal: rel1.6.0
|
||||
SRT_ATR_DEPRECATED_PX static inline int srt_bind_peerof(SRTSOCKET u, UDPSOCKET sys_udp_sock) SRT_ATR_DEPRECATED;
|
||||
static inline int srt_bind_peerof (SRTSOCKET u, UDPSOCKET sys_udp_sock) { return srt_bind_acquire(u, sys_udp_sock); }
|
||||
SRT_API int srt_listen (SRTSOCKET u, int backlog);
|
||||
SRT_API SRTSOCKET srt_accept (SRTSOCKET u, struct sockaddr* addr, int* addrlen);
|
||||
SRT_API SRTSOCKET srt_accept_bond (const SRTSOCKET listeners[], int lsize, int64_t msTimeOut);
|
||||
typedef int srt_listen_callback_fn (void* opaq, SRTSOCKET ns, int hsversion, const struct sockaddr* peeraddr, const char* streamid);
|
||||
SRT_API int srt_listen_callback(SRTSOCKET lsn, srt_listen_callback_fn* hook_fn, void* hook_opaque);
|
||||
typedef void srt_connect_callback_fn (void* opaq, SRTSOCKET ns, int errorcode, const struct sockaddr* peeraddr, int token);
|
||||
SRT_API int srt_connect_callback(SRTSOCKET clr, srt_connect_callback_fn* hook_fn, void* hook_opaque);
|
||||
SRT_API int srt_connect (SRTSOCKET u, const struct sockaddr* name, int namelen);
|
||||
SRT_API int srt_connect_debug(SRTSOCKET u, const struct sockaddr* name, int namelen, int forced_isn);
|
||||
SRT_API int srt_connect_bind (SRTSOCKET u, const struct sockaddr* source,
|
||||
const struct sockaddr* target, int len);
|
||||
SRT_API int srt_rendezvous (SRTSOCKET u, const struct sockaddr* local_name, int local_namelen,
|
||||
const struct sockaddr* remote_name, int remote_namelen);
|
||||
|
||||
SRT_API int srt_close (SRTSOCKET u);
|
||||
SRT_API int srt_getpeername (SRTSOCKET u, struct sockaddr* name, int* namelen);
|
||||
SRT_API int srt_getsockname (SRTSOCKET u, struct sockaddr* name, int* namelen);
|
||||
|
@ -625,19 +781,34 @@ SRT_API int srt_setsockopt (SRTSOCKET u, int level /*ignored*/, SRT_SOCK
|
|||
SRT_API int srt_getsockflag (SRTSOCKET u, SRT_SOCKOPT opt, void* optval, int* optlen);
|
||||
SRT_API int srt_setsockflag (SRTSOCKET u, SRT_SOCKOPT opt, const void* optval, int optlen);
|
||||
|
||||
typedef struct SRT_SocketGroupData_ SRT_SOCKGROUPDATA;
|
||||
|
||||
// XXX Note that the srctime functionality doesn't work yet and needs fixing.
|
||||
typedef struct SRT_MsgCtrl_
|
||||
{
|
||||
int flags; // Left for future
|
||||
int msgttl; // TTL for a message, default -1 (no TTL limitation)
|
||||
int msgttl; // TTL for a message (millisec), default -1 (no TTL limitation)
|
||||
int inorder; // Whether a message is allowed to supersede partially lost one. Unused in stream and live mode.
|
||||
int boundary; // 0:mid pkt, 1(01b):end of frame, 2(11b):complete frame, 3(10b): start of frame
|
||||
uint64_t srctime; // source timestamp (usec), 0: use internal time
|
||||
int64_t srctime; // source time since epoch (usec), 0: use internal time (sender)
|
||||
int32_t pktseq; // sequence number of the first packet in received message (unused for sending)
|
||||
int32_t msgno; // message number (output value for both sending and receiving)
|
||||
SRT_SOCKGROUPDATA* grpdata;
|
||||
size_t grpdata_size;
|
||||
} SRT_MSGCTRL;
|
||||
|
||||
// Trap representation for sequence and message numbers
|
||||
// This value means that this is "unset", and it's never
|
||||
// a result of an operation made on this number.
|
||||
static const int32_t SRT_SEQNO_NONE = -1; // -1: no seq (0 is a valid seqno!)
|
||||
static const int32_t SRT_MSGNO_NONE = -1; // -1: unset
|
||||
static const int32_t SRT_MSGNO_CONTROL = 0; // 0: control (used by packet filter)
|
||||
|
||||
static const int SRT_MSGTTL_INF = -1; // unlimited TTL specification for message TTL
|
||||
|
||||
// XXX Might be useful also other special uses of -1:
|
||||
// - -1 as infinity for srt_epoll_wait
|
||||
// - -1 as a trap index value used in list.cpp
|
||||
|
||||
// You are free to use either of these two methods to set SRT_MSGCTRL object
|
||||
// to default values: either call srt_msgctrl_init(&obj) or obj = srt_msgctrl_default.
|
||||
SRT_API void srt_msgctrl_init(SRT_MSGCTRL* mctrl);
|
||||
|
@ -657,11 +828,6 @@ SRT_API extern const SRT_MSGCTRL srt_msgctrl_default;
|
|||
// parameters will be filled, as needed. NULL is acceptable, in which case
|
||||
// the defaults are used.
|
||||
|
||||
// NOTE: srt_send and srt_recv have the last "..." left to allow ignore a
|
||||
// deprecated and unused "flags" parameter. After confirming that all
|
||||
// compat applications that pass useless 0 there are fixed, this will be
|
||||
// removed.
|
||||
|
||||
//
|
||||
// Sending functions
|
||||
//
|
||||
|
@ -692,16 +858,17 @@ SRT_API int srt_getlasterror(int* errno_loc);
|
|||
SRT_API const char* srt_strerror(int code, int errnoval);
|
||||
SRT_API void srt_clearlasterror(void);
|
||||
|
||||
// performance track
|
||||
// perfmon with Byte counters for better bitrate estimation.
|
||||
// Performance tracking
|
||||
// Performance monitor with Byte counters for better bitrate estimation.
|
||||
SRT_API int srt_bstats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear);
|
||||
// permon with Byte counters and instantaneous stats instead of moving averages for Snd/Rcvbuffer sizes.
|
||||
// Performance monitor with Byte counters and instantaneous stats instead of moving averages for Snd/Rcvbuffer sizes.
|
||||
SRT_API int srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous);
|
||||
|
||||
// Socket Status (for problem tracking)
|
||||
SRT_API SRT_SOCKSTATUS srt_getsockstate(SRTSOCKET u);
|
||||
|
||||
SRT_API int srt_epoll_create(void);
|
||||
SRT_API int srt_epoll_clear_usocks(int eid);
|
||||
SRT_API int srt_epoll_add_usock(int eid, SRTSOCKET u, const int* events);
|
||||
SRT_API int srt_epoll_add_ssock(int eid, SYSSOCKET s, const int* events);
|
||||
SRT_API int srt_epoll_remove_usock(int eid, SRTSOCKET u);
|
||||
|
@ -711,10 +878,14 @@ SRT_API int srt_epoll_update_ssock(int eid, SYSSOCKET s, const int* events);
|
|||
|
||||
SRT_API int srt_epoll_wait(int eid, SRTSOCKET* readfds, int* rnum, SRTSOCKET* writefds, int* wnum, int64_t msTimeOut,
|
||||
SYSSOCKET* lrfds, int* lrnum, SYSSOCKET* lwfds, int* lwnum);
|
||||
typedef struct SRT_EPOLL_EVENT_
|
||||
typedef struct SRT_EPOLL_EVENT_STR
|
||||
{
|
||||
SRTSOCKET fd;
|
||||
int events; // SRT_EPOLL_IN | SRT_EPOLL_OUT | SRT_EPOLL_ERR
|
||||
#ifdef __cplusplus
|
||||
SRT_EPOLL_EVENT_STR(SRTSOCKET s, int ev): fd(s), events(ev) {}
|
||||
SRT_EPOLL_EVENT_STR(): fd(-1), events(0) {} // NOTE: allows singular values, no init.
|
||||
#endif
|
||||
} SRT_EPOLL_EVENT;
|
||||
SRT_API int srt_epoll_uwait(int eid, SRT_EPOLL_EVENT* fdsSet, int fdsSize, int64_t msTimeOut);
|
||||
|
||||
|
@ -736,9 +907,88 @@ SRT_API void srt_setlogflags(int flags);
|
|||
|
||||
SRT_API int srt_getsndbuffer(SRTSOCKET sock, size_t* blocks, size_t* bytes);
|
||||
|
||||
SRT_API enum SRT_REJECT_REASON srt_getrejectreason(SRTSOCKET sock);
|
||||
SRT_API extern const char* const srt_rejectreason_msg [];
|
||||
const char* srt_rejectreason_str(enum SRT_REJECT_REASON id);
|
||||
SRT_API int srt_getrejectreason(SRTSOCKET sock);
|
||||
SRT_API int srt_setrejectreason(SRTSOCKET sock, int value);
|
||||
// The srt_rejectreason_msg[] array is deprecated (as unsafe).
|
||||
// Planned removal: v1.6.0.
|
||||
SRT_API SRT_ATR_DEPRECATED extern const char* const srt_rejectreason_msg [];
|
||||
SRT_API const char* srt_rejectreason_str(int id);
|
||||
|
||||
SRT_API uint32_t srt_getversion(void);
|
||||
|
||||
SRT_API int64_t srt_time_now(void);
|
||||
|
||||
SRT_API int64_t srt_connection_time(SRTSOCKET sock);
|
||||
|
||||
// Possible internal clock types
|
||||
#define SRT_SYNC_CLOCK_STDCXX_STEADY 0 // C++11 std::chrono::steady_clock
|
||||
#define SRT_SYNC_CLOCK_GETTIME_MONOTONIC 1 // clock_gettime with CLOCK_MONOTONIC
|
||||
#define SRT_SYNC_CLOCK_WINQPC 2
|
||||
#define SRT_SYNC_CLOCK_MACH_ABSTIME 3
|
||||
#define SRT_SYNC_CLOCK_POSIX_GETTIMEOFDAY 4
|
||||
#define SRT_SYNC_CLOCK_AMD64_RDTSC 5
|
||||
#define SRT_SYNC_CLOCK_IA32_RDTSC 6
|
||||
#define SRT_SYNC_CLOCK_IA64_ITC 7
|
||||
|
||||
SRT_API int srt_clock_type(void);
|
||||
|
||||
// SRT Socket Groups API (ENABLE_BONDING)
|
||||
|
||||
typedef enum SRT_GROUP_TYPE
|
||||
{
|
||||
SRT_GTYPE_UNDEFINED,
|
||||
SRT_GTYPE_BROADCAST,
|
||||
SRT_GTYPE_BACKUP,
|
||||
// ...
|
||||
SRT_GTYPE_E_END
|
||||
} SRT_GROUP_TYPE;
|
||||
|
||||
// Free-form flags for groups
|
||||
// Flags may be type-specific!
|
||||
static const uint32_t SRT_GFLAG_SYNCONMSG = 1;
|
||||
|
||||
typedef enum SRT_MemberStatus
|
||||
{
|
||||
SRT_GST_PENDING, // The socket is created correctly, but not yet ready for getting data.
|
||||
SRT_GST_IDLE, // The socket is ready to be activated
|
||||
SRT_GST_RUNNING, // The socket was already activated and is in use
|
||||
SRT_GST_BROKEN // The last operation broke the socket, it should be closed.
|
||||
} SRT_MEMBERSTATUS;
|
||||
|
||||
struct SRT_SocketGroupData_
|
||||
{
|
||||
SRTSOCKET id;
|
||||
struct sockaddr_storage peeraddr; // Don't want to expose sockaddr_any to public API
|
||||
SRT_SOCKSTATUS sockstate;
|
||||
uint16_t weight;
|
||||
SRT_MEMBERSTATUS memberstate;
|
||||
int result;
|
||||
int token;
|
||||
};
|
||||
|
||||
typedef struct SRT_SocketOptionObject SRT_SOCKOPT_CONFIG;
|
||||
|
||||
typedef struct SRT_GroupMemberConfig_
|
||||
{
|
||||
SRTSOCKET id;
|
||||
struct sockaddr_storage srcaddr;
|
||||
struct sockaddr_storage peeraddr; // Don't want to expose sockaddr_any to public API
|
||||
uint16_t weight;
|
||||
SRT_SOCKOPT_CONFIG* config;
|
||||
int errorcode;
|
||||
int token;
|
||||
} SRT_SOCKGROUPCONFIG;
|
||||
|
||||
SRT_API SRTSOCKET srt_create_group(SRT_GROUP_TYPE);
|
||||
SRT_API SRTSOCKET srt_groupof(SRTSOCKET socket);
|
||||
SRT_API int srt_group_data(SRTSOCKET socketgroup, SRT_SOCKGROUPDATA* output, size_t* inoutlen);
|
||||
|
||||
SRT_API SRT_SOCKOPT_CONFIG* srt_create_config(void);
|
||||
SRT_API void srt_delete_config(SRT_SOCKOPT_CONFIG* config /*nullable*/);
|
||||
SRT_API int srt_config_add(SRT_SOCKOPT_CONFIG* config, SRT_SOCKOPT option, const void* contents, int len);
|
||||
|
||||
SRT_API SRT_SOCKGROUPCONFIG srt_prepare_endpoint(const struct sockaddr* src /*nullable*/, const struct sockaddr* adr, int namelen);
|
||||
SRT_API int srt_connect_group(SRTSOCKET group, SRT_SOCKGROUPCONFIG name[], int arraysize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue