udp.c File Reference

UDP protocol. More...

#include "avformat.h"
#include "avio_internal.h"
#include "libavutil/parseutils.h"
#include "libavutil/avstring.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  UDPContext
 

Macros

#define _BSD_SOURCE   /* Needed for using struct ip_mreq with recent glibc */
 
#define IPV6_ADD_MEMBERSHIP   IPV6_JOIN_GROUP
 
#define IPV6_DROP_MEMBERSHIP   IPV6_LEAVE_GROUP
 
#define UDP_TX_BUF_SIZE   32768
 
#define UDP_MAX_PKT_SIZE   65536
 

Functions

static void log_net_error (void *ctx, int level, const char *prefix)
 
static int udp_set_multicast_ttl (int sockfd, int mcastTTL, struct sockaddr *addr)
 
static int udp_join_multicast_group (int sockfd, struct sockaddr *addr)
 
static int udp_leave_multicast_group (int sockfd, struct sockaddr *addr)
 
static struct addrinfoudp_resolve_host (const char *hostname, int port, int type, int family, int flags)
 
static int udp_set_multicast_sources (int sockfd, struct sockaddr *addr, int addr_len, char **sources, int nb_sources, int include)
 
static int udp_set_url (struct sockaddr_storage *addr, const char *hostname, int port)
 
static int udp_socket_create (UDPContext *s, struct sockaddr_storage *addr, socklen_t *addr_len, const char *localaddr)
 
static int udp_port (struct sockaddr_storage *addr, int addr_len)
 
int ff_udp_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...
 
int ff_udp_get_local_port (URLContext *h)
 Return the local port used by the UDP connection. More...
 
static int udp_get_file_handle (URLContext *h)
 Return the udp file handle for select() usage to wait for several RTP streams at the same time. More...
 
static int udp_open (URLContext *h, const char *uri, int flags)
 
static int udp_read (URLContext *h, uint8_t *buf, int size)
 
static int udp_write (URLContext *h, const uint8_t *buf, int size)
 
static int udp_close (URLContext *h)
 

Variables

URLProtocol ff_udp_protocol
 

Detailed Description

UDP protocol.

Definition in file udp.c.

Macro Definition Documentation

#define _BSD_SOURCE   /* Needed for using struct ip_mreq with recent glibc */

Definition at line 27 of file udp.c.

#define IPV6_ADD_MEMBERSHIP   IPV6_JOIN_GROUP

Definition at line 39 of file udp.c.

Referenced by udp_join_multicast_group().

#define IPV6_DROP_MEMBERSHIP   IPV6_LEAVE_GROUP

Definition at line 40 of file udp.c.

Referenced by udp_leave_multicast_group().

#define UDP_MAX_PKT_SIZE   65536

Definition at line 56 of file udp.c.

Referenced by udp_open().

#define UDP_TX_BUF_SIZE   32768

Definition at line 55 of file udp.c.

Referenced by udp_open().

Function Documentation

int ff_udp_get_local_port ( URLContext h)

Return the local port used by the UDP connection.

Parameters
hmedia file context
Returns
the local port number

Definition at line 364 of file udp.c.

Referenced by ff_rtp_get_local_rtcp_port(), ff_rtp_get_local_rtp_port(), and rtp_open().

int ff_udp_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.

url syntax: udp://host:port[?option=val...] option: 'ttl=n' : set the ttl value (for multicast only) 'localport=n' : set the local port 'pkt_size=n' : set max packet size 'reuse=1' : enable reusing the socket

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

Definition at line 325 of file udp.c.

Referenced by ff_rtp_set_remote_url(), and udp_open().

static void log_net_error ( void ctx,
int  level,
const char *  prefix 
)
static
static int udp_close ( URLContext h)
static

Definition at line 599 of file udp.c.

static int udp_get_file_handle ( URLContext h)
static

Return the udp file handle for select() usage to wait for several RTP streams at the same time.

Parameters
hmedia file context

Definition at line 375 of file udp.c.

static int udp_join_multicast_group ( int  sockfd,
struct sockaddr *  addr 
)
static

Definition at line 87 of file udp.c.

Referenced by udp_open().

static int udp_leave_multicast_group ( int  sockfd,
struct sockaddr *  addr 
)
static

Definition at line 116 of file udp.c.

Referenced by udp_close().

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

Definition at line 383 of file udp.c.

static int udp_port ( struct sockaddr_storage addr,
int  addr_len 
)
static

Definition at line 296 of file udp.c.

Referenced by udp_open().

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

Definition at line 564 of file udp.c.

static struct addrinfo* udp_resolve_host ( const char *  hostname,
int  port,
int  type,
int  family,
int  flags 
)
static

Definition at line 145 of file udp.c.

Referenced by udp_set_multicast_sources(), udp_set_url(), and udp_socket_create().

static int udp_set_multicast_sources ( int  sockfd,
struct sockaddr *  addr,
int  addr_len,
char **  sources,
int  nb_sources,
int  include 
)
static

Definition at line 171 of file udp.c.

Referenced by udp_open().

static int udp_set_multicast_ttl ( int  sockfd,
int  mcastTTL,
struct sockaddr *  addr 
)
static

Definition at line 65 of file udp.c.

Referenced by udp_open().

static int udp_set_url ( struct sockaddr_storage addr,
const char *  hostname,
int  port 
)
static

Definition at line 244 of file udp.c.

Referenced by ff_udp_set_remote_url().

static int udp_socket_create ( UDPContext s,
struct sockaddr_storage addr,
socklen_t *  addr_len,
const char *  localaddr 
)
static

Definition at line 259 of file udp.c.

Referenced by udp_open().

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

Definition at line 578 of file udp.c.

Variable Documentation

URLProtocol ff_udp_protocol
Initial value:
= {
.name = "udp",
.url_open = udp_open,
.url_read = udp_read,
.url_write = udp_write,
.url_close = udp_close,
.url_get_file_handle = udp_get_file_handle,
.priv_data_size = sizeof(UDPContext),
}
static int udp_open(URLContext *h, const char *uri, int flags)
Definition: udp.c:383
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:35
static int flags
Definition: log.c:42
static int udp_close(URLContext *h)
Definition: udp.c:599
static int udp_get_file_handle(URLContext *h)
Return the udp file handle for select() usage to wait for several RTP streams at the same time...
Definition: udp.c:375
Definition: udp.c:43
static int udp_read(URLContext *h, uint8_t *buf, int size)
Definition: udp.c:564
static int udp_write(URLContext *h, const uint8_t *buf, int size)
Definition: udp.c:578

Definition at line 609 of file udp.c.