gst/rtsp/: replaced closesocket and close in code with one CLOSE_SOCKET.
authorWim Taymans <wim.taymans@gmail.com>
Mon, 10 Jul 2006 16:41:57 +0000 (16:41 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 10 Jul 2006 16:41:57 +0000 (16:41 +0000)
Original commit message from CVS:
* gst/rtsp/Makefile.am:
* gst/rtsp/rtspconnection.c: (rtsp_connection_send),
(rtsp_connection_close):
* gst/rtsp/rtspdefs.h:
replaced closesocket and close in code with one CLOSE_SOCKET.
Some more cleanups. Fixes #345301.

ChangeLog
gst/rtsp/Makefile.am
gst/rtsp/rtspconnection.c
gst/rtsp/rtspdefs.h

index ee81d4c..7676ffb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-07-10  Wim Taymans  <wim@fluendo.com>
+
+       * gst/rtsp/Makefile.am:
+       * gst/rtsp/rtspconnection.c: (rtsp_connection_send),
+       (rtsp_connection_close):
+       * gst/rtsp/rtspdefs.h:
+       replaced closesocket and close in code with one CLOSE_SOCKET. 
+       Some more cleanups. Fixes #345301.
+
 2006-07-10  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst/autodetect/gstautoaudiosink.c:
index 85c2dad..86e0a2a 100644 (file)
@@ -2,21 +2,21 @@ plugin_LTLIBRARIES = libgstrtsp.la
 
 libgstrtsp_la_SOURCES = gstrtsp.c gstrtspsrc.c \
                        gstrtpdec.c             \
-                       rtspconnection.c        \
-                       rtspdefs.c              \
-                       rtspmessage.c           \
+                       rtspconnection.c        \
+                       rtspdefs.c              \
+                       rtspmessage.c           \
                        rtsptransport.c         \
                        rtspurl.c               \
                        sdpmessage.c
 
 libgstrtsp_la_CFLAGS = $(GST_CFLAGS)
-libgstrtsp_la_LIBADD = $(GST_LIBS)
+libgstrtsp_la_LIBADD = $(GST_LIBS) $(WIN32_LIBS)
 libgstrtsp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 
 check_PROGRAMS = test
 
 test_SOURCES = test.c rtspdefs.c rtspurl.c rtspconnection.c rtspmessage.c rtsptransport.c sdpmessage.c
 test_CFLAGS = $(GST_CFLAGS)
-test_LDFLAGS = $(GST_LIBS)
+test_LDFLAGS = $(GST_LIBS) $(WIN32_LIBS)
 
 noinst_HEADERS = gstrtspsrc.h gstrtsp.h gstrtpdec.h rtsptransport.h rtsp.h rtspurl.h rtspconnection.h rtspdefs.h rtspmessage.h sdp.h sdpmessage.h
index 2be3ef6..65332cd 100644 (file)
 /* we include this here to get the G_OS_* defines */
 #include <glib.h>
 
-#ifdef G_OS_UNIX
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#else
 #include <netdb.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #endif
 
-#ifdef G_OS_WIN32
-#include <winsock2.h>
-#endif
 
 #include "rtspconnection.h"
 
 #ifdef G_OS_WIN32
+#define CLOSE_SOCKET(sock) closesocket(sock);
+#else
+#define CLOSE_SOCKET(sock) close(sock);
+#endif
+
+#ifdef G_OS_WIN32
 /* note that inet_aton is deprecated on unix because
  * inet_addr returns -1 (INADDR_NONE) for the valid 255.255.255.255
  * address. */
@@ -224,12 +229,15 @@ rtsp_connection_send (RTSPConnection * conn, RTSPMessage * message)
 startup_error:
   {
     GST_DEBUG_OBJECT (self, "Error %d on WSAStartup", error);
-    return RTSP_ERROR;
+    g_warning ("Error %d on WSAStartup", error);
+    return RTSP_EWSASTART;
   }
 version_error:
   {
+    g_warning ("Windows sockets are not version 0x202 (current 0x%x)",
+        w.wVersion);
     WSACleanup ();
-    return RTSP_ERROR;
+    return RTSP_EWSAVERSION;
   }
 #endif
 write_error:
@@ -586,13 +594,10 @@ rtsp_connection_close (RTSPConnection * conn)
   if (conn == NULL)
     return RTSP_EINVAL;
 
+  res = CLOSE_SOCKET (conn->fd);
 #ifdef G_OS_WIN32
-  res = socketclose (conn->fd);
   WSACleanup ();
-#else
-  res = close (conn->fd);
 #endif
-
   conn->fd = -1;
   if (res != 0)
     goto sys_error;
index c5b4474..169ce48 100644 (file)
 G_BEGIN_DECLS
 
 typedef enum {
-  RTSP_OK       =  0,
+  RTSP_OK          =  0,
   /* errors */
-  RTSP_EINVAL   = -1,
-  RTSP_ENOMEM   = -2,
-  RTSP_ERESOLV  = -3,
-  RTSP_ENOTIMPL = -4,
-  RTSP_ESYS     = -5,
-  RTSP_EPARSE   = -6,
+  RTSP_EINVAL      = -1,
+  RTSP_ENOMEM      = -2,
+  RTSP_ERESOLV     = -3,
+  RTSP_ENOTIMPL    = -4,
+  RTSP_ESYS        = -5,
+  RTSP_EPARSE      = -6,
+  RTSP_EWSASTART   = -7,
+  RTSP_EWSAVERSION = -8,
+
 } RTSPResult;
 
 typedef enum {