rtpbin: add a caps accumulator for the request-pt-map signal
authorWim Taymans <wtaymans@redhat.com>
Tue, 21 Jan 2014 14:48:20 +0000 (15:48 +0100)
committerWim Taymans <wtaymans@redhat.com>
Tue, 21 Jan 2014 14:48:20 +0000 (15:48 +0100)
Add an accumulator that stops the signal emission as soon as a caps has
been retrieved. Otherwise the default handler would continue emitting
the signal and possibly overwrite the result with NULL again.

gst/rtpmanager/gstrtpbin.c

index fdeffe0..22efef2 100644 (file)
@@ -1675,6 +1675,22 @@ _gst_element_accumulator (GSignalInvocationHint * ihint,
   return (element == NULL);
 }
 
+static gboolean
+_gst_caps_accumulator (GSignalInvocationHint * ihint,
+    GValue * return_accu, const GValue * handler_return, gpointer dummy)
+{
+  GstCaps *caps;
+
+  caps = g_value_get_boxed (handler_return);
+  GST_DEBUG ("got caps %" GST_PTR_FORMAT, caps);
+
+  if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
+    g_value_set_boxed (return_accu, caps);
+
+  /* stop emission if we have a caps */
+  return (caps == NULL);
+}
+
 static void
 gst_rtp_bin_class_init (GstRtpBinClass * klass)
 {
@@ -1716,8 +1732,8 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
   gst_rtp_bin_signals[SIGNAL_REQUEST_PT_MAP] =
       g_signal_new ("request-pt-map", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, request_pt_map),
-      NULL, NULL, g_cclosure_marshal_generic, GST_TYPE_CAPS, 2, G_TYPE_UINT,
-      G_TYPE_UINT);
+      _gst_caps_accumulator, NULL, g_cclosure_marshal_generic, GST_TYPE_CAPS,
+      2, G_TYPE_UINT, G_TYPE_UINT);
 
     /**
    * GstRtpBin::payload-type-change: