21 #ifndef AVFORMAT_NETWORK_H 22 #define AVFORMAT_NETWORK_H 41 #ifndef EPROTONOSUPPORT 42 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT 45 #define ETIMEDOUT WSAETIMEDOUT 48 #define ECONNREFUSED WSAECONNREFUSED 51 #define EINPROGRESS WSAEINPROGRESS 54 #define ENOTCONN WSAENOTCONN 57 #define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e) 58 #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) 62 #include <sys/types.h> 63 #include <sys/socket.h> 64 #include <netinet/in.h> 65 #include <netinet/tcp.h> 68 #define ff_neterrno() AVERROR(errno) 72 #include <arpa/inet.h> 110 #if !HAVE_STRUCT_SOCKADDR_STORAGE 112 #if HAVE_STRUCT_SOCKADDR_SA_LEN 126 struct sockaddr_in
in;
127 #if HAVE_STRUCT_SOCKADDR_IN6 128 struct sockaddr_in6 in6;
133 #define MSG_NOSIGNAL 0 136 #if !HAVE_STRUCT_ADDRINFO 154 #define EAI_BADFLAGS 3 172 #define EAI_SERVICE 9 175 #define EAI_SOCKTYPE 10 183 #define AI_CANONNAME 2 186 #ifndef AI_NUMERICHOST 187 #define AI_NUMERICHOST 4 194 #ifndef NI_NUMERICHOST 195 #define NI_NUMERICHOST 2 202 #ifndef NI_NUMERICSERV 203 #define NI_NUMERICSERV 8 210 #if !HAVE_GETADDRINFO 215 char *host,
int hostlen,
216 char *serv,
int servlen,
int flags);
217 #define getaddrinfo ff_getaddrinfo 218 #define freeaddrinfo ff_freeaddrinfo 219 #define getnameinfo ff_getnameinfo 222 #if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H 225 #define gai_strerror ff_gai_strerror 228 #ifndef INADDR_LOOPBACK 229 #define INADDR_LOOPBACK 0x7f000001 232 #ifndef INET_ADDRSTRLEN 233 #define INET_ADDRSTRLEN 16 236 #ifndef INET6_ADDRSTRLEN 237 #define INET6_ADDRSTRLEN INET_ADDRSTRLEN 241 #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000) 243 #ifndef IN6_IS_ADDR_MULTICAST 244 #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff) 249 #define POLLING_TIME 100 264 socklen_t addrlen,
int timeout,
274 int ff_listen(
int fd,
const struct sockaddr *addr, socklen_t addrlen);
303 socklen_t addrlen,
int timeout,
338 void (*
customize_fd)(
void *,
int),
void *customize_ctx);
static void customize_fd(void *ctx, int fd)
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...
int ff_network_wait_fd(int fd, int write)
int ff_getnameinfo(const struct sockaddr *sa, int salen, char *host, int hostlen, char *serv, int servlen, int flags)
int ff_is_multicast_address(struct sockaddr *addr)
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_wa...
miscellaneous OS support macros and functions.
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
void ff_network_close(void)
Callback for checking whether to abort blocking functions.
const AVIOInterruptCB int_cb
void ff_log_net_error(void *ctx, int level, const char *prefix)
const char * ff_gai_strerror(int ecode)
void ff_freeaddrinfo(struct addrinfo *res)
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.
int ff_socket_nonblock(int socket, int enable)
int ff_accept(int fd, int timeout, URLContext *h)
Poll for a single connection on the passed file descriptor.
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.
int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen)
Bind to a file descriptor to an address without accepting connections.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define flags(name, subs,...)
struct addrinfo * ai_next
int ff_network_init(void)
int ff_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
int ff_socket(int domain, int type, int protocol)
unbuffered private I/O API
int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
Waits for up to 'timeout' microseconds.
struct sockaddr * ai_addr