mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
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:
parent
e97290739d
commit
aca58fb8ac
2 changed files with 34 additions and 11 deletions
10
ChangeLog
10
ChangeLog
|
@ -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>
|
||||
|
||||
Patch by: Milosz Derezynski <internalerror at gmail dot com>
|
||||
|
|
|
@ -96,11 +96,23 @@
|
|||
#ifdef G_OS_WIN32
|
||||
#define FIONREAD_TYPE gulong
|
||||
#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
|
||||
#define FIONREAD_TYPE gint
|
||||
#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
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
@ -191,7 +203,7 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout)
|
|||
gint retval;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
unsigned long flags;
|
||||
unsigned long flags = 1;
|
||||
struct in_addr *addrp;
|
||||
#else
|
||||
char **addrs;
|
||||
|
@ -252,7 +264,7 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout)
|
|||
ret = connect (fd, (struct sockaddr *) &sa_in, sizeof (sa_in));
|
||||
if (ret == 0)
|
||||
goto done;
|
||||
if (errno != EINPROGRESS)
|
||||
if (ERRNO_IS_NOT_EINPROGRESS)
|
||||
goto sys_error;
|
||||
|
||||
/* 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)
|
||||
goto sys_error;
|
||||
|
||||
gst_poll_fd_ignored (conn->fdset, &conn->fd);
|
||||
|
||||
done:
|
||||
conn->ip = g_strdup (ip);
|
||||
|
||||
|
@ -407,9 +421,9 @@ gst_rtsp_connection_write (GstRTSPConnection * conn, const guint8 * data,
|
|||
}
|
||||
|
||||
/* now we can write */
|
||||
written = write (conn->fd.fd, data, towrite);
|
||||
written = WRITE_SOCKET (conn->fd.fd, data, towrite);
|
||||
if (written < 0) {
|
||||
if (errno != EAGAIN && errno != EINTR)
|
||||
if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
|
||||
goto write_error;
|
||||
} else {
|
||||
towrite -= written;
|
||||
|
@ -580,11 +594,11 @@ read_line (gint fd, gchar * buffer, guint size)
|
|||
|
||||
idx = 0;
|
||||
while (TRUE) {
|
||||
r = read (fd, &c, 1);
|
||||
r = READ_SOCKET (fd, &c, 1);
|
||||
if (r == 0) {
|
||||
goto eof;
|
||||
} else if (r < 0) {
|
||||
if (errno != EAGAIN && errno != EINTR)
|
||||
if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
|
||||
goto read_error;
|
||||
} else {
|
||||
if (c == '\n') /* end on \n */
|
||||
|
@ -821,12 +835,11 @@ gst_rtsp_connection_read_internal (GstRTSPConnection * conn, guint8 * data,
|
|||
do_read:
|
||||
/* if we get here there is activity on the real fd since the select
|
||||
* 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) {
|
||||
goto eof;
|
||||
} else if (bytes < 0) {
|
||||
if (errno != EAGAIN && errno != EINTR)
|
||||
if (ERRNO_IS_NOT_EAGAIN && ERRNO_IS_NOT_EINTR)
|
||||
goto read_error;
|
||||
} else {
|
||||
toread -= bytes;
|
||||
|
|
Loading…
Reference in a new issue