FFmpeg
Data Structures | Macros | Functions | Variables
rtpproto.c File Reference

RTP protocol. More...

#include "libavutil/parseutils.h"
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "avio_internal.h"
#include "rtp.h"
#include "rtpproto.h"
#include "url.h"
#include "ip.h"
#include <stdarg.h>
#include "internal.h"
#include "network.h"
#include "os_support.h"
#include <fcntl.h>

Go to the source code of this file.

Data Structures

struct  RTPContext
 

Macros

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

Functions

int ff_rtp_set_remote_url (URLContext *h, const char *uri)
 If no filename is given to av_open_input_file because you want to get the local port first, then you must call this function to set the remote server address. More...
 
static int get_port (const struct sockaddr_storage *ss)
 
static void set_port (struct sockaddr_storage *ss, int port)
 
static av_printf_format (3, 4)
 add option to url of the form: "http://host:port/path?option1=val1&option2=val2... More...
 
static void build_udp_url (RTPContext *s, char *buf, int buf_size, const char *hostname, int port, int local_port, const char *include_sources, const char *exclude_sources)
 
static int rtp_open (URLContext *h, const char *uri, int flags)
 url syntax: rtp://host:port[?option=val...] option: 'ttl=n' : set the ttl value (for multicast only) 'rtcpport=n' : set the remote rtcp port to n 'localrtpport=n' : set the local rtp port to n 'localrtcpport=n' : set the local rtcp port to n 'pkt_size=n' : set max packet size 'connect=0/1' : do a connect() on the UDP socket 'sources=ip[,ip]' : list allowed source IP addresses 'block=ip[,ip]' : list disallowed source IP addresses 'write_to_source=0/1' : send packets to the source address of the latest received packet 'dscp=n' : set DSCP value to n (QoS) deprecated option: 'localport=n' : set the local port to n More...
 
static int rtp_read (URLContext *h, uint8_t *buf, int size)
 
static int rtp_write (URLContext *h, const uint8_t *buf, int size)
 
static int rtp_close (URLContext *h)
 
int ff_rtp_get_local_rtp_port (URLContext *h)
 Return the local rtp port used by the RTP connection. More...
 
static int rtp_get_file_handle (URLContext *h)
 Return the local rtcp port used by the RTP connection. More...
 
static int rtp_get_multi_file_handle (URLContext *h, int **handles, int *numhandles)
 

Variables

static const AVOption options []
 
static const AVClass rtp_class
 
const URLProtocol ff_rtp_protocol
 

Detailed Description

RTP protocol.

Definition in file rtpproto.c.

Macro Definition Documentation

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

Definition at line 66 of file rtpproto.c.

Definition at line 67 of file rtpproto.c.

Definition at line 68 of file rtpproto.c.

Function Documentation

int ff_rtp_set_remote_url ( URLContext h,
const char *  uri 
)

If no filename is given to av_open_input_file because you want to get the local port first, then you must call this function to set the remote server address.

Parameters
hmedia file context
uriof the remote server
Returns
zero if no error.

Definition at line 103 of file rtpproto.c.

Referenced by ff_rtsp_open_transport_ctx().

static int get_port ( const struct sockaddr_storage ss)
static

Definition at line 132 of file rtpproto.c.

Referenced by rtp_write().

static void set_port ( struct sockaddr_storage ss,
int  port 
)
static

Definition at line 143 of file rtpproto.c.

Referenced by rtp_write().

static av_printf_format ( ,
 
)
static

add option to url of the form: "http://host:port/path?option1=val1&option2=val2...

Definition at line 158 of file rtpproto.c.

static void build_udp_url ( RTPContext s,
char *  buf,
int  buf_size,
const char *  hostname,
int  port,
int  local_port,
const char *  include_sources,
const char *  exclude_sources 
)
static

Definition at line 173 of file rtpproto.c.

Referenced by rtp_open().

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

