[gst-cvs] gst-plugins-good: rtpbin: add property to remove pads automatically

Wim Taymans wtay at kemper.freedesktop.org
Mon Dec 21 06:08:17 PST 2009


Module: gst-plugins-good
Branch: master
Commit: 973469978865673c3b5b2dd79a180db5b4b169e6
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=973469978865673c3b5b2dd79a180db5b4b169e6

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Dec 21 15:05:09 2009 +0100

rtpbin: add property to remove pads automatically

Add a property called autoremove to automatically remove the pads of sources
that timed out.

Fixes #554839

---

 gst/rtpmanager/gstrtpbin.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index d92e2e3..dc48352 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -215,6 +215,8 @@ struct _GstRtpBinPrivate
 
   /* if we are shutting down or not */
   gint shutdown;
+
+  gboolean autoremove;
 };
 
 /* signals and args */
@@ -243,6 +245,7 @@ enum
 #define DEFAULT_SDES                 NULL
 #define DEFAULT_DO_LOST              FALSE
 #define DEFAULT_IGNORE_PT            FALSE
+#define DEFAULT_AUTOREMOVE           FALSE
 
 enum
 {
@@ -251,6 +254,7 @@ enum
   PROP_SDES,
   PROP_DO_LOST,
   PROP_IGNORE_PT,
+  PROP_AUTOREMOVE,
   PROP_LAST
 };
 
@@ -446,6 +450,9 @@ on_bye_timeout (GstElement * session, guint32 ssrc, GstRtpBinSession * sess)
 {
   g_signal_emit (sess->bin, gst_rtp_bin_signals[SIGNAL_ON_BYE_TIMEOUT], 0,
       sess->id, ssrc);
+
+  if (sess->bin->priv->autoremove)
+    g_signal_emit_by_name (sess->demux, "clear-ssrc", ssrc, NULL);
 }
 
 static void
@@ -453,6 +460,9 @@ on_timeout (GstElement * session, guint32 ssrc, GstRtpBinSession * sess)
 {
   g_signal_emit (sess->bin, gst_rtp_bin_signals[SIGNAL_ON_TIMEOUT], 0,
       sess->id, ssrc);
+
+  if (sess->bin->priv->autoremove)
+    g_signal_emit_by_name (sess->demux, "clear-ssrc", ssrc, NULL);
 }
 
 static void
@@ -1513,10 +1523,15 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class, PROP_IGNORE_PT,
-      g_param_spec_boolean ("ignore_pt", "Ignore PT",
+      g_param_spec_boolean ("ignore-pt", "Ignore PT",
           "Do not demultiplex based on PT values", DEFAULT_IGNORE_PT,
           G_PARAM_READWRITE));
 
+  g_object_class_install_property (gobject_class, PROP_AUTOREMOVE,
+      g_param_spec_boolean ("autoremove", "Auto Remove",
+          "Automatically removed timed out sources", DEFAULT_AUTOREMOVE,
+          G_PARAM_READWRITE));
+
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
   gstelement_class->request_new_pad =
       GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
@@ -1544,6 +1559,7 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
   rtpbin->latency = DEFAULT_LATENCY_MS;
   rtpbin->do_lost = DEFAULT_DO_LOST;
   rtpbin->ignore_pt = DEFAULT_IGNORE_PT;
+  rtpbin->priv->autoremove = DEFAULT_AUTOREMOVE;
 
   /* some default SDES entries */
   str = g_strdup_printf ("%s@%s", g_get_user_name (), g_get_host_name ());
@@ -1653,6 +1669,9 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
     case PROP_IGNORE_PT:
       rtpbin->ignore_pt = g_value_get_boolean (value);
       break;
+    case PROP_AUTOREMOVE:
+      rtpbin->priv->autoremove = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1684,6 +1703,9 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
     case PROP_IGNORE_PT:
       g_value_set_boolean (value, rtpbin->ignore_pt);
       break;
+    case PROP_AUTOREMOVE:
+      g_value_set_boolean (value, rtpbin->priv->autoremove);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;





More information about the Gstreamer-commits mailing list