diff options
author | Olivier Crete <tester@tester.ca> | 2008-04-21 08:26:37 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2008-04-21 08:26:37 +0000 |
commit | 4be1b4a30a383231448c727c6413495cfdbcb5b6 (patch) | |
tree | 6cc81f8bae5e41dc09008c05a6955b98dd5403da | |
parent | a6a13dff0fdb282fa445f88654f20f0c5e9305f6 (diff) | |
download | gst-plugins-bad-4be1b4a30a383231448c727c6413495cfdbcb5b6.tar.gz gst-plugins-bad-4be1b4a30a383231448c727c6413495cfdbcb5b6.tar.bz2 gst-plugins-bad-4be1b4a30a383231448c727c6413495cfdbcb5b6.zip |
gst/rtpmanager/gstrtpbin.c: Ref caps when inserting into the cache.
Original commit message from CVS:
Patch by: Olivier Crete <tester at tester dot ca>
* gst/rtpmanager/gstrtpbin.c: (create_session), (get_pt_map),
(new_ssrc_pad_found):
Ref caps when inserting into the cache.
Don't leak pads.
* gst/rtpmanager/gstrtpjitterbuffer.c:
(gst_rtp_jitter_buffer_get_clock_rate),
(gst_rtp_jitter_buffer_query):
Avoid a caps leak.
Don't leak refcount in query.
* gst/rtpmanager/gstrtpptdemux.c: (gst_rtp_pt_demux_get_caps),
(gst_rtp_pt_demux_chain):
Avoid caps leaks.
* gst/rtpmanager/gstrtpsession.c: (source_get_sdes_structure),
(gst_rtp_session_init), (return_true),
(gst_rtp_session_clear_pt_map), (gst_rtp_session_cache_caps),
(gst_rtp_session_clock_rate):
Ref caps when inserting into the cache.
Fix some more caps leaks. Fixes #528245.
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | gst/rtpmanager/gstrtpbin.c | 18 | ||||
-rw-r--r-- | gst/rtpmanager/gstrtpjitterbuffer.c | 5 | ||||
-rw-r--r-- | gst/rtpmanager/gstrtpptdemux.c | 7 | ||||
-rw-r--r-- | gst/rtpmanager/gstrtpsession.c | 25 |
5 files changed, 67 insertions, 14 deletions
@@ -1,3 +1,29 @@ +2008-04-21 Wim Taymans <wim.taymans@collabora.co.uk> + + Patch by: Olivier Crete <tester at tester dot ca> + + * gst/rtpmanager/gstrtpbin.c: (create_session), (get_pt_map), + (new_ssrc_pad_found): + Ref caps when inserting into the cache. + Don't leak pads. + + * gst/rtpmanager/gstrtpjitterbuffer.c: + (gst_rtp_jitter_buffer_get_clock_rate), + (gst_rtp_jitter_buffer_query): + Avoid a caps leak. + Don't leak refcount in query. + + * gst/rtpmanager/gstrtpptdemux.c: (gst_rtp_pt_demux_get_caps), + (gst_rtp_pt_demux_chain): + Avoid caps leaks. + + * gst/rtpmanager/gstrtpsession.c: (source_get_sdes_structure), + (gst_rtp_session_init), (return_true), + (gst_rtp_session_clear_pt_map), (gst_rtp_session_cache_caps), + (gst_rtp_session_clock_rate): + Ref caps when inserting into the cache. + Fix some more caps leaks. Fixes #528245. + 2008-04-18 Tim-Philipp Müller <tim at centricular dot net> * tests/icles/metadata_editor.c: diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index cf1983d7..76b806bc 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -460,7 +460,8 @@ create_session (GstRtpBin * rtpbin, gint id) sess->bin = rtpbin; sess->session = session; sess->demux = demux; - sess->ptmap = g_hash_table_new (NULL, NULL); + sess->ptmap = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) gst_caps_unref); rtpbin->sessions = g_slist_prepend (rtpbin->sessions, sess); /* set NTP base or new session */ @@ -584,8 +585,10 @@ get_pt_map (GstRtpBinSession * session, guint pt) /* first look in the cache */ caps = g_hash_table_lookup (session->ptmap, GINT_TO_POINTER (pt)); - if (caps) + if (caps) { + gst_caps_ref (caps); goto done; + } bin = session->bin; @@ -614,11 +617,11 @@ get_pt_map (GstRtpBinSession * session, guint pt) GST_DEBUG ("caching pt %d as %" GST_PTR_FORMAT, pt, caps); - /* store in cache */ - g_hash_table_insert (session->ptmap, GINT_TO_POINTER (pt), caps); + /* store in cache, take additional ref */ + g_hash_table_insert (session->ptmap, GINT_TO_POINTER (pt), + gst_caps_ref (caps)); done: - gst_caps_ref (caps); GST_RTP_SESSION_UNLOCK (session); return caps; @@ -1780,16 +1783,17 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad, /* get pad and link */ GST_DEBUG_OBJECT (session->bin, "linking jitterbuffer"); padname = g_strdup_printf ("src_%d", ssrc); - srcpad = gst_element_get_pad (element, padname); + srcpad = gst_element_get_static_pad (element, padname); g_free (padname); sinkpad = gst_element_get_static_pad (stream->buffer, "sink"); gst_pad_link (srcpad, sinkpad); gst_object_unref (sinkpad); + gst_object_unref (srcpad); /* get the RTCP sync pad */ GST_DEBUG_OBJECT (session->bin, "linking sync pad"); padname = g_strdup_printf ("rtcp_src_%d", ssrc); - srcpad = gst_element_get_pad (element, padname); + srcpad = gst_element_get_static_pad (element, padname); g_free (padname); gst_pad_link (srcpad, stream->sync_pad); gst_object_unref (srcpad); diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index 3e5cb3b3..9bea78f2 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -780,6 +780,8 @@ gst_rtp_jitter_buffer_get_clock_rate (GstRtpJitterBuffer * jitterbuffer, res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps); + gst_caps_unref (caps); + return res; /* ERRORS */ @@ -1233,6 +1235,9 @@ gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query) res = gst_pad_query_default (pad, query); break; } + + gst_object_unref (jitterbuffer); + return res; } diff --git a/gst/rtpmanager/gstrtpptdemux.c b/gst/rtpmanager/gstrtpptdemux.c index f3121cb4..b6df8526 100644 --- a/gst/rtpmanager/gstrtpptdemux.c +++ b/gst/rtpmanager/gstrtpptdemux.c @@ -277,8 +277,11 @@ gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt) g_value_unset (&args[1]); caps = g_value_dup_boxed (&ret); g_value_unset (&ret); - if (caps == NULL) + if (caps == NULL) { caps = GST_PAD_CAPS (rtpdemux->sink); + if (caps) + gst_caps_ref (caps); + } GST_DEBUG ("pt %d, got caps %" GST_PTR_FORMAT, pt, caps); @@ -341,6 +344,7 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf) caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL); gst_pad_set_caps (srcpad, caps); + gst_caps_unref (caps); GST_DEBUG ("Adding pt=%d to the list.", pt); rtpdemuxpad = g_new0 (GstRtpPtDemuxPad, 1); @@ -380,6 +384,7 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf) caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL); gst_pad_set_caps (srcpad, caps); + gst_caps_unref (caps); rtpdemuxpad->newcaps = FALSE; } diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index a73de15b..c27291ff 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -391,6 +391,7 @@ source_get_sdes_structure (RTPSource * src) g_value_take_string (&val, str); gst_structure_set_value (result, "priv", &val); } + g_value_unset (&val); return result; } @@ -690,7 +691,8 @@ gst_rtp_session_init (GstRtpSession * rtpsession, GstRtpSessionClass * klass) (GCallback) on_bye_timeout, rtpsession); g_signal_connect (rtpsession->priv->session, "on-timeout", (GCallback) on_timeout, rtpsession); - rtpsession->priv->ptmap = g_hash_table_new (NULL, NULL); + rtpsession->priv->ptmap = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) gst_caps_unref); gst_segment_init (&rtpsession->recv_rtp_seg, GST_FORMAT_UNDEFINED); gst_segment_init (&rtpsession->send_rtp_seg, GST_FORMAT_UNDEFINED); @@ -1068,10 +1070,16 @@ failed_thread: } } +static gboolean +return_true (gpointer key, gpointer value, gpointer user_data) +{ + return TRUE; +} + static void gst_rtp_session_clear_pt_map (GstRtpSession * rtpsession) { - /* FIXME, do something */ + g_hash_table_foreach_remove (rtpsession->priv->ptmap, return_true, NULL); } /* called when the session manager has an RTP packet ready for further @@ -1203,11 +1211,11 @@ gst_rtp_session_cache_caps (GstRtpSession * rtpsession, GstCaps * caps) if (!gst_structure_get_int (s, "payload", &payload)) return; - caps = g_hash_table_lookup (priv->ptmap, GINT_TO_POINTER (payload)); - if (caps) + if (g_hash_table_lookup (priv->ptmap, GINT_TO_POINTER (payload))) return; - g_hash_table_insert (priv->ptmap, GINT_TO_POINTER (payload), caps); + g_hash_table_insert (priv->ptmap, GINT_TO_POINTER (payload), + gst_caps_ref (caps)); } /* called when the session manager needs the clock rate */ @@ -1229,8 +1237,10 @@ gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload, GST_RTP_SESSION_LOCK (rtpsession); ipayload = payload; /* make compiler happy */ caps = g_hash_table_lookup (priv->ptmap, GINT_TO_POINTER (ipayload)); - if (caps) + if (caps) { + gst_caps_ref (caps); goto found; + } /* not found in the cache, try to get it with a signal */ g_value_init (&args[0], GST_TYPE_ELEMENT); @@ -1258,6 +1268,8 @@ found: if (!gst_structure_get_int (s, "clock-rate", &result)) goto no_clock_rate; + gst_caps_unref (caps); + GST_DEBUG_OBJECT (rtpsession, "parsed clock-rate %d", result); done: @@ -1273,6 +1285,7 @@ no_caps: } no_clock_rate: { + gst_caps_unref (caps); GST_DEBUG_OBJECT (rtpsession, "No clock-rate in caps!"); goto done; } |