url syntax: rtp://host:port[?option=val...] option: 'ttl=n' : set the ttl value (for multicast only) 'rtcpport=n' : set the remote rtcp port to n 'localrtpport=n' : set the local rtp port to n 'localrtcpport=n' : set the local rtcp port to n 'pkt_size=n' : set max packet size 'connect=0/1' : do a connect() on the UDP socket 'sources=ip[,ip]' : list allowed source IP addresses 'block=ip[,ip]' : list disallowed source IP addresses 'write_to_source=0/1' : send packets to the source address of the latest received packet 'dscp=n' : set DSCP value to n (QoS) deprecated option: 'localport=n' : set the local port to n

if rtcpport isn't set the rtcp port will be the rtp port + 1 if local rtp port isn't set any available port will be used for the local rtp and rtcp ports if the local rtcp port is not set it will be the local rtp port + 1

Definition at line 221 of file rtpproto.c.

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

Definition at line 380 of file rtpproto.c.

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

Definition at line 424 of file rtpproto.c.

static int rtp_close ( URLContext h)
static

Definition at line 510 of file rtpproto.c.

int ff_rtp_get_local_rtp_port ( URLContext h)

Return the local rtp port used by the RTP connection.

Parameters
hmedia file context
Returns
the local port number

Definition at line 528 of file rtpproto.c.

Referenced by ff_rtsp_open_transport_ctx(), and rtsp_read_setup().

static int rtp_get_file_handle ( URLContext h)
static

Return the local rtcp port used by the RTP connection.

Parameters
hmedia file context
Returns
the local port number

Definition at line 540 of file rtpproto.c.

static int rtp_get_multi_file_handle ( URLContext h,
int **  handles,
int numhandles 
)
static

Definition at line 546 of file rtpproto.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "ttl", "Time to live (in milliseconds, multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "buffer_size", "Send/Receive buffer size (in bytes)", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "rtcp_port", "Custom rtcp port", OFFSET(rtcp_port), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "local_rtpport", "Local rtp port", OFFSET(local_rtpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "local_rtcpport", "Local rtcp port", OFFSET(local_rtcpport), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "connect", "Connect socket", OFFSET(connect), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
{ "write_to_source", "Send packets to the source address of the latest received packet", OFFSET(write_to_source), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = D|E },
{ "pkt_size", "Maximum packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "dscp", "DSCP class", OFFSET(dscp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E },
{ "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, .flags = D|E },
{ "sources", "Source list", OFFSET(sources), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
{ "block", "Block list", OFFSET(block), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E },
{ "fec", "FEC", OFFSET(fec_options_str), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = E },
{ NULL }
}
#define NULL
Definition: coverity.c:32
Note except for filters that can have queued frames and sources
The exact code depends on how similar the blocks are and how related they are to the block
#define D
Definition: rtpproto.c:67
#define OFFSET(x)
Definition: rtpproto.c:66
#define E
Definition: rtpproto.c:68

Definition at line 69 of file rtpproto.c.

const AVClass rtp_class
static
Initial value:
= {
.class_name = "rtp",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
static const AVOption options[]
Definition: rtpproto.c:69

Definition at line 86 of file rtpproto.c.

const URLProtocol ff_rtp_protocol
Initial value:
= {
.name = "rtp",
.url_open = rtp_open,
.url_read = rtp_read,
.url_write = rtp_write,
.url_close = rtp_close,
.url_get_file_handle = rtp_get_file_handle,
.url_get_multi_file_handle = rtp_get_multi_file_handle,
.priv_data_size = sizeof(RTPContext),
.priv_data_class = &rtp_class,
}
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:34
static int rtp_write(URLContext *h, const uint8_t *buf, int size)
Definition: rtpproto.c:424
static int rtp_close(URLContext *h)
Definition: rtpproto.c:510
static int rtp_read(URLContext *h, uint8_t *buf, int size)
Definition: rtpproto.c:380
static const AVClass rtp_class
Definition: rtpproto.c:86
static int rtp_open(URLContext *h, const char *uri, int flags)
url syntax: rtp://host:port[?option=val...] option: &#39;ttl=n&#39; : set the ttl value (for multicast only) ...
Definition: rtpproto.c:221
static int rtp_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Definition: rtpproto.c:546
#define flags(name, subs,...)
Definition: cbs_av1.c:560
static int rtp_get_file_handle(URLContext *h)
Return the local rtcp port used by the RTP connection.
Definition: rtpproto.c:540

Definition at line 559 of file rtpproto.c.