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
#include <termios.h>
#include <sys/resource.h>
#endif
-#ifdef __BEOS__
-/* for snooze() */
-#include <OS.h>
-#endif
#include <time.h>
#include <ctype.h>
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);
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)
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)
--- /dev/null
+
+#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;
+}
--- /dev/null
+#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 */
#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 <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
#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>
#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
#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 {
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) {
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;
}
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;
}
#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 {
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 */
}
}
}
+#endif
if (is_output) {
/* limit the tx buf size to limit latency */
return 0;
fail:
if (udp_fd >= 0)
+#ifdef CONFIG_BEOS_NETSERVER
+ closesocket(udp_fd);
+#else
close(udp_fd);
+#endif
av_free(s);
return -EIO;
}
{
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) {
}
}
close(s->udp_fd);
+#else
+ closesocket(s->udp_fd);
+#endif
av_free(s);
return 0;
}