summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-09-12 21:23:47 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-08-11 02:30:30 +0100
commita93348cc6da0eff1a30fd08b2ec17962079a38a6 (patch)
tree6f61f0fdad755ee04c07f52d65729a965a263940
parent919deb449063c2b26485b7c07b829e081b7c7fae (diff)
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.
-rw-r--r--gst/rtpmanager/gstrtpbin.c78
-rw-r--r--gst/rtpmanager/gstrtpjitterbuffer.c17
-rw-r--r--gst/rtpmanager/gstrtpptdemux.c1
-rw-r--r--gst/rtpmanager/gstrtpsession.c2
-rw-r--r--gst/rtpmanager/gstrtpssrcdemux.c16
-rw-r--r--gst/rtpmanager/rtpsession.c5
-rw-r--r--gst/rtpmanager/rtpsession.h1
7 files changed, 108 insertions, 12 deletions
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index 7d5fb5d13..6f288bdcc 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;
@@ -1087,6 +1142,21 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
}
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)
{
GstRtpBin *rtpbin;
@@ -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 08a55f2bc..497ce89df 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 6aa427017..b16426d19 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 70833655b..44f6535a0 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 c728a6d58..2f1e9e67a 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);
/**
@@ -306,6 +308,20 @@ gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux,
}
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)
{
GstRtpSsrcDemux *demux;
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 724fa24a0..fa9b84db8 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 d7dbb784f..26c5924f0 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;