FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
network.c File Reference
#include <fcntl.h>
#include "network.h"
#include "tls.h"
#include "url.h"
#include "libavcodec/internal.h"
#include "libavutil/avutil.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"

Go to the source code of this file.

Functions

int ff_tls_init (void)
 
void ff_tls_deinit (void)
 
int ff_network_init (void)
 
int ff_network_wait_fd (int fd, int write)
 
int ff_network_wait_fd_timeout (int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
 This works similarly to ff_network_wait_fd, but waits up to 'timeout' microseconds Uses ff_network_wait_fd in a loop. More...
 
void ff_network_close (void)
 
int ff_is_multicast_address (struct sockaddr *addr)
 
static int ff_poll_interrupt (struct pollfd *p, nfds_t nfds, int timeout, AVIOInterruptCB *cb)
 
int ff_socket (int af, int type, int proto)
 
int ff_listen (int fd, const struct sockaddr *addr, socklen_t addrlen)
 Bind to a file descriptor to an address without accepting connections. More...
 
int ff_accept (int fd, int timeout, URLContext *h)
 Poll for a single connection on the passed file descriptor. More...
 
int ff_listen_bind (int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h)
 Bind to a file descriptor and poll for a connection. More...
 
int ff_listen_connect (int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next)
 Connect to a file descriptor and poll for result. More...
 
static int match_host_pattern (const char *pattern, const char *hostname)
 
int ff_http_match_no_proxy (const char *no_proxy, const char *hostname)
 

Variables

int ff_network_inited_globally
 

Function Documentation

int ff_tls_init ( void  )

Definition at line 30 of file network.c.

Referenced by avformat_network_init().

void ff_tls_deinit ( void  )

Definition at line 43 of file network.c.

Referenced by avformat_network_deinit().

int ff_network_init ( void  )
int ff_network_wait_fd ( int  fd,
int  write 
)
int ff_network_wait_fd_timeout ( int  fd,
int  write,
int64_t  timeout,
AVIOInterruptCB int_cb 
)

This works similarly to ff_network_wait_fd, but waits up to 'timeout' microseconds Uses ff_network_wait_fd in a loop.

Socket descriptor Set 1 to wait for socket able to be read, 0 to be written Timeout interval, in microseconds. Actual precision is 100000 mcs, due to ff_network_wait_fd usage

Parameters
int_cbInterrupt callback, is checked before each ff_network_wait_fd call
Returns
0 if data can be read/written, AVERROR(ETIMEDOUT) if timeout expired, or negative error code

Definition at line 82 of file network.c.

Referenced by tcp_read(), and tcp_write().

void ff_network_close ( void  )
int ff_is_multicast_address ( struct sockaddr *  addr)

Definition at line 131 of file network.c.

Referenced by ff_udp_set_remote_url().

static int ff_poll_interrupt ( struct pollfd *  p,
nfds_t  nfds,
int  timeout,
AVIOInterruptCB cb 
)
static

Definition at line 145 of file network.c.

Referenced by ff_accept(), and ff_listen_connect().

int ff_socket ( int  af,
int  type,
int  proto 
)

Definition at line 166 of file network.c.

Referenced by sctp_open(), tcp_open(), udp_socket_create(), and unix_open().

int ff_listen ( int  fd,
const struct sockaddr *  addr,
socklen_t  addrlen 
)

Bind to a file descriptor to an address without accepting connections.

Parameters
fdFirst argument of bind().
addrSecond argument of bind().
addrlenThird argument of bind().
Returns
0 on success or an AVERROR on failure.

Definition at line 190 of file network.c.

Referenced by ff_listen_bind(), and tcp_open().

int ff_accept ( int  fd,
int  timeout,
URLContext h 
)

Poll for a single connection on the passed file descriptor.

Parameters
fdThe listening socket file descriptor.
timeoutPolling timeout in milliseconds.
hURLContext providing interrupt check callback and logging context.
Returns
A non-blocking file descriptor on success or an AVERROR on failure.

Definition at line 208 of file network.c.

Referenced by ff_listen_bind(), and tcp_accept().

int ff_listen_bind ( int  fd,
const struct sockaddr *  addr,
socklen_t  addrlen,
int  timeout,
URLContext h 
)

Bind to a file descriptor and poll for a connection.

Parameters
fdFirst argument of bind().
addrSecond argument of bind().
addrlenThird argument of bind().
timeoutPolling timeout in milliseconds.
hURLContext providing interrupt check callback and logging context.
Returns
A non-blocking file descriptor on success or an AVERROR on failure.

Definition at line 226 of file network.c.

Referenced by sctp_open(), tcp_open(), and unix_open().

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

Connect to a file descriptor and poll for result.

Parameters
fdFirst argument of connect(), will be set as non-blocking.
addrSecond argument of connect().
addrlenThird argument of connect().
timeoutPolling timeout in milliseconds.
hURLContext providing interrupt check callback and logging context.
will_try_nextWhether the caller will try to connect to another address for the same host name, affecting the form of logged errors.
Returns
0 on success, AVERROR on failure.

Definition at line 238 of file network.c.

Referenced by sctp_open(), tcp_open(), and unix_open().

static int match_host_pattern ( const char *  pattern,
const char *  hostname 
)
static

Definition at line 283 of file network.c.

Referenced by ff_http_match_no_proxy().

int ff_http_match_no_proxy ( const char *  no_proxy,
const char *  hostname 
)

Definition at line 307 of file network.c.

Referenced by ff_tls_open_underlying(), http_open_cnx_internal(), and test().

Variable Documentation

int ff_network_inited_globally

Definition at line 53 of file network.c.

Referenced by avformat_network_deinit(), avformat_network_init(), and ff_network_init().