gst-libs/gst/rtsp/gstrtspconnection.c: Generic Windows fixes that makes libgstrtsp work on Windows when coupled with ...

Original commit message from CVS:
Patch by: Ole André Vadla Ravnås  <ole.andre.ravnas@tandberg.com>
* gst-libs/gst/rtsp/gstrtspconnection.c:
(gst_rtsp_connection_connect), (gst_rtsp_connection_write),
(read_line), (gst_rtsp_connection_read_internal):
Generic Windows fixes that makes libgstrtsp work on Windows when
coupled with the new GstPoll API. See #520808.
This commit is contained in:
Ole André Vadla Ravnås 2008-03-18 11:10:12 +00:00 committed by Wim Taymans
parent e97290739d
commit aca58fb8ac
2 changed files with 34 additions and 11 deletions

View file

@ -1,3 +1,13 @@
2008-03-18 Wim Taymans <wim.taymans@collabora.co.uk>
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
* gst-libs/gst/rtsp/gstrtspconnection.c:
(gst_rtsp_connection_connect), (gst_rtsp_connection_write),
(read_line), (gst_rtsp_connection_read_internal):
Generic Windows fixes that makes libgstrtsp work on Windows when
coupled with the new GstPoll API. See #520808.
2008-03-17 Sebastian Dröge <slomo@circular-chaos.org> 2008-03-17 Sebastian Dröge <slomo@circular-chaos.org>
Patch by: Milosz Derezynski <internalerror at gmail dot com> Patch by: Milosz Derezynski <internalerror at gmail dot com>

View file

@ -96,11 +96,23 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#define FIONREAD_TYPE gulong #define FIONREAD_TYPE gulong
#define IOCTL_SOCKET ioctlsocket #define IOCTL_SOCKET ioctlsocket
#define CLOSE_SOCKET(sock) closesocket(sock); #define READ_SOCKET(fd, buf, len) recv (fd, buf, len, 0)
#define WRITE_SOCKET(fd, buf, len) send (fd, buf, len, 0)
#define CLOSE_SOCKET(sock) closesocket (sock)
#define ERRNO_IS_NOT_EAGAIN (WSAGetLastError () != WSAEWOULDBLOCK)
#define ERRNO_IS_NOT_EINTR (WSAGetLastError () != WSAEINTR)
/* According to Microsoft's connect() documentation this one returns
* WSAEWOULDBLOCK and not WSAEINPROGRESS. */
#define ERRNO_IS_NOT_EINPROGRESS (WSAGetLastError () != WSAEWOULDBLOCK)
#else #else
#define FIONREAD_TYPE gint #define FIONREAD_TYPE gint
#define IOCTL_SOCKET ioctl #define IOCTL_SOCKET ioctl
#define CLOSE_SOCKET(sock) close(sock); #define READ_SOCKET(fd, buf, len) read (fd, buf, len)
#define WRITE_SOCKET(fd, buf, len) write (fd, buf, len)
#define CLOSE_SOCKET(sock) close (sock)
#define ERRNO_IS_NOT_EAGAIN (errno != EAGAIN)
#define ERRNO_IS_NOT_EINTR (errno != EINTR)
#define ERRNO_IS_NOT_EINPROGRESS (errno != EINPROGRESS)
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
@ -191,7 +203,7 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout)
gint retval; gint retval;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
unsigned long flags; unsigned long flags = 1;
struct in_addr *addrp; struct in_addr *addrp;
#else #else
char **addrs; char **addrs;
@ -252,7 +264,7 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout)
ret = connect (fd, (struct sockaddr *) &sa_in, sizeof (sa_in)); ret = connect (fd, (struct sockaddr *) &sa_in, sizeof (sa_in));
if (ret == 0) if (ret == 0)
goto done; goto done;
if (errno != EINPROGRESS) if (ERRNO_IS_NOT_EINPROGRESS)
goto sys_error; goto sys_error;
/* wait for connect to complete up to the specified timeout or until we got /* wait for connect to complete up to the specified timeout or until we got
@ -270,6 +282,8 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout)
else if (retval == -1) else if (retval == -1)
goto sys_error; goto sys_error;
gst_poll_fd_ignored (conn->fdset, &conn->fd);
done: done:
conn->ip = g_strdup (ip); conn->ip = g_strdup (ip);
@ -407,9 +421,9 @@ gst_rtsp_connection_write (GstRTSPConnection * conn, const guint8 * data,
} }
/* now we can write */ /* now we can write */
written = write (conn->fd.fd, data, towrite); written = WRITE_SOCKET (conn->fd.fd, data, towrite);
if (written < 0) { if (written < 0) {
if (errno != EAGAIN && errno != EINTR) if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
goto write_error; goto write_error;
} else { } else {
towrite -= written; towrite -= written;
@ -580,11 +594,11 @@ read_line (gint fd, gchar * buffer, guint size)
idx = 0; idx = 0;
while (TRUE) { while (TRUE) {
r = read (fd, &c, 1); r = READ_SOCKET (fd, &c, 1);
if (r == 0) { if (r == 0) {
goto eof; goto eof;
} else if (r < 0) { } else if (r < 0) {
if (errno != EAGAIN && errno != EINTR) if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
goto read_error; goto read_error;
} else { } else {
if (c == '\n') /* end on \n */ if (c == '\n') /* end on \n */
@ -821,12 +835,11 @@ gst_rtsp_connection_read_internal (GstRTSPConnection * conn, guint8 * data,
do_read: do_read:
/* if we get here there is activity on the real fd since the select /* if we get here there is activity on the real fd since the select
* completed and the control socket was not readable. */ * completed and the control socket was not readable. */
bytes = read (conn->fd.fd, data, toread); bytes = READ_SOCKET (conn->fd.fd, data, toread);
if (bytes == 0) { if (bytes == 0) {
goto eof; goto eof;
} else if (bytes < 0) { } else if (bytes < 0) {
if (errno != EAGAIN && errno != EINTR) if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
goto read_error; goto read_error;
} else { } else {
toread -= bytes; toread -= bytes;