? collision-loop-detection-2.diff
? collision-loop-detection.diff
? jb-ref-leak.diff
? rtpmanager-leaks.patch
? rtpmanager-unsigned-ssrc-pt-printf.patch
? rtpsession.c.extrnal-compare
? use-extrnal-compare.diff
Index: gstrtpbin.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpbin.c,v
retrieving revision 1.43
diff -u -p -r1.43 gstrtpbin.c
--- gstrtpbin.c	17 Apr 2008 07:31:43 -0000	1.43
+++ gstrtpbin.c	18 Apr 2008 19:28:07 -0000
@@ -460,7 +460,8 @@ create_session (GstRtpBin * rtpbin, gint
   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, 
 
   /* 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;
 
@@ -615,10 +618,10 @@ get_pt_map (GstRtpBinSession * session, 
   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);
+  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
   /* 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);
Index: gstrtpjitterbuffer.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpjitterbuffer.c,v
retrieving revision 1.35
diff -u -p -r1.35 gstrtpjitterbuffer.c
--- gstrtpjitterbuffer.c	17 Apr 2008 07:31:44 -0000	1.35
+++ gstrtpjitterbuffer.c	18 Apr 2008 19:28:08 -0000
@@ -780,6 +780,8 @@ gst_rtp_jitter_buffer_get_clock_rate (Gs
 
   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 * pa
       res = gst_pad_query_default (pad, query);
       break;
   }
+
+  gst_object_unref (jitterbuffer);
+
   return res;
 }
 
Index: gstrtpptdemux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpptdemux.c,v
retrieving revision 1.15
diff -u -p -r1.15 gstrtpptdemux.c
--- gstrtpptdemux.c	17 Apr 2008 07:31:44 -0000	1.15
+++ gstrtpptdemux.c	18 Apr 2008 19:28:08 -0000
@@ -341,6 +341,7 @@ gst_rtp_pt_demux_chain (GstPad * pad, Gs
     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 +381,7 @@ gst_rtp_pt_demux_chain (GstPad * pad, Gs
     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;
   }
 
Index: gstrtpsession.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/rtpmanager/gstrtpsession.c,v
retrieving revision 1.38
diff -u -p -r1.38 gstrtpsession.c
--- gstrtpsession.c	17 Apr 2008 07:31:44 -0000	1.38
+++ gstrtpsession.c	18 Apr 2008 19:28:08 -0000
@@ -391,6 +391,7 @@ source_get_sdes_structure (RTPSource * s
     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 * rt
       (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);
@@ -1071,7 +1073,7 @@ failed_thread:
 static void
 gst_rtp_session_clear_pt_map (GstRtpSession * rtpsession)
 {
-  /* FIXME, do something */
+  g_hash_table_remove_all (rtpsession->priv->ptmap);
 }
 
 /* called when the session manager has an RTP packet ready for further
@@ -1203,11 +1205,11 @@ gst_rtp_session_cache_caps (GstRtpSessio
   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 +1231,10 @@ gst_rtp_session_clock_rate (RTPSession *
   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 +1262,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 +1279,7 @@ no_caps:
   }
 no_clock_rate:
   {
+    gst_caps_unref (caps);
     GST_DEBUG_OBJECT (rtpsession, "No clock-rate in caps!");
     goto done;
   }
