FFmpeg  4.0
Data Structures | Macros | Enumerations | Functions | Variables
libsrt.c File Reference

Haivision Open SRT (Secure Reliable Transport) protocol. More...

#include <srt/srt.h>
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/time.h"
#include "avformat.h"
#include "internal.h"
#include "network.h"
#include "os_support.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  SRTContext
 

Macros

#define D   AV_OPT_FLAG_DECODING_PARAM
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 
#define OFFSET(x)   offsetof(SRTContext, x)
 

Enumerations

enum  SRTMode { SRT_MODE_CALLER = 0, SRT_MODE_LISTENER = 1, SRT_MODE_RENDEZVOUS = 2 }
 

Functions

static int libsrt_neterrno (URLContext *h)
 
static int libsrt_socket_nonblock (int socket, int enable)
 
static int libsrt_network_wait_fd (URLContext *h, int eid, int fd, int write)
 
static int libsrt_network_wait_fd_timeout (URLContext *h, int eid, int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
 
static int libsrt_listen (int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, URLContext *h, int timeout)
 
static int libsrt_listen_connect (int eid, int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next)
 
static int libsrt_setsockopt (URLContext *h, int fd, SRT_SOCKOPT optname, const char *optnamestr, const void *optval, int optlen)
 
static int libsrt_set_options_post (URLContext *h, int fd)
 
static int libsrt_set_options_pre (URLContext *h, int fd)
 
static int libsrt_setup (URLContext *h, const char *uri, int flags)
 
static int libsrt_open (URLContext *h, const char *uri, int flags)
 
static int libsrt_read (URLContext *h, uint8_t *buf, int size)
 
static int libsrt_write (URLContext *h, const uint8_t *buf, int size)
 
static int libsrt_close (URLContext *h)
 
static int libsrt_get_file_handle (URLContext *h)
 

Variables

static const AVOption libsrt_options []
 
static const AVClass libsrt_class
 
const URLProtocol ff_libsrt_protocol
 

Detailed Description

Haivision Open SRT (Secure Reliable Transport) protocol.

Definition in file libsrt.c.

Macro Definition Documentation

◆ D

Definition at line 68 of file libsrt.c.

◆ E

Definition at line 69 of file libsrt.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(SRTContext, x)

Definition at line 70 of file libsrt.c.

Enumeration Type Documentation

◆ SRTMode

enum SRTMode
Enumerator
SRT_MODE_CALLER 
SRT_MODE_LISTENER 
SRT_MODE_RENDEZVOUS 

Definition at line 37 of file libsrt.c.

Function Documentation

◆ libsrt_neterrno()

static int libsrt_neterrno ( URLContext h)
static

◆ libsrt_socket_nonblock()

static int libsrt_socket_nonblock ( int  socket,
int  enable 
)
static

Definition at line 105 of file libsrt.c.

Referenced by libsrt_listen(), and libsrt_listen_connect().

◆ libsrt_network_wait_fd()

static int libsrt_network_wait_fd ( URLContext h,
int  eid,
int  fd,
int  write 
)
static

Definition at line 113 of file libsrt.c.

Referenced by libsrt_network_wait_fd_timeout().

◆ libsrt_network_wait_fd_timeout()

static int libsrt_network_wait_fd_timeout ( URLContext h,
int  eid,
int  fd,
int  write,
int64_t  timeout,
AVIOInterruptCB int_cb 
)
static

Definition at line 141 of file libsrt.c.

Referenced by libsrt_listen(), libsrt_listen_connect(), libsrt_read(), and libsrt_write().

◆ libsrt_listen()

static int libsrt_listen ( int  eid,
int  fd,
const struct sockaddr *  addr,
socklen_t  addrlen,
URLContext h,
int  timeout 
)
static

Definition at line 161 of file libsrt.c.

Referenced by libsrt_setup().

◆ libsrt_listen_connect()

static int libsrt_listen_connect ( int  eid,
int  fd,
const struct sockaddr *  addr,
socklen_t  addrlen,
int  timeout,
URLContext h,
int  will_try_next 
)
static

Definition at line 194 of file libsrt.c.

Referenced by libsrt_setup().

◆ libsrt_setsockopt()

static int libsrt_setsockopt ( URLContext h,
int  fd,
SRT_SOCKOPT  optname,
const char *  optnamestr,
const void optval,
int  optlen 
)
static

Definition at line 234 of file libsrt.c.

Referenced by libsrt_set_options_post(), and libsrt_set_options_pre().

◆ libsrt_set_options_post()

static int libsrt_set_options_post ( URLContext h,
int  fd 
)
static

Definition at line 247 of file libsrt.c.

Referenced by libsrt_setup().

◆ libsrt_set_options_pre()

static int libsrt_set_options_pre ( URLContext h,
int  fd 
)
static

Definition at line 261 of file libsrt.c.

Referenced by libsrt_setup().

◆ libsrt_setup()

static int libsrt_setup ( URLContext h,
const char *  uri,
int  flags 
)
static

Definition at line 286 of file libsrt.c.

Referenced by libsrt_open().

◆ libsrt_open()

static int libsrt_open ( URLContext h,
const char *  uri,
int  flags 
)
static

Definition at line 405 of file libsrt.c.

◆ libsrt_read()

static int libsrt_read ( URLContext h,
uint8_t buf,
int  size 
)
static

Definition at line 472 of file libsrt.c.

◆ libsrt_write()

static int libsrt_write ( URLContext h,
const uint8_t buf,
int  size 
)
static

Definition at line 491 of file libsrt.c.

◆ libsrt_close()

static int libsrt_close ( URLContext h)
static

Definition at line 510 of file libsrt.c.

◆ libsrt_get_file_handle()

static int libsrt_get_file_handle ( URLContext h)
static

Definition at line 523 of file libsrt.c.

Variable Documentation

◆ libsrt_options

const AVOption libsrt_options[]
static
Initial value:
= {
{ "rw_timeout", "Timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "listen_timeout", "Connection awaiting timeout", OFFSET(listen_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "recv_buffer_size", "Socket receive buffer size (in bytes)", OFFSET(recv_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "maxbw", "Maximum bandwidth (bytes per second) that the connection can use", OFFSET(maxbw), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "pbkeylen", "Crypto key len in bytes {16,24,32} Default: 16 (128-bit)", OFFSET(pbkeylen), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 32, .flags = D|E },
{ "passphrase", "Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto", OFFSET(passphrase), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
{ "mss", "The Maximum Segment Size", OFFSET(mss), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1500, .flags = D|E },
{ "ffs", "Flight flag size (window size) (in bytes)", OFFSET(ffs), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "ipttl", "IP Time To Live", OFFSET(ipttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E },
{ "iptos", "IP Type of Service", OFFSET(iptos), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E },
{ "inputbw", "Estimated input stream rate", OFFSET(inputbw), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "oheadbw", "MaxBW ceiling based on % over input stream rate", OFFSET(oheadbw), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 100, .flags = D|E },
{ "tsbpddelay", "TsbPd receiver delay to absorb burst of missed packet retransmission", OFFSET(tsbpddelay), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "tlpktdrop", "Enable receiver pkt drop", OFFSET(tlpktdrop), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E },
{ "nakreport", "Enable receiver to send periodic NAK reports", OFFSET(nakreport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E },
{ "connect_timeout", "Connect timeout. Caller default: 3000, rendezvous (x 10)", OFFSET(connect_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "mode", "Connection mode (caller, listener, rendezvous)", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = SRT_MODE_CALLER }, SRT_MODE_CALLER, SRT_MODE_RENDEZVOUS, .flags = D|E, "mode" },
{ "caller", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_CALLER }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
{ "listener", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_LISTENER }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
{ "rendezvous", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRT_MODE_RENDEZVOUS }, INT_MIN, INT_MAX, .flags = D|E, "mode" },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define D
Definition: libsrt.c:68
#define OFFSET(x)
Definition: libsrt.c:70
#define E
Definition: libsrt.c:69
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83

Definition at line 71 of file libsrt.c.

◆ libsrt_class

const AVClass libsrt_class
static
Initial value:
= {
.class_name = "libsrt",
.item_name = av_default_item_name,
.option = libsrt_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption libsrt_options[]
Definition: libsrt.c:71

Definition at line 529 of file libsrt.c.

◆ ff_libsrt_protocol

const URLProtocol ff_libsrt_protocol
Initial value:
= {
.name = "srt",
.url_open = libsrt_open,
.url_read = libsrt_read,
.url_write = libsrt_write,
.url_close = libsrt_close,
.url_get_file_handle = libsrt_get_file_handle,
.priv_data_size = sizeof(SRTContext),
.priv_data_class = &libsrt_class,
}
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:34
static int libsrt_open(URLContext *h, const char *uri, int flags)
Definition: libsrt.c:405
static int flags
Definition: log.c:55
static const AVClass libsrt_class
Definition: libsrt.c:529
static int libsrt_read(URLContext *h, uint8_t *buf, int size)
Definition: libsrt.c:472
static int libsrt_get_file_handle(URLContext *h)
Definition: libsrt.c:523
static int libsrt_write(URLContext *h, const uint8_t *buf, int size)
Definition: libsrt.c:491
static int libsrt_close(URLContext *h)
Definition: libsrt.c:510

Definition at line 536 of file libsrt.c.