From f6b7f47cf430393041bd4262ddac2bb51a3a8a1d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 12 Sep 2007 21:23:47 +0000 Subject: gst/rtpmanager/: Various leak fixes. Original commit message from CVS: * gst/rtpmanager/gstrtpbin.c: (create_session), (free_session), (get_client), (free_client), (gst_rtp_bin_associate), (free_stream), (gst_rtp_bin_class_init), (gst_rtp_bin_dispose), (gst_rtp_bin_finalize): * gst/rtpmanager/gstrtpjitterbuffer.c: (gst_rtp_jitter_buffer_class_init), (gst_rtp_jitter_buffer_finalize): * gst/rtpmanager/gstrtpptdemux.c: (gst_rtp_pt_demux_release): * gst/rtpmanager/gstrtpsession.c: (gst_rtp_session_finalize), (gst_rtp_session_set_property), (gst_rtp_session_chain_recv_rtp), (gst_rtp_session_chain_send_rtp): * gst/rtpmanager/gstrtpssrcdemux.c: (gst_rtp_ssrc_demux_class_init), (gst_rtp_ssrc_demux_dispose): * gst/rtpmanager/rtpsession.c: (rtp_session_finalize): * gst/rtpmanager/rtpsession.h: Various leak fixes. --- ChangeLog | 19 +++++++++ gst/rtpmanager/gstrtpbin.c | 78 +++++++++++++++++++++++++++++++++++-- gst/rtpmanager/gstrtpjitterbuffer.c | 17 ++++---- gst/rtpmanager/gstrtpptdemux.c | 1 + gst/rtpmanager/gstrtpsession.c | 2 + gst/rtpmanager/gstrtpssrcdemux.c | 16 ++++++++ gst/rtpmanager/rtpsession.c | 5 +++ gst/rtpmanager/rtpsession.h | 1 - 8 files changed, 127 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 815f7c9f..2412bfdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2007-09-12 Wim Taymans + + * gst/rtpmanager/gstrtpbin.c: (create_session), (free_session), + (get_client), (free_client), (gst_rtp_bin_associate), + (free_stream), (gst_rtp_bin_class_init), (gst_rtp_bin_dispose), + (gst_rtp_bin_finalize): + * gst/rtpmanager/gstrtpjitterbuffer.c: + (gst_rtp_jitter_buffer_class_init), + (gst_rtp_jitter_buffer_finalize): + * gst/rtpmanager/gstrtpptdemux.c: (gst_rtp_pt_demux_release): + * gst/rtpmanager/gstrtpsession.c: (gst_rtp_session_finalize), + (gst_rtp_session_set_property), (gst_rtp_session_chain_recv_rtp), + (gst_rtp_session_chain_send_rtp): + * gst/rtpmanager/gstrtpssrcdemux.c: + (gst_rtp_ssrc_demux_class_init), (gst_rtp_ssrc_demux_dispose): + * gst/rtpmanager/rtpsession.c: (rtp_session_finalize): + * gst/rtpmanager/rtpsession.h: + Various leak fixes. + 2007-09-12 Wim Taymans * gst/rtpmanager/gstrtpbin.c: (calc_ntp_ns_base), diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index 7d5fb5d1..6f288bdc 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -245,6 +245,8 @@ static guint gst_rtp_bin_signals[LAST_SIGNAL] = { 0 }; static GstCaps *pt_map_requested (GstElement * element, guint pt, GstRtpBinSession * session); +static void free_stream (GstRtpBinStream * stream); + /* Manages the RTP stream for one SSRC. * * We pipe the stream (comming from the SSRC demuxer) into a jitterbuffer. @@ -462,6 +464,30 @@ no_demux: } } +static void +free_session (GstRtpBinSession * sess) +{ + GstRtpBin *bin; + + bin = sess->bin; + + gst_element_set_state (sess->session, GST_STATE_NULL); + gst_element_set_state (sess->demux, GST_STATE_NULL); + + gst_bin_remove (GST_BIN_CAST (bin), sess->session); + gst_bin_remove (GST_BIN_CAST (bin), sess->demux); + + g_slist_foreach (sess->streams, (GFunc) free_stream, NULL); + g_slist_free (sess->streams); + + g_mutex_free (sess->lock); + g_hash_table_destroy (sess->ptmap); + + bin->sessions = g_slist_remove (bin->sessions, sess); + + g_free (sess); +} + #if 0 static GstRtpBinStream * find_stream_by_ssrc (GstRtpBinSession * session, guint32 ssrc) @@ -565,8 +591,7 @@ gst_rtp_bin_clear_pt_map (GstRtpBin * bin) } static GstRtpBinClient * -gst_rtp_bin_get_client (GstRtpBin * bin, guint8 len, guint8 * data, - gboolean * created) +get_client (GstRtpBin * bin, guint8 len, guint8 * data, gboolean * created) { GstRtpBinClient *result = NULL; GSList *walk; @@ -598,6 +623,14 @@ gst_rtp_bin_get_client (GstRtpBin * bin, guint8 len, guint8 * data, return result; } +static void +free_client (GstRtpBinClient * client, GstRtpBin * bin) +{ + bin->clients = g_slist_remove (bin->clients, client); + g_free (client->cname); + g_free (client); +} + /* associate a stream to the given CNAME. This will make sure all streams for * that CNAME are synchronized together. */ static void @@ -609,7 +642,7 @@ gst_rtp_bin_associate (GstRtpBin * bin, GstRtpBinStream * stream, guint8 len, GSList *walk; /* first find or create the CNAME */ - client = gst_rtp_bin_get_client (bin, len, data, &created); + client = get_client (bin, len, data, &created); /* find stream in the client */ for (walk = client->streams; walk; walk = g_slist_next (walk)) { @@ -898,7 +931,28 @@ no_demux: } } +static void +free_stream (GstRtpBinStream * stream) +{ + GstRtpBinSession *session; + + session = stream->session; + + gst_element_set_state (stream->buffer, GST_STATE_NULL); + gst_element_set_state (stream->demux, GST_STATE_NULL); + + gst_bin_remove (GST_BIN_CAST (session->bin), stream->buffer); + gst_bin_remove (GST_BIN_CAST (session->bin), stream->demux); + + gst_object_unref (stream->sync_pad); + + session->streams = g_slist_remove (session->streams, stream); + + g_free (stream); +} + /* GObject vmethods */ +static void gst_rtp_bin_dispose (GObject * object); static void gst_rtp_bin_finalize (GObject * object); static void gst_rtp_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -951,6 +1005,7 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass) g_type_class_add_private (klass, sizeof (GstRtpBinPrivate)); + gobject_class->dispose = gst_rtp_bin_dispose; gobject_class->finalize = gst_rtp_bin_finalize; gobject_class->set_property = gst_rtp_bin_set_property; gobject_class->get_property = gst_rtp_bin_get_property; @@ -1086,6 +1141,21 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass) rtpbin->latency = DEFAULT_LATENCY_MS; } +static void +gst_rtp_bin_dispose (GObject * object) +{ + GstRtpBin *rtpbin; + + rtpbin = GST_RTP_BIN (object); + + g_slist_foreach (rtpbin->sessions, (GFunc) free_session, NULL); + g_slist_foreach (rtpbin->clients, (GFunc) free_client, NULL); + g_slist_free (rtpbin->sessions); + rtpbin->sessions = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + static void gst_rtp_bin_finalize (GObject * object) { @@ -1094,6 +1164,8 @@ gst_rtp_bin_finalize (GObject * object) rtpbin = GST_RTP_BIN (object); g_mutex_free (rtpbin->priv->bin_lock); + gst_object_unref (rtpbin->provided_clock); + g_slist_free (rtpbin->sessions); G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index 08a55f2b..497ce89d 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -208,7 +208,7 @@ static void gst_rtp_jitter_buffer_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtp_jitter_buffer_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_rtp_jitter_buffer_dispose (GObject * object); +static void gst_rtp_jitter_buffer_finalize (GObject * object); /* element overrides */ static GstStateChangeReturn gst_rtp_jitter_buffer_change_state (GstElement @@ -256,7 +256,7 @@ gst_rtp_jitter_buffer_class_init (GstRtpJitterBufferClass * klass) g_type_class_add_private (klass, sizeof (GstRtpJitterBufferPrivate)); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_dispose); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_finalize); gobject_class->set_property = gst_rtp_jitter_buffer_set_property; gobject_class->get_property = gst_rtp_jitter_buffer_get_property; @@ -370,17 +370,18 @@ gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer, } static void -gst_rtp_jitter_buffer_dispose (GObject * object) +gst_rtp_jitter_buffer_finalize (GObject * object) { GstRtpJitterBuffer *jitterbuffer; jitterbuffer = GST_RTP_JITTER_BUFFER (object); - if (jitterbuffer->priv->jbuf) { - g_object_unref (jitterbuffer->priv->jbuf); - jitterbuffer->priv->jbuf = NULL; - } - G_OBJECT_CLASS (parent_class)->dispose (object); + g_mutex_free (jitterbuffer->priv->jbuf_lock); + g_cond_free (jitterbuffer->priv->jbuf_cond); + + g_object_unref (jitterbuffer->priv->jbuf); + + G_OBJECT_CLASS (parent_class)->finalize (object); } static void diff --git a/gst/rtpmanager/gstrtpptdemux.c b/gst/rtpmanager/gstrtpptdemux.c index 6aa42701..b16426d1 100644 --- a/gst/rtpmanager/gstrtpptdemux.c +++ b/gst/rtpmanager/gstrtpptdemux.c @@ -415,6 +415,7 @@ gst_rtp_pt_demux_release (GstElement * element) if (ptdemux) { /* note: GstElement's dispose() will handle the pads */ + g_slist_foreach (ptdemux->srcpads, (GFunc) g_free, NULL); g_slist_free (ptdemux->srcpads); ptdemux->srcpads = NULL; } diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 70833655..44f6535a 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -515,6 +515,8 @@ gst_rtp_session_finalize (GObject * object) GstRtpSession *rtpsession; rtpsession = GST_RTP_SESSION (object); + + g_hash_table_destroy (rtpsession->priv->ptmap); g_mutex_free (rtpsession->priv->lock); g_object_unref (rtpsession->priv->session); diff --git a/gst/rtpmanager/gstrtpssrcdemux.c b/gst/rtpmanager/gstrtpssrcdemux.c index c728a6d5..2f1e9e67 100644 --- a/gst/rtpmanager/gstrtpssrcdemux.c +++ b/gst/rtpmanager/gstrtpssrcdemux.c @@ -108,6 +108,7 @@ GST_BOILERPLATE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GstElement, /* GObject vmethods */ +static void gst_rtp_ssrc_demux_dispose (GObject * object); static void gst_rtp_ssrc_demux_finalize (GObject * object); /* GstElement vmethods */ @@ -257,6 +258,7 @@ gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass) gobject_klass = (GObjectClass *) klass; gstelement_klass = (GstElementClass *) klass; + gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_dispose); gobject_klass->finalize = GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_finalize); /** @@ -305,6 +307,20 @@ gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux, gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED); } +static void +gst_rtp_ssrc_demux_dispose (GObject * object) +{ + GstRtpSsrcDemux *demux; + + demux = GST_RTP_SSRC_DEMUX (object); + + g_slist_foreach (demux->srcpads, (GFunc) g_free, NULL); + g_slist_free (demux->srcpads); + demux->srcpads = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + static void gst_rtp_ssrc_demux_finalize (GObject * object) { diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 724fa24a..fa9b84db 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -214,7 +214,12 @@ rtp_session_finalize (GObject * object) g_object_unref (sess->source); g_free (sess->cname); + g_free (sess->name); + g_free (sess->email); + g_free (sess->phone); + g_free (sess->location); g_free (sess->tool); + g_free (sess->note); g_free (sess->bye_reason); G_OBJECT_CLASS (rtp_session_parent_class)->finalize (object); diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h index d7dbb784..26c5924f 100644 --- a/gst/rtpmanager/rtpsession.h +++ b/gst/rtpmanager/rtpsession.h @@ -183,7 +183,6 @@ struct _RTPSession { GstClockTime last_rtcp_send_time; gboolean first_rtcp; - GstBuffer *bye_packet; gchar *bye_reason; gboolean sent_bye; -- cgit v1.2.1