subparse: fix off by one offset calculation
[platform/upstream/gstreamer.git] / gst / tcp / gstmultihandlesink.c
index 1727bc6..9b9eb64 100644 (file)
@@ -17,8 +17,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
 #include "gstmultihandlesink.h"
 #include "gsttcp-marshal.h"
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
 #ifndef G_OS_WIN32
 #include <netinet/in.h>
 #endif
@@ -416,7 +420,7 @@ gst_multi_handle_sink_class_init (GstMultiHandleSinkClass * klass)
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_BURST_VALUE,
       g_param_spec_uint64 ("burst-value", "Burst value",
-          "The amount of burst expressed in burst-unit", 0, G_MAXUINT64,
+          "The amount of burst expressed in burst-format", 0, G_MAXUINT64,
           DEFAULT_BURST_VALUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class, PROP_QOS_DSCP,
@@ -460,7 +464,7 @@ gst_multi_handle_sink_class_init (GstMultiHandleSinkClass * klass)
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&sinktemplate));
 
-  gst_element_class_set_details_simple (gstelement_class,
+  gst_element_class_set_static_metadata (gstelement_class,
       "Multi socket sink", "Sink/Network",
       "Send data to multiple sockets",
       "Thomas Vander Stichele <thomas at apestaart dot org>, "
@@ -474,12 +478,14 @@ gst_multi_handle_sink_class_init (GstMultiHandleSinkClass * klass)
   klass->client_queue_buffer =
       GST_DEBUG_FUNCPTR (gst_multi_handle_sink_client_queue_buffer);
 
+#if 0
   klass->add = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_add);
   klass->add_full = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_add_full);
   klass->remove = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_remove);
   klass->remove_flush = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_remove_flush);
+#endif
+
   klass->clear = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_clear);
-  klass->get_stats = GST_DEBUG_FUNCPTR (gst_multi_handle_sink_get_stats);
 
   GST_DEBUG_CATEGORY_INIT (multihandlesink_debug, "multihandlesink", 0,
       "Multi socket sink");
@@ -531,7 +537,7 @@ gint
 gst_multi_handle_sink_setup_dscp_client (GstMultiHandleSink * sink,
     GstMultiHandleClient * client)
 {
-#ifndef IP_TOS
+#if !defined(IP_TOS) || !defined(HAVE_SYS_SOCKET_H)
   return 0;
 #else
   gint tos;
@@ -650,6 +656,12 @@ gst_multi_handle_sink_add_full (GstMultiHandleSink * sink,
   GstMultiHandleSinkClass *mhsinkclass =
       GST_MULTI_HANDLE_SINK_GET_CLASS (mhsink);
 
+  if (!sink->running) {
+    g_warning ("Element %s must be set to READY, PAUSED or PLAYING state "
+        "before clients can be added", GST_OBJECT_NAME (sink));
+    return;
+  }
+
   mhsinkclass->handle_debug (handle, debug);
   GST_DEBUG_OBJECT (sink, "%s adding client, sync_method %d, "
       "min_format %d, min_value %" G_GUINT64_FORMAT
@@ -689,8 +701,7 @@ gst_multi_handle_sink_add_full (GstMultiHandleSink * sink,
 
   CLIENTS_UNLOCK (sink);
 
-  g_signal_emit (G_OBJECT (sink),
-      mhsinkclass->signals[GST_MULTI_HANDLE_SIGNAL_CLIENT_ADDED], 0, handle);
+  mhsinkclass->emit_client_added (mhsink, handle);
 
   return;
 
@@ -707,9 +718,8 @@ duplicate:
   {
     CLIENTS_UNLOCK (sink);
     GST_WARNING_OBJECT (sink, "%s duplicate client found, refusing", debug);
-    g_signal_emit (G_OBJECT (sink),
-        mhsinkclass->signals[GST_MULTI_HANDLE_SIGNAL_CLIENT_REMOVED], 0,
-        handle, GST_CLIENT_STATUS_DUPLICATE);
+    mhsinkclass->emit_client_removed (mhsink, handle,
+        GST_CLIENT_STATUS_DUPLICATE);
     return;
   }
 }
@@ -977,9 +987,7 @@ gst_multi_handle_sink_remove_client_link (GstMultiHandleSink * sink,
    * might query some properties */
   CLIENTS_UNLOCK (sink);
 
-  g_signal_emit (G_OBJECT (sink),
-      mhsinkclass->signals[GST_MULTI_HANDLE_SIGNAL_CLIENT_REMOVED], 0,
-      mhclient->handle, mhclient->status);
+  mhsinkclass->emit_client_removed (sink, mhclient->handle, mhclient->status);
 
   /* lock again before we remove the client completely */
   CLIENTS_LOCK (sink);
@@ -1004,13 +1012,12 @@ gst_multi_handle_sink_remove_client_link (GstMultiHandleSink * sink,
 
   CLIENTS_UNLOCK (sink);
 
+  /* sub-class must implement this to emit the client-$handle-removed signal */
+  g_assert (mhsinkclass->client_free != NULL);
+
   /* and the handle is really gone now */
-  g_signal_emit (G_OBJECT (sink),
-      mhsinkclass->signals[GST_MULTI_HANDLE_SIGNAL_CLIENT_HANDLE_REMOVED],
-      0, mhclient->handle);
+  mhsinkclass->client_free (sink, mhclient);
 
-  if (mhsinkclass->client_free)
-    mhsinkclass->client_free (mhclient);
   g_free (mhclient);
 
   CLIENTS_LOCK (sink);