diff options
author | François Revol <revol@free.fr> | 2002-11-02 10:35:07 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-11-02 10:35:07 +0000 |
commit | 9ddd71fc6063b357344f81a0f704c1d04f584ada (patch) | |
tree | 87e9377d16bd2a22727ca6f572ba312f167d258f | |
parent | bbd8335b69b4960b2a6e830317f189748232c749 (diff) | |
download | ffmpeg-9ddd71fc6063b357344f81a0f704c1d04f584ada.tar.gz |
added BeOS net_server support (R5 network stack), basically the same
problems as with winsock (sockets != fd), and the broken select().
based on older patch by Andrew Bachmann.
patch by (François Revol <revol at free dot fr>)
Originally committed as revision 1144 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | ffmpeg.c | 13 | ||||
-rw-r--r-- | libav/Makefile | 4 | ||||
-rw-r--r-- | libav/barpainet.c | 25 | ||||
-rw-r--r-- | libav/barpainet.h | 23 | ||||
-rw-r--r-- | libav/http.c | 6 | ||||
-rw-r--r-- | libav/rtp.c | 6 | ||||
-rw-r--r-- | libav/rtpproto.c | 6 | ||||
-rw-r--r-- | libav/rtsp.c | 6 | ||||
-rw-r--r-- | libav/tcp.c | 26 | ||||
-rw-r--r-- | libav/udp.c | 16 |
10 files changed, 119 insertions, 12 deletions
@@ -27,10 +27,6 @@ #include <termios.h> #include <sys/resource.h> #endif -#ifdef __BEOS__ -/* for snooze() */ -#include <OS.h> -#endif #include <time.h> #include <ctype.h> @@ -227,14 +223,18 @@ static void term_init(void) tcsetattr (0, TCSANOW, &tty); atexit(term_exit); +#ifdef CONFIG_BEOS_NETSERVER + fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); +#endif } /* read a key without blocking */ static int read_key(void) { - struct timeval tv; - int n; + int n = 1; unsigned char ch; +#ifndef CONFIG_BEOS_NETSERVER + struct timeval tv; fd_set rfds; FD_ZERO(&rfds); @@ -242,6 +242,7 @@ static int read_key(void) tv.tv_sec = 0; tv.tv_usec = 0; n = select(1, &rfds, NULL, NULL, &tv); +#endif if (n > 0) { n = read(0, &ch, 1); if (n == 1) diff --git a/libav/Makefile b/libav/Makefile index bd33e4aea0..e3a8ace27b 100644 --- a/libav/Makefile +++ b/libav/Makefile @@ -31,6 +31,10 @@ endif ifeq ($(CONFIG_NETWORK),yes) OBJS+= udp.o tcp.o http.o rtsp.o rtp.o rtpproto.o +# BeOS network stuff +ifeq ($(CONFIG_BEOS_NETSERVER),yes) +OBJS+= barpainet.o +endif endif ifeq ($(CONFIG_VORBIS),yes) diff --git a/libav/barpainet.c b/libav/barpainet.c new file mode 100644 index 0000000000..c1e8877718 --- /dev/null +++ b/libav/barpainet.c @@ -0,0 +1,25 @@ + +#include <stdlib.h> +#include <strings.h> +#include "barpainet.h" + +int inet_aton (const char * str, struct in_addr * add) { + const char * pch = str; + unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0; + + add1 = atoi(pch); + pch = strpbrk(pch,"."); + if (pch == 0 || ++pch == 0) goto done; + add2 = atoi(pch); + pch = strpbrk(pch,"."); + if (pch == 0 || ++pch == 0) goto done; + add3 = atoi(pch); + pch = strpbrk(pch,"."); + if (pch == 0 || ++pch == 0) goto done; + add4 = atoi(pch); + +done: + add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1; + + return 1; +} diff --git a/libav/barpainet.h b/libav/barpainet.h new file mode 100644 index 0000000000..461403b3fa --- /dev/null +++ b/libav/barpainet.h @@ -0,0 +1,23 @@ +#ifndef BARPA_INET_H +#define BARPA_INET_H + +#include "../config.h" + +#ifdef CONFIG_BEOS_NETSERVER + +# include <socket.h> +int inet_aton (const char * str, struct in_addr * add); +# define PF_INET AF_INET +# define SO_SNDBUF 0x40000001 + +/* fake */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +#else +# include <arpa/inet.h> +#endif + +#endif /* BARPA_INET_H */ diff --git a/libav/http.c b/libav/http.c index 21ac51dd46..7271a6da81 100644 --- a/libav/http.c +++ b/libav/http.c @@ -22,7 +22,11 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif #include <netdb.h> diff --git a/libav/rtp.c b/libav/rtp.c index 45ccc2c39d..714787c88b 100644 --- a/libav/rtp.c +++ b/libav/rtp.c @@ -22,7 +22,11 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif #include <netdb.h> //#define DEBUG diff --git a/libav/rtpproto.c b/libav/rtpproto.c index dac5273a80..41823fc829 100644 --- a/libav/rtpproto.c +++ b/libav/rtpproto.c @@ -23,7 +23,11 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif #include <netdb.h> #include <fcntl.h> diff --git a/libav/rtsp.c b/libav/rtsp.c index acacc5de9c..81b59f8916 100644 --- a/libav/rtsp.c +++ b/libav/rtsp.c @@ -21,7 +21,11 @@ #include <sys/time.h> #include <netinet/in.h> #include <sys/socket.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif //#define DEBUG diff --git a/libav/tcp.c b/libav/tcp.c index 644e139393..61d8665525 100644 --- a/libav/tcp.c +++ b/libav/tcp.c @@ -22,7 +22,11 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif #include <netdb.h> typedef struct TCPContext { @@ -103,10 +107,18 @@ static int tcp_read(URLContext *h, UINT8 *buf, int size) size1 = size; while (size > 0) { +#ifdef CONFIG_BEOS_NETSERVER + len = recv (s->fd, buf, size, 0); +#else len = read (s->fd, buf, size); +#endif if (len < 0) { if (errno != EINTR && errno != EAGAIN) +#ifdef __BEOS__ + return errno; +#else return -errno; +#endif else continue; } else if (len == 0) { @@ -125,9 +137,17 @@ static int tcp_write(URLContext *h, UINT8 *buf, int size) size1 = size; while (size > 0) { +#ifdef CONFIG_BEOS_NETSERVER + ret = send (s->fd, buf, size, 0); +#else ret = write (s->fd, buf, size); +#endif if (ret < 0 && errno != EINTR && errno != EAGAIN) +#ifdef __BEOS__ + return errno; +#else return -errno; +#endif size -= ret; buf += ret; } @@ -137,7 +157,11 @@ static int tcp_write(URLContext *h, UINT8 *buf, int size) static int tcp_close(URLContext *h) { TCPContext *s = h->priv_data; +#ifdef CONFIG_BEOS_NETSERVER + closesocket(s->fd); +#else close(s->fd); +#endif av_free(s); return 0; } diff --git a/libav/udp.c b/libav/udp.c index ad514cb2fb..8df93a8a8a 100644 --- a/libav/udp.c +++ b/libav/udp.c @@ -21,7 +21,11 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> -#include <arpa/inet.h> +#ifndef __BEOS__ +# include <arpa/inet.h> +#else +# include "barpainet.h" +#endif #include <netdb.h> typedef struct { @@ -154,6 +158,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) getsockname(udp_fd, (struct sockaddr *)&my_addr1, &len); s->local_port = ntohs(my_addr1.sin_port); +#ifndef CONFIG_BEOS_NETSERVER if (s->is_multicast) { if (h->flags & URL_WRONLY) { /* output */ @@ -174,6 +179,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) } } } +#endif if (is_output) { /* limit the tx buf size to limit latency */ @@ -189,7 +195,11 @@ static int udp_open(URLContext *h, const char *uri, int flags) return 0; fail: if (udp_fd >= 0) +#ifdef CONFIG_BEOS_NETSERVER + closesocket(udp_fd); +#else close(udp_fd); +#endif av_free(s); return -EIO; } @@ -237,6 +247,7 @@ static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; +#ifndef CONFIG_BEOS_NETSERVER if (s->is_multicast && !(h->flags & URL_WRONLY)) { if (setsockopt(s->udp_fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &s->mreq, sizeof(s->mreq)) < 0) { @@ -244,6 +255,9 @@ static int udp_close(URLContext *h) } } close(s->udp_fd); +#else + closesocket(s->udp_fd); +#endif av_free(s); return 0; } |