From 7b405d88d315db33572b8020b60120b89b0cff70 Mon Sep 17 00:00:00 2001 From: Joni Valtanen Date: Tue, 20 Jun 2006 10:31:41 +0000 Subject: [PATCH] gst/rtsp/rtspconnection.c: Make RTSP plugin compile on windows. Fixes #345301. Original commit message from CVS: Patch by: Joni Valtanen * gst/rtsp/rtspconnection.c: (inet_aton), (rtsp_connection_send), (rtsp_connection_close): Make RTSP plugin compile on windows. Fixes #345301. Some changes to original patch to catch errors better. use ifdef WIN32 instead of ifndef. --- ChangeLog | 10 ++++++++ gst/rtsp/rtspconnection.c | 50 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 95858795a1..bdc1775001 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-06-20 Wim Taymans + + Patch by: Joni Valtanen + + * gst/rtsp/rtspconnection.c: (inet_aton), (rtsp_connection_send), + (rtsp_connection_close): + Make RTSP plugin compile on windows. Fixes #345301. + Some changes to original patch to catch errors better. + use ifdef WIN32 instead of ifndef. + 2006-06-19 Zaheer Abbas Merali * configure.ac: diff --git a/gst/rtsp/rtspconnection.c b/gst/rtsp/rtspconnection.c index 221369d963..b1fb34f1a2 100644 --- a/gst/rtsp/rtspconnection.c +++ b/gst/rtsp/rtspconnection.c @@ -22,13 +22,34 @@ #include #include #include + +#ifdef WIN32 +#include +#else #include #include #include #include +#endif #include "rtspconnection.h" +#ifdef WIN32 +/* note that inet_aton is deprecated on unix because + * inet_addr returns -1 (INADDR_NONE) for the valid 255.255.255.255 + * address. */ +static int +inet_aton (const char *c, struct in_addr *paddr) +{ + paddr->s_addr = inet_addr (c); + + if (paddr->s_addr == INADDR_NONE) + return 0; + + return 1; +} +#endif + RTSPResult rtsp_connection_open (RTSPUrl * url, RTSPConnection ** conn) { @@ -129,6 +150,17 @@ rtsp_connection_send (RTSPConnection * conn, RTSPMessage * message) if (conn == NULL || message == NULL) return RTSP_EINVAL; +#ifdef WIN32 + WSADATA w; + int error = WSAStartup (0x0202, &w); + + if (error) + goto startup_error; + + if (w.wVersion != 0x0202) + goto version_error; +#endif + str = g_string_new (""); /* create request string, add CSeq */ @@ -183,6 +215,18 @@ rtsp_connection_send (RTSPConnection * conn, RTSPMessage * message) return RTSP_OK; +#ifdef WIN32 +startup_error: + { + GST_DEBUG_OBJECT (self, "Error %d on WSAStartup", error); + return RTSP_ERROR; + } +version_error: + { + WSACleanup (); + return RTSP_ERROR; + } +#endif write_error: { g_string_free (str, TRUE); @@ -536,8 +580,12 @@ rtsp_connection_close (RTSPConnection * conn) if (conn == NULL) return RTSP_EINVAL; - +#ifdef WIN32 + res = socketclose (conn->fd); + WSACleanup (); +#else res = close (conn->fd); +#endif conn->fd = -1; if (res != 0) goto sys_error;