FFmpeg
|
#include <fcntl.h>
#include "network.h"
#include "tls.h"
#include "url.h"
#include "libavcodec/internal.h"
#include "libavutil/avutil.h"
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"
Go to the source code of this file.
Data Structures | |
struct | ConnectionAttempt |
Macros | |
#define | NEXT_ATTEMPT_DELAY_MS 200 |
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... | |
int | ff_network_sleep_interruptible (int64_t timeout, AVIOInterruptCB *int_cb) |
Waits for up to 'timeout' microseconds. 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 void | interleave_addrinfo (struct addrinfo *base) |
static void | print_address_list (void *ctx, const struct addrinfo *addr, const char *title) |
static int | start_connect_attempt (struct ConnectionAttempt *attempt, struct addrinfo **ptr, int timeout_ms, URLContext *h, void(*customize_fd)(void *, int), void *customize_ctx) |
int | ff_connect_parallel (struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, void(*customize_fd)(void *, int), void *customize_ctx) |
Connect to any of the given addrinfo addresses, with multiple attempts running in parallel. 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) |
void | ff_log_net_error (void *ctx, int level, const char *prefix) |
int ff_tls_init | ( | void | ) |
Definition at line 31 of file network.c.
Referenced by avformat_network_init().
void ff_tls_deinit | ( | void | ) |
Definition at line 46 of file network.c.
Referenced by avformat_network_deinit().
int ff_network_init | ( | void | ) |
Definition at line 58 of file network.c.
Referenced by avformat_network_init(), rtsp_listen(), sap_read_header(), sap_write_header(), and url_alloc_for_protocol().
Definition at line 69 of file network.c.
Referenced by ff_network_wait_fd_timeout(), rtp_write(), udp_read(), udp_write(), unix_read(), and unix_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.
fd | Socket descriptor |
write | Set 1 to wait for socket able to be read, 0 to be written |
timeout | Timeout interval, in microseconds. Actual precision is 100000 mcs, due to ff_network_wait_fd usage |
int_cb | Interrupt callback, is checked before each ff_network_wait_fd call |
Definition at line 78 of file network.c.
Referenced by amqp_proto_read(), amqp_proto_write(), tcp_read(), and tcp_write().
int ff_network_sleep_interruptible | ( | int64_t | timeout, |
AVIOInterruptCB * | int_cb | ||
) |
Waits for up to 'timeout' microseconds.
If the usert's int_cb is set and triggered, return before that.
timeout | Timeout in microseconds. Maybe have lower actual precision. |
int_cb | Interrupt callback, is checked regularly. |
Definition at line 98 of file network.c.
Referenced by http_open_cnx(), and http_read_stream().
void ff_network_close | ( | void | ) |
Definition at line 116 of file network.c.
Referenced by avformat_network_deinit(), ffurl_closep(), rtsp_listen(), rtsp_read_close(), rtsp_write_close(), sap_read_close(), sap_write_close(), and url_alloc_for_protocol().
int ff_is_multicast_address | ( | struct sockaddr * | addr | ) |
Definition at line 145 of file network.c.
Referenced by ff_udp_set_remote_url().
|
static |
Definition at line 159 of file network.c.
Referenced by ff_accept(), ff_connect_parallel(), and ff_listen_connect().
Definition at line 183 of file network.c.
Referenced by sctp_open(), start_connect_attempt(), tcp_open(), udp_socket_create(), and unix_open().
Bind to a file descriptor to an address without accepting connections.
fd | First argument of bind(). |
addr | Second argument of bind(). |
addrlen | Third argument of bind(). |
Definition at line 210 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.
fd | The listening socket file descriptor. |
timeout | Polling timeout in milliseconds. |
h | URLContext providing interrupt check callback and logging context. |
Definition at line 228 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.
fd | First argument of bind(). |
addr | Second argument of bind(). |
addrlen | Third argument of bind(). |
timeout | Polling timeout in milliseconds. |
h | URLContext providing interrupt check callback and logging context. |
Definition at line 246 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.
fd | First argument of connect(), will be set as non-blocking. |
addr | Second argument of connect(). |
addrlen | Third argument of connect(). |
timeout | Polling timeout in milliseconds. |
h | URLContext providing interrupt check callback and logging context. |
will_try_next | Whether the caller will try to connect to another address for the same host name, affecting the form of logged errors. |
Definition at line 258 of file network.c.
Referenced by sctp_open(), and unix_open().
|
static |
Definition at line 303 of file network.c.
Referenced by ff_connect_parallel().
|
static |
Definition at line 334 of file network.c.
Referenced by ff_connect_parallel().
|
static |
Definition at line 356 of file network.c.
Referenced by ff_connect_parallel().
int ff_connect_parallel | ( | struct addrinfo * | addrs, |
int | timeout_ms_per_address, | ||
int | parallel, | ||
URLContext * | h, | ||
int * | fd, | ||
void(*)(void *, int) | customize_fd, | ||
void * | customize_ctx | ||
) |
Connect to any of the given addrinfo addresses, with multiple attempts running in parallel.
addrs | The list of addresses to try to connect to. This list will be mutated internally, but the list head will remain as such, so this doesn't affect the caller freeing the list afterwards. |
timeout_ms_per_address | The number of milliseconds to wait for each connection attempt. Since multiple addresses are tried, some of them in parallel, the total run time will at most be timeout_ms_per_address*ceil(nb_addrs/parallel) + (parallel - 1) * NEXT_ATTEMPT_DELAY_MS. |
parallel | The maximum number of connections to attempt in parallel. This is limited to an internal maximum capacity. |
h | URLContext providing interrupt check callback and logging context. |
fd | If successful, the connected socket is returned here. |
customize_fd | Function that will be called for each socket created, to allow the caller to set socket options before calling connect() on it, may be NULL. |
customize_ctx | Context parameter passed to customize_fd. |
Definition at line 403 of file network.c.
Referenced by tcp_open().
|
static |
Definition at line 527 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 551 of file network.c.
Referenced by ff_tls_open_underlying(), http_open_cnx_internal(), and test().
void ff_log_net_error | ( | void * | ctx, |
int | level, | ||
const char * | prefix | ||
) |
Definition at line 581 of file network.c.
Referenced by customize_fd(), ff_udp_set_remote_url(), udp_join_multicast_group(), udp_leave_multicast_group(), udp_open(), udp_set_multicast_sources(), udp_set_multicast_ttl(), and udp_socket_create().