]> git.sesse.net Git - ffmpeg/blob - libavformat/network.h
lavfi: allow audio filters to request a given number of samples.
[ffmpeg] / libavformat / network.h
1 /*
2  * Copyright (c) 2007 The Libav Project
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVFORMAT_NETWORK_H
22 #define AVFORMAT_NETWORK_H
23
24 #include <errno.h>
25
26 #include "config.h"
27 #include "libavutil/error.h"
28 #include "os_support.h"
29
30 #if HAVE_WINSOCK2_H
31 #include <winsock2.h>
32 #include <ws2tcpip.h>
33
34 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
35 #define ETIMEDOUT       WSAETIMEDOUT
36 #define ECONNREFUSED    WSAECONNREFUSED
37 #define EINPROGRESS     WSAEINPROGRESS
38 #define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
39 #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)
40
41 int ff_neterrno(void);
42 #else
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <netinet/in.h>
46 #include <netdb.h>
47
48 #define ff_neterrno() AVERROR(errno)
49 #endif
50
51 #if HAVE_ARPA_INET_H
52 #include <arpa/inet.h>
53 #endif
54
55 #if HAVE_POLL_H
56 #include <poll.h>
57 #endif
58
59 int ff_socket_nonblock(int socket, int enable);
60
61 extern int ff_network_inited_globally;
62 int ff_network_init(void);
63 void ff_network_close(void);
64
65 void ff_tls_init(void);
66 void ff_tls_deinit(void);
67
68 int ff_network_wait_fd(int fd, int write);
69
70 int ff_inet_aton (const char * str, struct in_addr * add);
71
72 #if !HAVE_STRUCT_SOCKADDR_STORAGE
73 struct sockaddr_storage {
74 #if HAVE_STRUCT_SOCKADDR_SA_LEN
75     uint8_t ss_len;
76     uint8_t ss_family;
77 #else
78     uint16_t ss_family;
79 #endif
80     char ss_pad1[6];
81     int64_t ss_align;
82     char ss_pad2[112];
83 };
84 #endif
85
86 #if !HAVE_STRUCT_ADDRINFO
87 struct addrinfo {
88     int ai_flags;
89     int ai_family;
90     int ai_socktype;
91     int ai_protocol;
92     int ai_addrlen;
93     struct sockaddr *ai_addr;
94     char *ai_canonname;
95     struct addrinfo *ai_next;
96 };
97 #endif
98
99 /* getaddrinfo constants */
100 #ifndef EAI_FAIL
101 #define EAI_FAIL 4
102 #endif
103
104 #ifndef EAI_FAMILY
105 #define EAI_FAMILY 5
106 #endif
107
108 #ifndef EAI_NONAME
109 #define EAI_NONAME 8
110 #endif
111
112 #ifndef AI_PASSIVE
113 #define AI_PASSIVE 1
114 #endif
115
116 #ifndef AI_CANONNAME
117 #define AI_CANONNAME 2
118 #endif
119
120 #ifndef AI_NUMERICHOST
121 #define AI_NUMERICHOST 4
122 #endif
123
124 #ifndef NI_NOFQDN
125 #define NI_NOFQDN 1
126 #endif
127
128 #ifndef NI_NUMERICHOST
129 #define NI_NUMERICHOST 2
130 #endif
131
132 #ifndef NI_NAMERQD
133 #define NI_NAMERQD 4
134 #endif
135
136 #ifndef NI_NUMERICSERV
137 #define NI_NUMERICSERV 8
138 #endif
139
140 #ifndef NI_DGRAM
141 #define NI_DGRAM 16
142 #endif
143
144 #if !HAVE_GETADDRINFO
145 int ff_getaddrinfo(const char *node, const char *service,
146                    const struct addrinfo *hints, struct addrinfo **res);
147 void ff_freeaddrinfo(struct addrinfo *res);
148 int ff_getnameinfo(const struct sockaddr *sa, int salen,
149                    char *host, int hostlen,
150                    char *serv, int servlen, int flags);
151 const char *ff_gai_strerror(int ecode);
152 #define getaddrinfo ff_getaddrinfo
153 #define freeaddrinfo ff_freeaddrinfo
154 #define getnameinfo ff_getnameinfo
155 #define gai_strerror ff_gai_strerror
156 #endif
157
158 #ifndef INET6_ADDRSTRLEN
159 #define INET6_ADDRSTRLEN INET_ADDRSTRLEN
160 #endif
161
162 #ifndef IN_MULTICAST
163 #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
164 #endif
165 #ifndef IN6_IS_ADDR_MULTICAST
166 #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
167 #endif
168
169 int ff_is_multicast_address(struct sockaddr *addr);
170
171 #endif /* AVFORMAT_NETWORK_H */