From b5f1969406cb88d2ab131dfc8273a2b62a01ddba Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 7 Mar 2012 15:22:36 +0100 Subject: [PATCH] rtpbin: improve cleanup Reuse cleanup methods to make sure we remove all pads correctly --- gst/rtpmanager/gstrtpbin.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index d5d6ca6..997c275 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -305,6 +305,10 @@ static GstCaps *pt_map_requested (GstElement * element, guint pt, GstRtpBinSession * session); static void payload_type_change (GstElement * element, guint pt, GstRtpBinSession * session); +static void remove_recv_rtp (GstRtpBin * rtpbin, GstRtpBinSession * session); +static void remove_recv_rtcp (GstRtpBin * rtpbin, GstRtpBinSession * session); +static void remove_send_rtp (GstRtpBin * rtpbin, GstRtpBinSession * session); +static void remove_rtcp (GstRtpBin * rtpbin, GstRtpBinSession * session); static void free_client (GstRtpBinClient * client, GstRtpBin * bin); static void free_stream (GstRtpBinStream * stream); @@ -641,28 +645,12 @@ free_session (GstRtpBinSession * sess, GstRtpBin * bin) gst_element_set_state (sess->demux, GST_STATE_NULL); gst_element_set_state (sess->session, GST_STATE_NULL); - if (sess->recv_rtp_sink != NULL) { - gst_element_release_request_pad (sess->session, sess->recv_rtp_sink); - gst_object_unref (sess->recv_rtp_sink); - } - if (sess->recv_rtp_src != NULL) - gst_object_unref (sess->recv_rtp_src); - if (sess->recv_rtcp_sink != NULL) { - gst_element_release_request_pad (sess->session, sess->recv_rtcp_sink); - gst_object_unref (sess->recv_rtcp_sink); - } - if (sess->sync_src != NULL) - gst_object_unref (sess->sync_src); - if (sess->send_rtp_sink != NULL) { - gst_element_release_request_pad (sess->session, sess->send_rtp_sink); - gst_object_unref (sess->send_rtp_sink); - } - if (sess->send_rtp_src != NULL) - gst_object_unref (sess->send_rtp_src); - if (sess->send_rtcp_src != NULL) { - gst_element_release_request_pad (sess->session, sess->send_rtcp_src); - gst_object_unref (sess->send_rtcp_src); - } + GST_RTP_BIN_LOCK (bin); + remove_recv_rtp (bin, sess); + remove_recv_rtcp (bin, sess); + remove_send_rtp (bin, sess); + remove_rtcp (bin, sess); + GST_RTP_BIN_UNLOCK (bin); gst_bin_remove (GST_BIN_CAST (bin), sess->session); gst_bin_remove (GST_BIN_CAST (bin), sess->demux); -- 2.7.4