diff -Naur ffmpeg-2006-11-09/configure ffmpeg/configure --- ffmpeg-2006-11-09/configure 2006-11-09 19:07:00.000000000 -0600 +++ ffmpeg/configure 2006-11-09 19:07:20.000000000 -0600 @@ -907,7 +907,7 @@ dv1394="no" dc1394="no" ffserver="no" - network="no" + extralibs="$extralibs -lws2_32" if test "$mingwce" = "yes"; then protocols="no" fi diff -Naur ffmpeg-2006-11-09/libavformat/gxf.c ffmpeg/libavformat/gxf.c --- ffmpeg-2006-11-09/libavformat/gxf.c 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/gxf.c 2006-11-09 19:15:25.000000000 -0600 @@ -200,7 +200,11 @@ * \return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_tag2avr(int32_t fps) { +#ifndef __MINGW32__ extern const AVRational ff_frame_rate_tab[]; +#else + extern __declspec(dllimport) const AVRational ff_frame_rate_tab[]; +#endif if (fps < 1 || fps > 9) fps = 9; return ff_frame_rate_tab[9 - fps]; // values have opposite order } diff -Naur ffmpeg-2006-11-09/libavformat/http.c ffmpeg/libavformat/http.c --- ffmpeg-2006-11-09/libavformat/http.c 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/http.c 2006-11-09 19:07:20.000000000 -0600 @@ -21,14 +21,12 @@ #include "avformat.h" #include #include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" -#endif #include +#include +#endif #include "base64.h" diff -Naur ffmpeg-2006-11-09/libavformat/os_support.c ffmpeg/libavformat/os_support.c --- ffmpeg-2006-11-09/libavformat/os_support.c 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/os_support.c 2006-11-09 19:07:20.000000000 -0600 @@ -34,6 +34,9 @@ #include #endif #include +#ifdef __MINGW32__ +#include +#endif /** * gets the current time in micro seconds. @@ -67,3 +70,28 @@ } #endif /* !defined(HAVE_LOCALTIME_R) */ #endif /* !defined(CONFIG_WINCE) */ + +#ifdef __MINGW32__ +int init_winsock() +{ +WSADATA wsaData; +WORD wVersionRequested=MAKEWORD(1,1); +int Win32isStupid; + + Win32isStupid=WSAStartup(wVersionRequested, &wsaData); + if (Win32isStupid) return -1; + + return 0; +} + +int inet_aton(const char *hostname, struct in_addr *sin_addr) +{ + sin_addr->s_addr=inet_addr(hostname); + if (sin_addr->s_addr == INADDR_NONE) { + return 0; + } + + return -1; +} +#endif + diff -Naur ffmpeg-2006-11-09/libavformat/os_support.h ffmpeg/libavformat/os_support.h --- ffmpeg-2006-11-09/libavformat/os_support.h 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/os_support.h 2006-11-09 19:11:48.000000000 -0600 @@ -31,10 +31,29 @@ * - strcasecmp() (OS/2) */ +#ifdef __BEOS__ +#include "barpainet.h" +#endif + +#if defined(__BEOS__) || defined(__MINGW32__) || defined(__INNOTEK_LIBC__) +typedef int socklen_t; +#endif + #ifdef __MINGW32__ __declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds); // # include +#define GUID microsoft_issue_GUID +#include +#undef GUID # define usleep(t) Sleep((t) / 1000) +# define sleep(t) Sleep((t) * 1000) +#define O_NONBLOCK FIONBIO +#define fcntl(fd,b,c) { u_long arg=1L; \ + ioctlsocket(fd, c, &arg); } +// #define EINPROGRESS WSAEINPROGRESS +#define EINPROGRESS 0 +int init_winsock(); + #endif #ifdef __BEOS__ diff -Naur ffmpeg-2006-11-09/libavformat/rtp.c ffmpeg/libavformat/rtp.c --- ffmpeg-2006-11-09/libavformat/rtp.c 2006-11-09 19:06:59.000000000 -0600 +++ ffmpeg/libavformat/rtp.c 2006-11-09 19:07:20.000000000 -0600 @@ -24,14 +24,12 @@ #include #include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" -#endif #include +#include +#endif #include "rtp_internal.h" #include "rtp_h264.h" diff -Naur ffmpeg-2006-11-09/libavformat/rtp_h264.c ffmpeg/libavformat/rtp_h264.c --- ffmpeg-2006-11-09/libavformat/rtp_h264.c 2006-11-09 19:07:00.000000000 -0600 +++ ffmpeg/libavformat/rtp_h264.c 2006-11-09 19:07:20.000000000 -0600 @@ -42,15 +42,12 @@ #include #include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" -#endif #include +#include +#endif #include "rtp_internal.h" #include "rtp_h264.h" diff -Naur ffmpeg-2006-11-09/libavformat/rtpproto.c ffmpeg/libavformat/rtpproto.c --- ffmpeg-2006-11-09/libavformat/rtpproto.c 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/rtpproto.c 2006-11-09 19:07:20.000000000 -0600 @@ -23,15 +23,13 @@ #include #include #include +#include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" -#endif #include -#include +#include +#endif #define RTP_TX_BUF_SIZE (64 * 1024) #define RTP_RX_BUF_SIZE (128 * 1024) diff -Naur ffmpeg-2006-11-09/libavformat/rtsp.c ffmpeg/libavformat/rtsp.c --- ffmpeg-2006-11-09/libavformat/rtsp.c 2006-11-09 19:07:00.000000000 -0600 +++ ffmpeg/libavformat/rtsp.c 2006-11-09 19:07:20.000000000 -0600 @@ -22,12 +22,10 @@ #include /* for select() prototype */ #include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" +#include #endif #include "rtp_internal.h" diff -Naur ffmpeg-2006-11-09/libavformat/tcp.c ffmpeg/libavformat/tcp.c --- ffmpeg-2006-11-09/libavformat/tcp.c 2006-11-09 19:06:59.000000000 -0600 +++ ffmpeg/libavformat/tcp.c 2006-11-09 19:07:20.000000000 -0600 @@ -21,19 +21,14 @@ #include "avformat.h" #include #include +#include +#include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include #include -#if defined(__BEOS__) || defined(__INNOTEK_LIBC__) -typedef int socklen_t; -#endif -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" -#endif #include -#include -#include +#include +#endif typedef struct TCPContext { int fd; @@ -79,6 +74,10 @@ if (port <= 0 || port >= 65536) goto fail; +#ifdef __MINGW32__ + init_winsock(); +#endif + dest_addr.sin_family = AF_INET; dest_addr.sin_port = htons(port); if (resolve_host(&dest_addr.sin_addr, hostname) < 0) @@ -149,11 +148,7 @@ tv.tv_usec = 100 * 1000; ret = select(fd_max + 1, &rfds, NULL, NULL, &tv); if (ret > 0 && FD_ISSET(s->fd, &rfds)) { -#ifdef __BEOS__ 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__ @@ -186,11 +181,7 @@ tv.tv_usec = 100 * 1000; ret = select(fd_max + 1, NULL, &wfds, NULL, &tv); if (ret > 0 && FD_ISSET(s->fd, &wfds)) { -#ifdef __BEOS__ len = send(s->fd, buf, size, 0); -#else - len = write(s->fd, buf, size); -#endif if (len < 0) { if (errno != EINTR && errno != EAGAIN) { #ifdef __BEOS__ @@ -213,7 +204,7 @@ static int tcp_close(URLContext *h) { TCPContext *s = h->priv_data; -#ifdef CONFIG_BEOS_NETSERVER +#if defined(CONFIG_BEOS_NETSERVER) || defined(__MINGW32__) closesocket(s->fd); #else close(s->fd); diff -Naur ffmpeg-2006-11-09/libavformat/udp.c ffmpeg/libavformat/udp.c --- ffmpeg-2006-11-09/libavformat/udp.c 2006-11-09 19:06:58.000000000 -0600 +++ ffmpeg/libavformat/udp.c 2006-11-09 19:14:00.000000000 -0600 @@ -21,14 +21,12 @@ #include "avformat.h" #include #include +#if !defined(__MINGW32__) && !defined(__BEOS__) #include +#include #include -#ifndef __BEOS__ -# include -#else -# include "barpainet.h" +#include #endif -#include #ifndef IPV6_ADD_MEMBERSHIP #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP @@ -214,7 +212,7 @@ fail: if (udp_fd >= 0) -#ifdef CONFIG_BEOS_NETSERVER +#if defined(CONFIG_BEOS_NETSERVER) || defined(__MINGW32__) closesocket(udp_fd); #else close(udp_fd); @@ -299,6 +297,7 @@ struct sockaddr_in my_addr, my_addr1; int len; #endif + int t; h->is_streamed = 1; h->max_packet_size = 1472; @@ -360,13 +359,30 @@ goto fail; /* the bind is needed to give a port to the socket now */ - if (bind(udp_fd,(struct sockaddr *)&my_addr, sizeof(my_addr)) < 0) - goto fail; + t=0; + while(1) + { + if (bind(udp_fd,(struct sockaddr *)&my_addr, sizeof(my_addr)) < 0) + { + if (t>100) goto fail; + s->local_port++; + my_addr.sin_port = htons(s->local_port); + } + else + { break; } + + t++; + } len = sizeof(my_addr1); getsockname(udp_fd, (struct sockaddr *)&my_addr1, &len); s->local_port = ntohs(my_addr1.sin_port); +#ifdef __MINGW32__ + tmp=65536; /* 64k UDP buffer size. Should this be bigger? */ + setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)); +#endif + #ifndef CONFIG_BEOS_NETSERVER if (s->is_multicast) { if (h->flags & URL_WRONLY) { @@ -421,7 +437,7 @@ return 0; fail: if (udp_fd >= 0) -#ifdef CONFIG_BEOS_NETSERVER +#if defined(CONFIG_BEOS_NETSERVER) || defined(__MINGW32__) closesocket(udp_fd); #else close(udp_fd); @@ -482,7 +498,7 @@ { UDPContext *s = h->priv_data; -#ifndef CONFIG_BEOS_NETSERVER +#if !defined(CONFIG_BEOS_NETSERVER) && !defined(__MINGW32__) #ifndef CONFIG_IPV6 if (s->is_multicast && !(h->flags & URL_WRONLY)) { if (setsockopt(s->udp_fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,