ensonic gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/gst/dccp/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-bad
Changes by:     ensonic
Date:           Thu Nov 20 2008  16:01:41 UTC

Log message:
	patch by: Leandro Melo de Sales <[email protected]>
	* gst/dccp/gstdccp.c:
	* gst/dccp/gstdccp.h:
	* gst/dccp/gstdccpclientsink.c:
	* gst/dccp/gstdccpclientsink.h:
	* gst/dccp/gstdccpclientsrc.c:
	* gst/dccp/gstdccpserversink.c:
	* gst/dccp/gstdccpserversrc.c:
	* gst/dccp/gstdccpserversrc.h:
	  CodeStyle improvements and minor fixes to the DCCP plugin.
	  Fixes #553823.

Modified files:
    .               : ChangeLog
    gst/dccp        : gstdccp.c gstdccp.h gstdccpclientsink.c
                      gstdccpclientsink.h gstdccpclientsrc.c
                      gstdccpserversink.c gstdccpserversrc.c
                      gstdccpserversrc.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3716&r2=1.3717
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccp.c.diff?r1=1.4&r2=1.5
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccp.h.diff?r1=1.1&r2=1.2
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsink.c.diff?r1=1.1&r2=1.2
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsink.h.diff?r1=1.1&r2=1.2
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsrc.c.diff?r1=1.2&r2=1.3
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversink.c.diff?r1=1.2&r2=1.3
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversrc.c.diff?r1=1.1&r2=1.2
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversrc.h.diff?r1=1.1&r2=1.2

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3716
retrieving revision 1.3717
diff -u -d -r1.3716 -r1.3717
--- ChangeLog	20 Nov 2008 08:19:14 -0000	1.3716
+++ ChangeLog	20 Nov 2008 16:01:25 -0000	1.3717
@@ -1,3 +1,18 @@
+2008-11-20  Stefan Kost  <[email protected]>
+
+	patch by: Leandro Melo de Sales <[email protected]>
+	* gst/dccp/gstdccp.c:
+	* gst/dccp/gstdccp.h:
+	* gst/dccp/gstdccpclientsink.c:
+	* gst/dccp/gstdccpclientsink.h:
+	* gst/dccp/gstdccpclientsrc.c:
+	* gst/dccp/gstdccpserversink.c:
+	* gst/dccp/gstdccpserversrc.c:
+	* gst/dccp/gstdccpserversrc.h:
+	  CodeStyle improvements and minor fixes to the DCCP plugin.
+	  Fixes #553823.
 2008-11-20  Sebastian Dröge  <[email protected]>
 
 	* gst/rtpmanager/gstrtpjitterbuffer.c:
Index: gstdccp.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccp.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gstdccp.c	28 Aug 2008 17:16:51 -0000	1.4
+++ gstdccp.c	20 Nov 2008 16:01:26 -0000	1.5
@@ -36,14 +36,16 @@
 #endif
 /* Prototypes and definitions for private functions and not exported via gstdccp.h */
-gint gst_dccp_socket_write (int socket, const void *buf, size_t count,
-    int packet_size);
-gboolean gst_dccp_socket_connected (GstElement * element, int server_sock_fd);
+GstFlowReturn gst_dccp_socket_write (GstElement * element, int socket,
+    const void *buf, size_t count, int packet_size);
 struct sockaddr_in gst_dccp_create_sockaddr (GstElement * element, gchar * ip,
     int port);
-/* Resolves host to IP address
- * @return a gchar pointer containing the ip address or NULL
+/*
+ * Resolves host to IP address
+ * @param element - the element
+ * @return a gchar pointer containing the ip address or NULL if it
+ * couldn't resolve the host to a IP adress
  */
 gchar *
 gst_dccp_host_to_ip (GstElement * element, const gchar * host)
@@ -83,10 +85,15 @@
   return ip;
 }
