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 */
/* 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;
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;
/* 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);
res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps);
+ gst_caps_unref (caps);
+
return res;
/* ERRORS */
res = gst_pad_query_default (pad, query);
break;
}
+
+ gst_object_unref (jitterbuffer);
+
return res;
}
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);
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);
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;
}
g_value_take_string (&val, str);
gst_structure_set_value (result, "priv", &val);
}
+ g_value_unset (&val);
return result;
}
(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);
}
}
+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
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 */
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);
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:
}
no_clock_rate:
{
+ gst_caps_unref (caps);
GST_DEBUG_OBJECT (rtpsession, "No clock-rate in caps!");
goto done;
}