annotate tcp.c @ 209:7414bbf64011 libavformat

first pass at PSX STR demuxer; does not yet interact correctly with MDEC video decoder
author tmmm
date Mon, 01 Sep 2003 15:55:38 +0000
parents 82fea3fec65b
children b0771ae979e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * TCP protocol
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2002 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 #include <unistd.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 #include <ctype.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include <sys/types.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 #include <sys/socket.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 #include <netinet/in.h>
182
82fea3fec65b OSX and BeOS networking fix (socklen_t)
mmu_man
parents: 180
diff changeset
25 #if defined(__APPLE__) || defined(__BEOS__)
82fea3fec65b OSX and BeOS networking fix (socklen_t)
mmu_man
parents: 180
diff changeset
26 typedef int socklen_t;
82fea3fec65b OSX and BeOS networking fix (socklen_t)
mmu_man
parents: 180
diff changeset
27 #endif
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 #ifndef __BEOS__
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 # include <arpa/inet.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 # include "barpainet.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 #include <netdb.h>
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
34 #include <sys/time.h>
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
35 #include <fcntl.h>
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 typedef struct TCPContext {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 int fd;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 } TCPContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 /* resolve host with also IP address parsing */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 int resolve_host(struct in_addr *sin_addr, const char *hostname)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 struct hostent *hp;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 if ((inet_aton(hostname, sin_addr)) == 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 hp = gethostbyname(hostname);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 if (!hp)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 memcpy (sin_addr, hp->h_addr, sizeof(struct in_addr));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 /* return non zero if error */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 static int tcp_open(URLContext *h, const char *uri, int flags)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 struct sockaddr_in dest_addr;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 char hostname[1024], *q;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60 int port, fd = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 TCPContext *s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 const char *p;
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
63 fd_set wfds;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
64 int fd_max, ret;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
65 struct timeval tv;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
66 socklen_t optlen;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
67
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 s = av_malloc(sizeof(TCPContext));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 if (!s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 return -ENOMEM;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 h->priv_data = s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 p = uri;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 if (!strstart(p, "tcp://", &p))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 q = hostname;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76 while (*p != ':' && *p != '/' && *p != '\0') {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 if ((q - hostname) < sizeof(hostname) - 1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 *q++ = *p;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 p++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 *q = '\0';
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 if (*p != ':')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84 p++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 port = strtoul(p, (char **)&p, 10);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 if (port <= 0 || port >= 65536)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 dest_addr.sin_family = AF_INET;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 dest_addr.sin_port = htons(port);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 fd = socket(PF_INET, SOCK_STREAM, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 if (fd < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 goto fail;
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
97 fcntl(fd, F_SETFL, O_NONBLOCK);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
98
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
99 redo:
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
100 ret = connect(fd, (struct sockaddr *)&dest_addr,
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
101 sizeof(dest_addr));
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
102 if (ret < 0) {
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
103 if (errno == EINTR)
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
104 goto redo;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
105 if (errno != EINPROGRESS)
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
106 goto fail;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
108 /* wait until we are connected or until abort */
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
109 for(;;) {
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
110 if (url_interrupt_cb()) {
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
111 ret = -EINTR;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
112 goto fail1;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
113 }
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
114 fd_max = fd;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
115 FD_ZERO(&wfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
116 FD_SET(fd, &wfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
117 tv.tv_sec = 0;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
118 tv.tv_usec = 100 * 1000;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
119 ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
120 if (ret > 0 && FD_ISSET(fd, &wfds))
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
121 break;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
122 }
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
123
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
124 /* test error */
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
125 optlen = sizeof(ret);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
126 getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
127 if (ret != 0)
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
128 goto fail;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
129 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130 s->fd = fd;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
132
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133 fail:
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
134 ret = -EIO;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
135 fail1:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
136 if (fd >= 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 close(fd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 av_free(s);
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
139 return ret;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
140 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
142 static int tcp_read(URLContext *h, uint8_t *buf, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
143 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
144 TCPContext *s = h->priv_data;
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
145 int size1, len, fd_max;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
146 fd_set rfds;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
147 struct timeval tv;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
148
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
149 size1 = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
150 while (size > 0) {
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
151 if (url_interrupt_cb())
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
152 return -EINTR;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
153 fd_max = s->fd;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
154 FD_ZERO(&rfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
155 FD_SET(s->fd, &rfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
156 tv.tv_sec = 0;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
157 tv.tv_usec = 100 * 1000;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
158 select(fd_max + 1, &rfds, NULL, NULL, &tv);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
159 #ifdef __BEOS__
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
160 len = recv(s->fd, buf, size, 0);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161 #else
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
162 len = read(s->fd, buf, size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164 if (len < 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
165 if (errno != EINTR && errno != EAGAIN)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
166 #ifdef __BEOS__
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
167 return errno;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169 return -errno;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
170 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
171 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
172 continue;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
173 } else if (len == 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
174 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
175 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
176 size -= len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
177 buf += len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
178 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
179 return size1 - size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
180 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
181
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 0
diff changeset
182 static int tcp_write(URLContext *h, uint8_t *buf, int size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
184 TCPContext *s = h->priv_data;
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
185 int ret, size1, fd_max;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
186 fd_set wfds;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
187 struct timeval tv;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
188
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
189 size1 = size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
190 while (size > 0) {
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
191 if (url_interrupt_cb())
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
192 return -EINTR;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
193 fd_max = s->fd;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
194 FD_ZERO(&wfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
195 FD_SET(s->fd, &wfds);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
196 tv.tv_sec = 0;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
197 tv.tv_usec = 100 * 1000;
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
198 select(fd_max + 1, NULL, &wfds, NULL, &tv);
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
199 #ifdef __BEOS__
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
200 ret = send(s->fd, buf, size, 0);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201 #else
180
9e673f620f4d support aborting in TCP
bellard
parents: 65
diff changeset
202 ret = write(s->fd, buf, size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 if (ret < 0 && errno != EINTR && errno != EAGAIN)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 #ifdef __BEOS__
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 return errno;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
208 return -errno;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
209 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 size -= ret;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 buf += ret;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 return size1 - size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
216 static int tcp_close(URLContext *h)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 TCPContext *s = h->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
219 #ifdef CONFIG_BEOS_NETSERVER
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
220 closesocket(s->fd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222 close(s->fd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 av_free(s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
226 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
227
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
228 URLProtocol tcp_protocol = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
229 "tcp",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
230 tcp_open,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
231 tcp_read,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
232 tcp_write,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233 NULL, /* seek */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234 tcp_close,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
235 };