39 #include <openssl/ssl.h>
40 static int openssl_init;
42 #include <openssl/crypto.h>
45 static void openssl_lock(
int mode,
int type,
const char *file,
int line)
47 if (mode & CRYPTO_LOCK)
52 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
53 static unsigned long openssl_thread_id(
void)
55 return (intptr_t) pthread_self();
61 #include <gnutls/gnutls.h>
62 #if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
65 GCRY_THREAD_OPTION_PTHREAD_IMPL;
75 SSL_load_error_strings();
77 if (!CRYPTO_get_locking_callback()) {
80 for (i = 0; i < CRYPTO_num_locks(); i++)
82 CRYPTO_set_locking_callback(openssl_lock);
83 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
84 CRYPTO_set_id_callback(openssl_thread_id);
92 #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
93 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
94 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
108 if (CRYPTO_get_locking_callback() == openssl_lock) {
110 CRYPTO_set_locking_callback(
NULL);
111 for (i = 0; i < CRYPTO_num_locks(); i++)
119 gnutls_global_deinit();
132 if (!ff_network_inited_globally)
134 "network initialization. Please use "
135 "avformat_network_init(), this will "
136 "become mandatory later.\n");
138 if (WSAStartup(MAKEWORD(1,1), &wsaData))
146 int ev = write ? POLLOUT : POLLIN;
147 struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
149 ret = poll(&p, 1, 100);
150 return ret < 0 ?
ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 :
AVERROR(EAGAIN);
156 int64_t wait_start = 0;
183 int err = WSAGetLastError();
189 case WSAEPROTONOSUPPORT:
190 return AVERROR(EPROTONOSUPPORT);
193 case WSAECONNREFUSED:
204 if (addr->sa_family == AF_INET) {
205 return IN_MULTICAST(ntohl(((
struct sockaddr_in *)addr)->sin_addr.s_addr));
207 #if HAVE_STRUCT_SOCKADDR_IN6
208 if (addr->sa_family == AF_INET6) {