24 #define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__)))
35 #include <openssl/ssl.h>
36 static int openssl_init;
38 #include <openssl/crypto.h>
41 static void openssl_lock(
int mode,
int type,
const char *file,
int line)
43 if (mode & CRYPTO_LOCK)
48 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
49 static unsigned long openssl_thread_id(
void)
51 return (intptr_t) pthread_self();
57 #include <gnutls/gnutls.h>
58 #if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
63 GCRY_THREAD_OPTION_PTHREAD_IMPL;
73 SSL_load_error_strings();
75 if (!CRYPTO_get_locking_callback()) {
78 for (i = 0; i < CRYPTO_num_locks(); i++)
80 CRYPTO_set_locking_callback(openssl_lock);
81 #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
82 CRYPTO_set_id_callback(openssl_thread_id);
90 #if THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
91 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
92 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
106 if (CRYPTO_get_locking_callback() == openssl_lock) {
108 CRYPTO_set_locking_callback(
NULL);
109 for (i = 0; i < CRYPTO_num_locks(); i++)
117 gnutls_global_deinit();
130 if (!ff_network_inited_globally)
132 "network initialization. Please use "
133 "avformat_network_init(), this will "
134 "become mandatory later.\n");
136 if (WSAStartup(MAKEWORD(1,1), &wsaData))
144 int ev = write ? POLLOUT : POLLIN;
145 struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
147 ret = poll(&p, 1, 100);
148 return ret < 0 ?
ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 :
AVERROR(EAGAIN);
161 int err = WSAGetLastError();
174 if (addr->sa_family == AF_INET) {
175 return IN_MULTICAST(ntohl(((
struct sockaddr_in *)addr)->sin_addr.s_addr));
177 #if HAVE_STRUCT_SOCKADDR_IN6
178 if (addr->sa_family == AF_INET6) {