-/* Read a buffer from the given socket
- * @returns:
- *   a GstBuffer from which data should be read
- *   or NULL, indicating a connection close or an error. Handle it with EOS.
+ * Read a buffer from the given socket
+ *
+ * @param this - the element that has the socket that will be read
+ * @param socket - the socket fd that will be read
+ * @param buf - the buffer with the data read from the socket
+ * @return GST_FLOW_OK if the read operation was successful
+ * or GST_FLOW_ERROR indicating a connection close or an error.
+ * Handle it with EOS.
 GstFlowReturn
 gst_dccp_read_buffer (GstElement * this, int socket, GstBuffer ** buf)
@@ -96,6 +103,8 @@
   int ret;
   ssize_t bytes_read;
   int readsize;
+  struct msghdr mh;
+  struct iovec iov;
   *buf = NULL;
@@ -124,7 +133,23 @@
   }
   *buf = gst_buffer_new_and_alloc (readsize);
-  bytes_read = read (socket, GST_BUFFER_DATA (*buf), readsize);
+  memset (&mh, 0, sizeof (mh));
+  mh.msg_name = NULL;
+  mh.msg_namelen = 0;
+  iov.iov_base = GST_BUFFER_DATA (*buf);
+  iov.iov_len = readsize;
+  mh.msg_iov = &iov;
+  mh.msg_iovlen = 1;
+  mh.msg_control = NULL;
+  mh.msg_controllen = 0;
+  bytes_read = recvmsg (socket, &mh, 0);
+  if (bytes_read != readsize) {
+    GST_DEBUG_OBJECT (this, ("Error while reading data"));
+    return GST_FLOW_ERROR;
+  }
   GST_LOG_OBJECT (this, "bytes read %" G_GSIZE_FORMAT, bytes_read);
   GST_LOG_OBJECT (this, "returning buffer of size %d", GST_BUFFER_SIZE (*buf));
@@ -132,7 +157,9 @@
   return GST_FLOW_OK;
-/* Create a new socket
+/* Create a new DCCP socket
  * @return the socket file descriptor
 gint
@@ -147,7 +174,10 @@
 /* Connect to a server
- * @return true in case of successfull connection, false otherwise
+ * @param server_sin - a struct with a server address and port
+ * @param sock_fd - the socket to connect
+ * @return TRUE in case of successful connection, FALSE otherwise
 gboolean
 gst_dccp_connect_to_server (GstElement * element, struct sockaddr_in server_sin,
@@ -158,11 +188,15 @@
   if (connect (sock_fd, (struct sockaddr *) &server_sin, sizeof (server_sin))) {
     switch (errno) {
       case ECONNREFUSED:
-        GST_ERROR_OBJECT (element, "Connection refused.");
+        GST_ELEMENT_ERROR (element, RESOURCE, OPEN_WRITE,
+            ("Connection to %s:%d refused.", inet_ntoa (server_sin.sin_addr),
+                ntohs (server_sin.sin_port)), (NULL));
         return FALSE;
         break;
       default:
-        GST_ERROR_OBJECT (element, "Connection failed.");
+        GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
+            ("Connect to %s:%d failed: %s", inet_ntoa (server_sin.sin_addr),
+                ntohs (server_sin.sin_port), g_strerror (errno)));
     }
@@ -173,6 +207,9 @@
 /* FIXME support only one client */
 /*
  * Accept connection on the server socket.
+ * @param server_sock_fd - the server socket file descriptor
  * @return the socket of the client connected to the server.
@@ -183,29 +220,30 @@
   struct sockaddr_in client_address;
   unsigned int client_address_len;
-  /* For some stupid reason, client_address and client_address_len has to be
-   * zeroed */
   memset (&client_address, 0, sizeof (client_address));
   client_address_len = 0;
   if ((client_sock_fd =
           accept (server_sock_fd, (struct sockaddr *) &client_address,
               &client_address_len)) == -1) {
+    GST_ELEMENT_ERROR (element, RESOURCE, OPEN_WRITE, (NULL),
+        ("Could not accept client on server socket %d: %s (%d)",
+            server_sock_fd, g_strerror (errno), errno));
     return -1;
-  /* to support multiple connection, fork here a new thread passing the
-   * client_sock_fd returned by accept function.
-   */
-  GST_DEBUG_OBJECT (element, "added new client ip %s with fd %d",
+  GST_DEBUG_OBJECT (element, "Added new client ip %s with fd %d.",
       inet_ntoa (client_address.sin_addr), client_sock_fd);
-  /* return the thread object, instead of the fd */
   return client_sock_fd;
  * Bind a server address.
+ * @param server_sock_fd - the server socket fd
+ * @param server_sin - the address and the port to bind the server on
  * @return true in success, false otherwise.
@@ -214,14 +252,15 @@
 {
-  GST_DEBUG_OBJECT (element, "binding server socket to address");
+  GST_DEBUG_OBJECT (element, "Binding server socket to address.");
   ret = bind (server_sock_fd, (struct sockaddr *) &server_sin,
       sizeof (server_sin));
   if (ret) {
         GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
-            ("bind on port %d failed: %s", server_sin.sin_port,
+            ("Bind on port %d failed: %s", ntohs (server_sin.sin_port),
                 g_strerror (errno)));
@@ -230,45 +269,65 @@
   return TRUE;
+ * Listen on server socket.
+ * @return true in success, false otherwise.
+ */
 gst_dccp_listen_server_socket (GstElement * element, int server_sock_fd)
-  GST_DEBUG_OBJECT (element, "listening on server socket %d with queue of %d",
+  GST_DEBUG_OBJECT (element, "Listening on server socket %d with queue of %d",
       server_sock_fd, DCCP_BACKLOG);
   if (listen (server_sock_fd, DCCP_BACKLOG) == -1) {
     GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
         ("Could not listen on server socket: %s", g_strerror (errno)));
     return FALSE;
   GST_DEBUG_OBJECT (element,
-      "listened on server socket %d, returning from connection setup",
+      "Listened on server socket %d, returning from connection setup",
       server_sock_fd);
-/* FIXME */
-gboolean
-gst_dccp_socket_connected (GstElement * element, int server_sock_fd)
-{
-  return FALSE;
-}
-
 /* Write buffer to given socket incrementally.
- * Returns number of bytes written.
+ * @param socket - the socket
+ * @param buf - the buffer that will be written
+ * @param size - the number of bytes of the buffer
+ * @param packet_size - the MTU
+ * @return the number of bytes written.
-gint
-gst_dccp_socket_write (int socket, const void *buf, size_t size,
-    int packet_size)
+GstFlowReturn
+gst_dccp_socket_write (GstElement * element, int socket, const void *buf,
+    size_t size, int packet_size)
   size_t bytes_written = 0;
   ssize_t wrote;
   while (bytes_written < size) {
     do {
-      wrote = write (socket, (const char *) buf + bytes_written,
-          MIN (packet_size, size - bytes_written));
+      mh.msg_name = NULL;
+      mh.msg_namelen = 0;
+      iov.iov_base = (char *) buf + bytes_written;
+      iov.iov_len = MIN (packet_size, size - bytes_written);
+      mh.msg_iov = &iov;
+      mh.msg_iovlen = 1;
+      mh.msg_control = NULL;
+      mh.msg_controllen = 0;
+      wrote = sendmsg (socket, &mh, 0);
     } while (wrote == -1 && errno == EAGAIN);
     /* TODO print the send error */
@@ -276,17 +335,35 @@
   if (bytes_written < 0)
-    GST_WARNING ("error while writing");
+    GST_WARNING ("Error while writing.");
   else
-    GST_LOG ("wrote %" G_GSIZE_FORMAT " bytes succesfully", bytes_written);
-  return bytes_written;
+    GST_LOG_OBJECT (element, "Wrote %" G_GSIZE_FORMAT " bytes succesfully.",
+        bytes_written);
+  if (bytes_written != size) {
+    GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
+        ("Error while sending data to socket %d.", socket),
+        ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
+            bytes_written, size, g_strerror (errno)));
+  return GST_FLOW_OK;
+/* Write buffer to given socket.
+ * @param this - the element
+ * @param client_sock_fd - the client socket
+ * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise.
 gst_dccp_send_buffer (GstElement * this, GstBuffer * buffer, int client_sock_fd,
     int packet_size)
-  size_t wrote;
+//  size_t wrote;
   gint size = 0;
   guint8 *data;
@@ -296,21 +373,17 @@
   GST_LOG_OBJECT (this, "writing %d bytes", size);
   if (packet_size < 0) {
-    GST_LOG_OBJECT (this, "error getting MTU");
     return GST_FLOW_ERROR;
-  wrote = gst_dccp_socket_write (client_sock_fd, data, size, packet_size);
-  if (wrote != size) {
-    GST_DEBUG_OBJECT (this, ("Error while sending data"));
-    return GST_FLOW_ERROR;
-  }
-  return GST_FLOW_OK;
+  return gst_dccp_socket_write (this, client_sock_fd, data, size, packet_size);
  * Create socket address.
+ * @param ip - the ip address
+ * @param port - the port
  * @return sockaddr_in.
 struct sockaddr_in
@@ -326,6 +399,12 @@
   return sin;
+ * Make address reusable.
+ * @param sock_fd - the socket
+ * @return TRUE if the operation was successful, FALSE otherwise.
 gst_dccp_make_address_reusable (GstElement * element, int sock_fd)
@@ -340,7 +419,13 @@
-/* DCCP socket specific stuffs */
+ * Set DCCP congestion control.
+ * @param ccid - the ccid number
 gst_dccp_set_ccid (GstElement * element, int sock_fd, uint8_t ccid)
@@ -408,6 +493,12 @@
   return ccid;
+ * Get the socket MTU.
+ * @param sock - the socket
+ * @return the MTU if the operation was successful, -1 otherwise.
 gst_dccp_get_max_packet_size (GstElement * element, int sock)
@@ -423,36 +514,12 @@
   return size;
-/* Still not used and need to be FIXED */
-gst_dccp_set_sock_windowsize (GstElement * element, int sock, int winSize,
-    gboolean inSend)
+void
+gst_dccp_socket_close (GstElement * element, int *socket)
-#ifdef SO_SNDBUF
-  int rc;
-  if (!inSend) {
-    /* receive buffer -- set
-     * note: results are verified after connect() or listen(),
-     * since some OS's don't show the corrected value until then. */
-    rc = setsockopt (sock, SOL_DCCP, SO_RCVBUF,
-        (char *) &winSize, sizeof (winSize));
-    GST_DEBUG_OBJECT (element, "set rcv sockbuf: %d", winSize);
-  } else {
-    /* send buffer -- set
-    rc = setsockopt (sock, SOL_DCCP, SO_SNDBUF,
-    GST_DEBUG_OBJECT (element, "set snd sockbuf: %d", winSize);
-  if (rc < 0) {
-    GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS, (NULL),
-        ("Could not set window size %d: %s", errno, g_strerror (errno)));
-    return FALSE;
+  if (socket >= 0) {
+    GST_DEBUG_OBJECT (element, "closing socket");
+    close (*socket);
+    *socket = -1;
-#endif /* SO_SNDBUF */
-  return TRUE;
Index: gstdccp.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccp.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gstdccp.h	21 Aug 2008 13:22:31 -0000	1.1
+++ gstdccp.h	20 Nov 2008 16:01:26 -0000	1.2
@@ -90,7 +90,6 @@
 					int client_sock_fd, int packet_size);
 gboolean gst_dccp_make_address_reusable (GstElement * element, int sock_fd);
-gboolean gst_dccp_set_sock_windowsize(GstElement * element, int sock, int winSize,
-															gboolean inSend);
+void gst_dccp_socket_close (GstElement * element, int * socket);
 #endif /* __GST_DCCP_H__ */
Index: gstdccpclientsink.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsink.c,v
--- gstdccpclientsink.c	21 Aug 2008 13:22:31 -0000	1.1
+++ gstdccpclientsink.c	20 Nov 2008 16:01:27 -0000	1.2
@@ -96,6 +96,11 @@
 static guint gst_dccp_client_sink_signals[LAST_SIGNAL] = { 0 };
+ * Write buffer to client socket.
 static GstFlowReturn
 gst_dccp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
@@ -172,6 +177,13 @@
+ * Starts the element. If the sockfd property was not the default, this method
+ * will create a new socket and connect to the server.
+ * @param bsink - the element
+ * @return TRUE if the send operation was successful, FALSE otherwise.
 static gboolean
 gst_dccp_client_sink_start (GstBaseSink * bsink)
@@ -250,10 +262,8 @@
   sink = GST_DCCP_CLIENT_SINK (bsink);
-  if (sink->sock_fd != -1 && sink->closed) {
-    GST_DEBUG_OBJECT (sink, "closing socket");
-    close (sink->sock_fd);
-    sink->sock_fd = -1;
+  if (sink->sock_fd != DCCP_DEFAULT_SOCK_FD && sink->closed) {
+    gst_dccp_socket_close (GST_ELEMENT (sink), &(sink->sock_fd));
@@ -276,10 +286,9 @@
   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
       g_param_spec_int ("port", "Port",
-          "The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
+          "The port to send the packets to", 0, G_MAXUINT16,
           DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
-/* FIXME property server_ip */
   g_object_class_install_property (gobject_class, PROP_HOST,
       g_param_spec_string ("host", "Host",
           "The host IP address to send packets to", DCCP_DEFAULT_HOST,
@@ -303,8 +312,8 @@
   /* signals */
   /**
    * GstDccpClientSink::connected:
-   * @sink: the gstdccpclientsink instance
-   * @fd: the connected socket fd
+   * @sink: the gstdccpclientsink element that emitted this signal
+   * @fd: the connected socket file descriptor
    *
    * Sign that the element has connected, return the fd of the socket.
    */
Index: gstdccpclientsink.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsink.h,v
--- gstdccpclientsink.h	21 Aug 2008 13:22:31 -0000	1.1
+++ gstdccpclientsink.h	20 Nov 2008 16:01:27 -0000	1.2
@@ -47,6 +47,11 @@
 typedef struct _GstDCCPClientSinkClass GstDCCPClientSinkClass;
+/**
+ * GstDCCPClientSink:
+ * dccpclientsink object structure.
 struct _GstDCCPClientSink
   GstBaseSink element;
Index: gstdccpclientsrc.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpclientsrc.c,v
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gstdccpclientsrc.c	28 Aug 2008 17:16:51 -0000	1.2
+++ gstdccpclientsrc.c	20 Nov 2008 16:01:27 -0000	1.3
@@ -102,6 +102,11 @@
 static guint gst_dccp_client_src_signals[LAST_SIGNAL] = { 0 };
+ * Read a buffer from the client socket
 gst_dccp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
@@ -220,6 +225,13 @@
+ * @param bsrc - the element
 gst_dccp_client_src_start (GstBaseSrc * bsrc)
@@ -323,10 +335,8 @@
   src = GST_DCCP_CLIENT_SRC (bsrc);
-  if (src->sock_fd != -1 && src->closed) {
-    GST_DEBUG_OBJECT (src, "closing socket");
-    close (src->sock_fd);
-    src->sock_fd = -1;
+  if (src->sock_fd != DCCP_DEFAULT_SOCK_FD && src->closed) {
+    gst_dccp_socket_close (GST_ELEMENT (src), &(src->sock_fd));
@@ -353,7 +363,7 @@
+          "The port to receive packets from", 0, G_MAXUINT16,
@@ -383,8 +393,8 @@
    * GstDccpClientSrc::connected:
-   * @src: the gstdccpclientsrc instance
+   * @src: the gstdccpclientsrc element that emitted this signal
    * Reports that the element has connected, giving the fd of the socket
Index: gstdccpserversink.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversink.c,v
--- gstdccpserversink.c	26 Aug 2008 11:18:38 -0000	1.2
+++ gstdccpserversink.c	20 Nov 2008 16:01:27 -0000	1.3
@@ -98,6 +98,13 @@
 static guint gst_dccp_server_sink_signals[LAST_SIGNAL] = { 0 };
+ * Create a new client with the socket and the MTU
+ * @param element - the gstdccpserversink instance
+ * @param socket - the client socket
+ * @return the client
 static Client *
 gst_dccp_server_create_client (GstElement * element, int socket)
@@ -106,6 +113,9 @@
   client->pksize = gst_dccp_get_max_packet_size (element, client->socket);
   client->flow_status = GST_FLOW_OK;
+  GST_DEBUG_OBJECT (element, "Creating a new client with fd %d and MTU %d.",
+      client->socket, client->pksize);
   /* the socket is connected */
   g_signal_emit (element, gst_dccp_server_sink_signals[SIGNAL_CONNECTED], 0,
       socket);
@@ -113,6 +123,11 @@
   return client;
+ * Wait connections of new clients
+ * @param arg - the gstdccpserversink instance
 static void *
 gst_dccp_server_accept_new_clients (void *arg)
@@ -132,6 +147,11 @@
+ * Send the buffer to a client
+ * @param arg - the client
 gst_dccp_server_send_buffer (void *arg)
@@ -148,7 +168,10 @@
   return NULL;
-/* Remove clients with problems to send */
+/* Remove clients with problems to send.
 gst_dccp_server_delete_dead_clients (void *arg)
@@ -185,23 +208,25 @@
   this->clients = NULL;
+ * will wait for a client connection.  If wait-connections property is true, it
+ * creates a thread to wait for new client connections.
 gst_dccp_server_sink_start (GstBaseSink * bsink)
   GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (bsink);
-  int ret = 1;
   Client *client;
-  /* create socket */
   if ((sink->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (sink))) < 0) {
-  /* make address reusable */
-  if (setsockopt (sink->sock_fd, SOL_SOCKET, SO_REUSEADDR,
-          (void *) &ret, sizeof (ret)) < 0) {
-    GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
-        ("Could not setsockopt: %s", g_strerror (errno)));
+  if (!gst_dccp_make_address_reusable (GST_ELEMENT (sink), sink->sock_fd)) {
@@ -290,16 +315,14 @@
     pthread_cancel (accept_thread_id);
-  if (sink->sock_fd != -1 && sink->closed == TRUE) {
+  gst_dccp_socket_close (GST_ELEMENT (sink), &(sink->sock_fd));
   pthread_mutex_lock (&lock);
   for (i = 0; i < g_list_length (sink->clients); i++) {
     Client *client = (Client *) g_list_nth_data (sink->clients, i);
-    close (client->socket);
+    if (client->socket != DCCP_DEFAULT_CLIENT_SOCK_FD && sink->closed == TRUE) {
+      gst_dccp_socket_close (GST_ELEMENT (sink), &(client->socket));
+    }
     g_free (client);
   pthread_mutex_unlock (&lock);
@@ -391,7 +414,7 @@
+          "The port to listen to", 0, G_MAXUINT16,
   g_object_class_install_property (gobject_class, PROP_CLIENT_SOCK_FD,
@@ -401,7 +424,7 @@
   g_object_class_install_property (gobject_class, PROP_CLOSED,
       g_param_spec_boolean ("close-socket", "Close",
-          "Close socket at end of stream",
+          "Close the client sockets at end of stream",
           DCCP_DEFAULT_CLOSED, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, PROP_CCID,
@@ -418,8 +441,8 @@
    * GstDccpServerSink::connected:
-   * @src: the gstdccpserversink instance
+   * @sink: the gstdccpserversink element that emitted this signal
Index: gstdccpserversrc.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversrc.c,v
--- gstdccpserversrc.c	21 Aug 2008 13:22:32 -0000	1.1
+++ gstdccpserversrc.c	20 Nov 2008 16:01:27 -0000	1.2
@@ -56,7 +56,6 @@
 #include <fcntl.h>
 #define DCCP_DEFAULT_CAPS        NULL
-#define DCCP_DEFAULT_LISTEN_HOST NULL   /* listen on all interfaces */
 /* signals */
 enum
@@ -70,7 +69,6 @@
   PROP_0,
   PROP_PORT,
-  PROP_HOST,
   PROP_CLIENT_SOCK_FD,
   PROP_CLOSED,
   PROP_CCID,
@@ -97,6 +95,11 @@
 static guint gst_dccp_server_src_signals[LAST_SIGNAL] = { 0 };
+ * Read a buffer from the server socket
 gst_dccp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
@@ -137,14 +140,6 @@
   GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (object);
   switch (prop_id) {
-    case PROP_HOST:
-      if (!g_value_get_string (value)) {
-        g_warning ("host property cannot be NULL");
-        break;
-      }
-      g_free (src->host);
-      src->host = g_strdup (g_value_get_string (value));
-      break;
     case PROP_PORT:
       src->port = g_value_get_int (value);
       break;
@@ -193,9 +188,6 @@
-      g_value_set_string (value, src->host);
       g_value_set_int (value, src->port);
@@ -217,7 +209,13 @@
+ * will create a new server socket and wait for a client connection.
 gst_dccp_server_src_start (GstBaseSrc * bsrc)
@@ -229,7 +227,9 @@
       return FALSE;
-    gst_dccp_make_address_reusable (GST_ELEMENT (src), src->sock_fd);
+    if (!gst_dccp_make_address_reusable (GST_ELEMENT (src), src->sock_fd)) {
+      return FALSE;
     /* name the server socket */
     memset (&src->server_sin, 0, sizeof (src->server_sin));
@@ -283,7 +283,6 @@
     GstDCCPServerSrcClass * g_class)
   this->port = DCCP_DEFAULT_PORT;
-  this->host = g_strdup (DCCP_DEFAULT_HOST);
   this->sock_fd = DCCP_DEFAULT_SOCK_FD;
   this->client_sock_fd = DCCP_DEFAULT_CLIENT_SOCK_FD;
   this->closed = DCCP_DEFAULT_CLOSED;
@@ -314,8 +313,6 @@
     this->caps = NULL;
-  g_free (this->host);
   G_OBJECT_CLASS (parent_class)->finalize (gobject);
@@ -327,10 +324,9 @@
   src = GST_DCCP_SERVER_SRC (bsrc);
-  if (src->sock_fd != -1 && src->closed == TRUE) {
+  gst_dccp_socket_close (GST_ELEMENT (src), &(src->sock_fd));
+  if (src->client_sock_fd != DCCP_DEFAULT_CLIENT_SOCK_FD && src->closed == TRUE) {
+    gst_dccp_socket_close (GST_ELEMENT (src), &(src->client_sock_fd));
@@ -354,13 +350,9 @@
-  g_object_class_install_property (gobject_class, PROP_HOST,
-      g_param_spec_string ("host", "Host", "The hostname to listen as",
-          DCCP_DEFAULT_LISTEN_HOST, G_PARAM_READWRITE));
       g_param_spec_int ("sockfd", "Socket fd",
           "The client socket file descriptor", -1, G_MAXINT,
@@ -368,7 +360,7 @@
       g_param_spec_boolean ("close-socket", "Close socket",
-          "Close socket at the end of stream", DCCP_DEFAULT_CLOSED,
+          "Close client socket at the end of stream", DCCP_DEFAULT_CLOSED,
           G_PARAM_READWRITE));
@@ -383,8 +375,8 @@
    * GstDccpServerSrc::connected:
-   * @src: the gstdccpserversrc instance
+   * @src: the gstdccpserversrc element that emitted this signal
Index: gstdccpserversrc.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/dccp/gstdccpserversrc.h,v
--- gstdccpserversrc.h	21 Aug 2008 13:22:32 -0000	1.1
+++ gstdccpserversrc.h	20 Nov 2008 16:01:27 -0000	1.2
@@ -53,7 +53,6 @@
   /* server information */
   int port;
-  gchar *host;
   struct sockaddr_in server_sin;
   /* socket */

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.