Mercurial > libavformat.hg
annotate network.h @ 6090:b260ede399be libavformat
matroskaenc: Don't write a second seekhead for the clusters; mkvalidate agrees
with me that it's unnecessary.
author | conrad |
---|---|
date | Fri, 04 Jun 2010 22:41:11 +0000 |
parents | 1c93ef22cea6 |
children | e29a553aa1fc |
rev | line source |
---|---|
1754 | 1 /* |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4206
diff
changeset
|
2 * Copyright (c) 2007 The FFmpeg Project |
1754 | 3 * |
4 * This file is part of FFmpeg. | |
5 * | |
6 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 */ | |
20 | |
3852 | 21 #ifndef AVFORMAT_NETWORK_H |
22 #define AVFORMAT_NETWORK_H | |
1754 | 23 |
4284
40c9bef5b4e2
Fix undefined preprocessor directives warnings during 'make checkheaders'.
diego
parents:
4251
diff
changeset
|
24 #include "config.h" |
40c9bef5b4e2
Fix undefined preprocessor directives warnings during 'make checkheaders'.
diego
parents:
4251
diff
changeset
|
25 |
4206 | 26 #if HAVE_WINSOCK2_H |
2085 | 27 #include <winsock2.h> |
28 #include <ws2tcpip.h> | |
29 | |
5954
1c93ef22cea6
Fix compile error on mingw where ETIMEDOUT is missing (because it's a WSA error).
rbultje
parents:
5766
diff
changeset
|
30 #define ff_neterrno() (-WSAGetLastError()) |
1c93ef22cea6
Fix compile error on mingw where ETIMEDOUT is missing (because it's a WSA error).
rbultje
parents:
5766
diff
changeset
|
31 #define FF_NETERROR(err) (-WSA##err) |
2085 | 32 #define WSAEAGAIN WSAEWOULDBLOCK |
33 #else | |
1754 | 34 #include <sys/types.h> |
35 #include <sys/socket.h> | |
36 #include <netinet/in.h> | |
37 #include <netdb.h> | |
38 | |
5954
1c93ef22cea6
Fix compile error on mingw where ETIMEDOUT is missing (because it's a WSA error).
rbultje
parents:
5766
diff
changeset
|
39 #define ff_neterrno() AVERROR(errno) |
1c93ef22cea6
Fix compile error on mingw where ETIMEDOUT is missing (because it's a WSA error).
rbultje
parents:
5766
diff
changeset
|
40 #define FF_NETERROR(err) AVERROR(err) |
2085 | 41 #endif |
42 | |
4206 | 43 #if HAVE_ARPA_INET_H |
2085 | 44 #include <arpa/inet.h> |
45 #endif | |
2056
eeea52739ff3
use ff_neterrno() and FF_NETERROR() for networking error handling
alex
parents:
1943
diff
changeset
|
46 |
2057
857fbfeb2fa0
implement ff_socket_nonblock and use it in networking code
alex
parents:
2056
diff
changeset
|
47 int ff_socket_nonblock(int socket, int enable); |
857fbfeb2fa0
implement ff_socket_nonblock and use it in networking code
alex
parents:
2056
diff
changeset
|
48 |
2351
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
49 static inline int ff_network_init(void) |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
50 { |
4206 | 51 #if HAVE_WINSOCK2_H |
2351
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
52 WSADATA wsaData; |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
53 if (WSAStartup(MAKEWORD(1,1), &wsaData)) |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
54 return 0; |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
55 #endif |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
56 return 1; |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
57 } |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
58 |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
59 static inline void ff_network_close(void) |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
60 { |
4206 | 61 #if HAVE_WINSOCK2_H |
2351
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
62 WSACleanup(); |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
63 #endif |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
64 } |
b9a881c0967e
Add initialization and cleanup functions for Winsock
ramiro
parents:
2322
diff
changeset
|
65 |
5766
a292ef47e2f9
Localize the #define _SVID_SOURCE needed for inet_aton() to os_support.c
conrad
parents:
5638
diff
changeset
|
66 int ff_inet_aton (const char * str, struct in_addr * add); |
1943
c0c0f19f0db6
Some more BeOS cleanup: check for arpa/inet.h; declare the prototype for inet_aton if not found; remove barpainet.h as it's not longer needed.
mmu_man
parents:
1754
diff
changeset
|
67 |
5519
9faa86343583
Implement a fallback for struct sockaddr_storage if not available.
rbultje
parents:
5516
diff
changeset
|
68 #if !HAVE_STRUCT_SOCKADDR_STORAGE |
9faa86343583
Implement a fallback for struct sockaddr_storage if not available.
rbultje
parents:
5516
diff
changeset
|
69 struct sockaddr_storage { |
5565
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
70 #if HAVE_STRUCT_SOCKADDR_SA_LEN |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
71 uint8_t ss_len; |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
72 uint8_t ss_family; |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
73 #else |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
74 uint16_t ss_family; |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
75 #endif |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
76 char ss_pad1[6]; |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
77 int64_t ss_align; |
befe2f0f9a00
Use the configure check from r21351 and use it to properly define struct
rbultje
parents:
5520
diff
changeset
|
78 char ss_pad2[112]; |
5519
9faa86343583
Implement a fallback for struct sockaddr_storage if not available.
rbultje
parents:
5516
diff
changeset
|
79 }; |
9faa86343583
Implement a fallback for struct sockaddr_storage if not available.
rbultje
parents:
5516
diff
changeset
|
80 #endif |
9faa86343583
Implement a fallback for struct sockaddr_storage if not available.
rbultje
parents:
5516
diff
changeset
|
81 |
5516
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
82 #if !HAVE_STRUCT_ADDRINFO |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
83 struct addrinfo { |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
84 int ai_flags; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
85 int ai_family; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
86 int ai_socktype; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
87 int ai_protocol; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
88 int ai_addrlen; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
89 struct sockaddr *ai_addr; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
90 char *ai_canonname; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
91 struct addrinfo *ai_next; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
92 }; |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
93 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
94 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
95 /* getaddrinfo constants */ |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
96 #ifndef EAI_FAIL |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
97 #define EAI_FAIL 4 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
98 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
99 |
5520
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
100 #ifndef EAI_FAMILY |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
101 #define EAI_FAMILY 5 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
102 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
103 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
104 #ifndef EAI_NONAME |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
105 #define EAI_NONAME 8 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
106 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
107 |
5516
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
108 #ifndef AI_PASSIVE |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
109 #define AI_PASSIVE 1 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
110 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
111 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
112 #ifndef AI_CANONNAME |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
113 #define AI_CANONNAME 2 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
114 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
115 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
116 #ifndef AI_NUMERICHOST |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
117 #define AI_NUMERICHOST 4 |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
118 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
119 |
5520
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
120 #ifndef NI_NOFQDN |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
121 #define NI_NOFQDN 1 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
122 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
123 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
124 #ifndef NI_NUMERICHOST |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
125 #define NI_NUMERICHOST 2 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
126 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
127 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
128 #ifndef NI_NAMERQD |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
129 #define NI_NAMERQD 4 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
130 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
131 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
132 #ifndef NI_NUMERICSERV |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
133 #define NI_NUMERICSERV 8 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
134 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
135 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
136 #ifndef NI_DGRAM |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
137 #define NI_DGRAM 16 |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
138 #endif |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
139 |
5516
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
140 #if !HAVE_GETADDRINFO |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
141 int ff_getaddrinfo(const char *node, const char *service, |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
142 const struct addrinfo *hints, struct addrinfo **res); |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
143 void ff_freeaddrinfo(struct addrinfo *res); |
5520
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
144 int ff_getnameinfo(const struct sockaddr *sa, int salen, |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
145 char *host, int hostlen, |
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
146 char *serv, int servlen, int flags); |
5638
a3e321e7ca38
Implement gai_strerror() for systems lacking such functionality. Patch
rbultje
parents:
5565
diff
changeset
|
147 const char *ff_gai_strerror(int ecode); |
5516
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
148 #define getaddrinfo ff_getaddrinfo |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
149 #define freeaddrinfo ff_freeaddrinfo |
5520
8797851aeedb
Provide a fallback for getnameinfo() also. Patch by Martin Storsj
rbultje
parents:
5519
diff
changeset
|
150 #define getnameinfo ff_getnameinfo |
5638
a3e321e7ca38
Implement gai_strerror() for systems lacking such functionality. Patch
rbultje
parents:
5565
diff
changeset
|
151 #define gai_strerror ff_gai_strerror |
5516
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
152 #endif |
afe4a96b6832
Provide fallback implementations of getaddrinfo() and freeaddrinfo().
rbultje
parents:
4284
diff
changeset
|
153 |
3852 | 154 #endif /* AVFORMAT_NETWORK_H */ |