[gst-devel] udpsrc patch for win32/MSC
Wim Taymans
wim.taymans at gmail.com
Fri Feb 22 14:18:52 CET 2008
On Fri, 2008-02-22 at 11:14 +0100, Carsten wrote:
> I'm trying to build gstreamer in Visual Studio 8.
> I succeeded in building it and all libraries it depends on, but during
> my test I discovered 2 problems with udpsrc.
>
> 1) The pipe blocks but should not.
> 2) bind fails on multicast addresses.
>
> I fixed this and attached a patch.
Other patches are in bugzilla. The most likely one to be accepted will
be the one that integrates with GstPoll (here:
http://bugzilla.gnome.org/show_bug.cgi?id=515962).
Wim
>
> Carsten
> plain text document attachment (gstudpsrc.c.patch)
> Index: gstudpsrc.c
> ===================================================================
> RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstudpsrc.c,v
> retrieving revision 1.80
> diff -u -r1.80 gstudpsrc.c
> --- gstudpsrc.c 2 Nov 2007 21:16:09 -0000 1.80
> +++ gstudpsrc.c 21 Feb 2008 11:02:48 -0000
> @@ -127,6 +127,9 @@
>
> #if defined _MSC_VER && (_MSC_VER >= 1400)
> #include <io.h>
> +#define close CloseHandle
> +#define write _write
> +#define read _read
> #endif
>
> #include <gst/netbuffer/gstnetbuffer.h>
> @@ -149,16 +152,39 @@
> #define WRITE_SOCKET(src) src->control_sock[1]
> #define READ_SOCKET(src) src->control_sock[0]
>
> -#define SEND_COMMAND(src, command, res) \
> -G_STMT_START { \
> - unsigned char c; c = command; \
> - res = write (WRITE_SOCKET(src), &c, 1); \
> +#if !defined(__MINGW32__) && defined(G_OS_WIN32)
> +
> +#define SEND_COMMAND(src, command, res) \
> +G_STMT_START { \
> + gint bw;gchar c; c = command; \
> + if (!WriteFile((PHANDLE)WRITE_SOCKET(src), &c, 1,&bw,NULL)){ \
> + res=-1;\
> + }else{\
> + res=bw;\
> + }\
> +} G_STMT_END
> +
> +#define READ_COMMAND(src, command, res) \
> +G_STMT_START {\
> + gint br=0;\
> + if(PeekNamedPipe((PHANDLE)READ_SOCKET(src),NULL,NULL,NULL,NULL,NULL)){ \
> + ReadFile((PHANDLE)WRITE_SOCKET(src), &command, 1,&br,NULL);\
> + }\
> + res=br;\
> +} G_STMT_END
> +
> +#else
> +#define SEND_COMMAND(src, command, res) \
> +G_STMT_START { \
> + gchar c; c = command; \
> + res = write(WRITE_SOCKET(src), &c, 1); \
> } G_STMT_END
>
> #define READ_COMMAND(src, command, res) \
> G_STMT_START { \
> - res = read(READ_SOCKET(src), &command, 1); \
> + res = read(READ_SOCKET(src), &command, 1); \
> } G_STMT_END
> +#endif
>
> #define CLOSE_IF_REQUESTED(udpctx) \
> if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) \
> @@ -718,8 +744,16 @@
>
> /* This should work on UNIX too. PF_UNIX sockets replaced with pipe */
> /* pipe( CONTROL_SOCKETS(src), 4096, _O_BINARY ) */
> +#if defined(__MINGW32__)
> if ((ret = _pipe (CONTROL_SOCKETS (src), 4096, _O_BINARY)) < 0)
> - goto no_socket_pair;
> + goto no_socket_pair;
> +
> +#else
> + if (!CreatePipe((PHANDLE)&READ_SOCKET(src),(PHANDLE)&WRITE_SOCKET(src),NULL,4096)){
> + ret=GetLastError();
> + goto no_socket_pair;
> + }
> +#endif
> #else
> GST_DEBUG_OBJECT (src, "creating socket pair");
> if ((ret = socketpair (PF_UNIX, SOCK_STREAM, 0, CONTROL_SOCKETS (src))) < 0)
> @@ -749,10 +783,11 @@
> memset (&src->myaddr, 0, sizeof (src->myaddr));
> src->myaddr.sin_family = AF_INET; /* host byte order */
> src->myaddr.sin_port = htons (src->port); /* short, network byte order */
> -
> +#ifndef G_OS_WIN32
> if (src->multi_addr.imr_multiaddr.s_addr)
> src->myaddr.sin_addr.s_addr = src->multi_addr.imr_multiaddr.s_addr;
> else
> +#endif
> src->myaddr.sin_addr.s_addr = INADDR_ANY;
>
> GST_DEBUG_OBJECT (src, "binding on port %d", src->port);
> @@ -938,7 +973,6 @@
> close (src->control_sock[1]);
> src->control_sock[1] = -1;
> }
> -
> WSA_CLEANUP (src);
>
> return TRUE;
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________ gstreamer-devel mailing list gstreamer-devel at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list