From b113516241de2b8ddd71b85b22458d98acde4451 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 24 Sep 2020 13:13:00 -0400 Subject: [PATCH] rtpbin: Add clear-ssrc action This action signal will delegate to clear-ssrc onto the rtpssrcdemux element associated with the session. This allow rtpbin users to clear pads and elements for a specific ssrc that is known to no longer be in use. This happens when a pad is reused in rtpsrc or ristsrc. Part-of: --- docs/gst_plugins_cache.json | 15 +++++++++++++++ gst/rtpmanager/gstrtpbin.c | 39 +++++++++++++++++++++++++++++++++++++++ gst/rtpmanager/gstrtpbin.h | 1 + 3 files changed, 55 insertions(+) diff --git a/docs/gst_plugins_cache.json b/docs/gst_plugins_cache.json index cc6641a..01dc8be 100644 --- a/docs/gst_plugins_cache.json +++ b/docs/gst_plugins_cache.json @@ -16448,6 +16448,21 @@ "return-type": "void", "when": "last" }, + "clear-ssrc": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "guint" + }, + { + "name": "arg1", + "type": "guint" + } + ], + "return-type": "void", + "when": "last" + }, "get-internal-session": { "action": true, "args": [ diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index 6b558c0..622e455 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -292,6 +292,7 @@ enum SIGNAL_GET_INTERNAL_SESSION, SIGNAL_GET_STORAGE, SIGNAL_GET_INTERNAL_STORAGE, + SIGNAL_CLEAR_SSRC, SIGNAL_ON_NEW_SSRC, SIGNAL_ON_SSRC_COLLISION, @@ -1138,6 +1139,25 @@ gst_rtp_bin_get_internal_storage (GstRtpBin * bin, guint session_id) return internal_storage; } +static void +gst_rtp_bin_clear_ssrc (GstRtpBin * bin, guint session_id, guint32 ssrc) +{ + GstRtpBinSession *session; + GstElement *demux = NULL; + + GST_RTP_BIN_LOCK (bin); + GST_DEBUG_OBJECT (bin, "clearing ssrc %u for session %u", ssrc, session_id); + session = find_session_by_id (bin, (gint) session_id); + if (session) + demux = gst_object_ref (session->demux); + GST_RTP_BIN_UNLOCK (bin); + + if (demux) { + g_signal_emit_by_name (demux, "clear-ssrc", ssrc, NULL); + gst_object_unref (demux); + } +} + static GstElement * gst_rtp_bin_request_encoder (GstRtpBin * bin, guint session_id) { @@ -2152,6 +2172,24 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass) get_storage), NULL, NULL, NULL, GST_TYPE_ELEMENT, 1, G_TYPE_UINT); /** + * GstRtpBin::clear-ssrc: + * @rtpbin: the object which received the signal + * @id: the session id + * @ssrc: the ssrc + * + * Remove all pads from rtpssrcdemux element associated with the specified + * ssrc. This delegate the action signal to the rtpssrcdemux element + * associated with the specified session. + * + * Since: 1.20 + */ + gst_rtp_bin_signals[SIGNAL_CLEAR_SSRC] = + g_signal_new ("clear-ssrc", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GstRtpBinClass, + clear_ssrc), NULL, NULL, NULL, G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); + + /** * GstRtpBin::on-new-ssrc: * @rtpbin: the object which received the signal * @session: the session @@ -2768,6 +2806,7 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass) klass->get_storage = GST_DEBUG_FUNCPTR (gst_rtp_bin_get_storage); klass->get_internal_storage = GST_DEBUG_FUNCPTR (gst_rtp_bin_get_internal_storage); + klass->clear_ssrc = GST_DEBUG_FUNCPTR (gst_rtp_bin_clear_ssrc); klass->request_rtp_encoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_encoder); klass->request_rtp_decoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_decoder); klass->request_rtcp_encoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_encoder); diff --git a/gst/rtpmanager/gstrtpbin.h b/gst/rtpmanager/gstrtpbin.h index 1185c40..257c236 100644 --- a/gst/rtpmanager/gstrtpbin.h +++ b/gst/rtpmanager/gstrtpbin.h @@ -117,6 +117,7 @@ struct _GstRtpBinClass { RTPSession* (*get_internal_session) (GstRtpBin *rtpbin, guint session); GstElement* (*get_storage) (GstRtpBin *rtpbin, guint session); GObject* (*get_internal_storage) (GstRtpBin *rtpbin, guint session); + void (*clear_ssrc) (GstRtpBin *rtpbin, guint session, guint32 ssrc); /* session manager signals */ void (*on_new_ssrc) (GstRtpBin *rtpbin, guint session, guint32 ssrc); -- 2.7.4