rtpsession: Use iterate internal links instead of deprecated get internal links

This commit is contained in:
Sebastian Dröge 2009-08-19 16:57:05 +02:00
parent c8c02d2c7a
commit a1cddb3fd6

View file

@ -1236,29 +1236,87 @@ gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event)
} }
static GList * typedef struct
gst_rtp_session_internal_links (GstPad * pad) {
GstIterator parent;
GstRtpSession *rtpsession;
GstPad *pad;
gboolean start;
} GstRtpSessionIterator;
static void
_iterate_free (GstIterator * it)
{
GstRtpSessionIterator *sit = (GstRtpSessionIterator *) it;
g_object_unref (sit->rtpsession);
g_object_unref (sit->pad);
g_free (it);
}
static GstIteratorResult
_iterate_next (GstIterator * it, gpointer * result)
{
GstRtpSessionIterator *sit = (GstRtpSessionIterator *) it;
GstPad *res = NULL;
if (!sit->start) {
/* go out */
} else if (sit->pad == sit->rtpsession->recv_rtp_src) {
res = sit->rtpsession->recv_rtp_sink;
} else if (sit->pad == sit->rtpsession->recv_rtp_sink) {
res = sit->rtpsession->recv_rtp_src;
} else if (sit->pad == sit->rtpsession->send_rtp_src) {
res = sit->rtpsession->send_rtp_sink;
} else if (sit->pad == sit->rtpsession->send_rtp_sink) {
res = sit->rtpsession->send_rtp_src;
}
*result = res;
return res ? GST_ITERATOR_OK : GST_ITERATOR_DONE;
}
static GstIteratorItem
_iterate_item (GstIterator * it, gpointer item)
{
GstPad *pad = (GstPad *) item;
gst_object_ref (pad);
return GST_ITERATOR_ITEM_PASS;
}
static void
_iterate_resync (GstIterator * it)
{
GstRtpSessionIterator *sit = (GstRtpSessionIterator *) it;
sit->start = TRUE;
}
static GstIterator *
gst_rtp_session_iterate_internal_links (GstPad * pad)
{ {
GstRtpSession *rtpsession; GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv; GstRtpSessionIterator *it;
GList *res = NULL;
rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad)); rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
priv = rtpsession->priv;
if (pad == rtpsession->recv_rtp_src) { it = (GstRtpSessionIterator *)
res = g_list_prepend (res, rtpsession->recv_rtp_sink); gst_iterator_new (sizeof (GstRtpSessionIterator),
} else if (pad == rtpsession->recv_rtp_sink) { GST_TYPE_PAD,
res = g_list_prepend (res, rtpsession->recv_rtp_src); rtpsession->priv->lock,
} else if (pad == rtpsession->send_rtp_src) { &GST_ELEMENT_CAST (rtpsession)->pads_cookie,
res = g_list_prepend (res, rtpsession->send_rtp_sink); _iterate_next, _iterate_item, _iterate_resync, _iterate_free);
} else if (pad == rtpsession->send_rtp_sink) { it->start = TRUE;
res = g_list_prepend (res, rtpsession->send_rtp_src); it->rtpsession = gst_object_ref (rtpsession);
} it->pad = gst_object_ref (pad);
gst_object_unref (rtpsession); gst_object_unref (rtpsession);
return res; return (GstIterator *) it;
} }
static gboolean static gboolean
@ -1651,8 +1709,8 @@ create_recv_rtp_sink (GstRtpSession * rtpsession)
(GstPadEventFunction) gst_rtp_session_event_recv_rtp_sink); (GstPadEventFunction) gst_rtp_session_event_recv_rtp_sink);
gst_pad_set_setcaps_function (rtpsession->recv_rtp_sink, gst_pad_set_setcaps_function (rtpsession->recv_rtp_sink,
gst_rtp_session_sink_setcaps); gst_rtp_session_sink_setcaps);
gst_pad_set_internal_link_function (rtpsession->recv_rtp_sink, gst_pad_set_iterate_internal_links_function (rtpsession->recv_rtp_sink,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_set_active (rtpsession->recv_rtp_sink, TRUE); gst_pad_set_active (rtpsession->recv_rtp_sink, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), gst_element_add_pad (GST_ELEMENT_CAST (rtpsession),
rtpsession->recv_rtp_sink); rtpsession->recv_rtp_sink);
@ -1661,8 +1719,8 @@ create_recv_rtp_sink (GstRtpSession * rtpsession)
rtpsession->recv_rtp_src = rtpsession->recv_rtp_src =
gst_pad_new_from_static_template (&rtpsession_recv_rtp_src_template, gst_pad_new_from_static_template (&rtpsession_recv_rtp_src_template,
"recv_rtp_src"); "recv_rtp_src");
gst_pad_set_internal_link_function (rtpsession->recv_rtp_src, gst_pad_set_iterate_internal_links_function (rtpsession->recv_rtp_src,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_use_fixed_caps (rtpsession->recv_rtp_src); gst_pad_use_fixed_caps (rtpsession->recv_rtp_src);
gst_pad_set_active (rtpsession->recv_rtp_src, TRUE); gst_pad_set_active (rtpsession->recv_rtp_src, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->recv_rtp_src); gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->recv_rtp_src);
@ -1708,8 +1766,8 @@ create_recv_rtcp_sink (GstRtpSession * rtpsession)
gst_rtp_session_chain_recv_rtcp); gst_rtp_session_chain_recv_rtcp);
gst_pad_set_event_function (rtpsession->recv_rtcp_sink, gst_pad_set_event_function (rtpsession->recv_rtcp_sink,
(GstPadEventFunction) gst_rtp_session_event_recv_rtcp_sink); (GstPadEventFunction) gst_rtp_session_event_recv_rtcp_sink);
gst_pad_set_internal_link_function (rtpsession->recv_rtcp_sink, gst_pad_set_iterate_internal_links_function (rtpsession->recv_rtcp_sink,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_set_active (rtpsession->recv_rtcp_sink, TRUE); gst_pad_set_active (rtpsession->recv_rtcp_sink, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), gst_element_add_pad (GST_ELEMENT_CAST (rtpsession),
rtpsession->recv_rtcp_sink); rtpsession->recv_rtcp_sink);
@ -1718,8 +1776,8 @@ create_recv_rtcp_sink (GstRtpSession * rtpsession)
rtpsession->sync_src = rtpsession->sync_src =
gst_pad_new_from_static_template (&rtpsession_sync_src_template, gst_pad_new_from_static_template (&rtpsession_sync_src_template,
"sync_src"); "sync_src");
gst_pad_set_internal_link_function (rtpsession->sync_src, gst_pad_set_iterate_internal_links_function (rtpsession->sync_src,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_use_fixed_caps (rtpsession->sync_src); gst_pad_use_fixed_caps (rtpsession->sync_src);
gst_pad_set_active (rtpsession->sync_src, TRUE); gst_pad_set_active (rtpsession->sync_src, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->sync_src); gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->sync_src);
@ -1765,8 +1823,8 @@ create_send_rtp_sink (GstRtpSession * rtpsession)
gst_rtp_session_setcaps_send_rtp); gst_rtp_session_setcaps_send_rtp);
gst_pad_set_event_function (rtpsession->send_rtp_sink, gst_pad_set_event_function (rtpsession->send_rtp_sink,
(GstPadEventFunction) gst_rtp_session_event_send_rtp_sink); (GstPadEventFunction) gst_rtp_session_event_send_rtp_sink);
gst_pad_set_internal_link_function (rtpsession->send_rtp_sink, gst_pad_set_iterate_internal_links_function (rtpsession->send_rtp_sink,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_set_active (rtpsession->send_rtp_sink, TRUE); gst_pad_set_active (rtpsession->send_rtp_sink, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), gst_element_add_pad (GST_ELEMENT_CAST (rtpsession),
rtpsession->send_rtp_sink); rtpsession->send_rtp_sink);
@ -1774,8 +1832,8 @@ create_send_rtp_sink (GstRtpSession * rtpsession)
rtpsession->send_rtp_src = rtpsession->send_rtp_src =
gst_pad_new_from_static_template (&rtpsession_send_rtp_src_template, gst_pad_new_from_static_template (&rtpsession_send_rtp_src_template,
"send_rtp_src"); "send_rtp_src");
gst_pad_set_internal_link_function (rtpsession->send_rtp_src, gst_pad_set_iterate_internal_links_function (rtpsession->send_rtp_src,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_set_active (rtpsession->send_rtp_src, TRUE); gst_pad_set_active (rtpsession->send_rtp_src, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->send_rtp_src); gst_element_add_pad (GST_ELEMENT_CAST (rtpsession), rtpsession->send_rtp_src);
@ -1813,8 +1871,8 @@ create_send_rtcp_src (GstRtpSession * rtpsession)
"send_rtcp_src"); "send_rtcp_src");
gst_pad_use_fixed_caps (rtpsession->send_rtcp_src); gst_pad_use_fixed_caps (rtpsession->send_rtcp_src);
gst_pad_set_active (rtpsession->send_rtcp_src, TRUE); gst_pad_set_active (rtpsession->send_rtcp_src, TRUE);
gst_pad_set_internal_link_function (rtpsession->send_rtcp_src, gst_pad_set_iterate_internal_links_function (rtpsession->send_rtcp_src,
gst_rtp_session_internal_links); gst_rtp_session_iterate_internal_links);
gst_pad_set_query_function (rtpsession->send_rtcp_src, gst_pad_set_query_function (rtpsession->send_rtcp_src,
gst_rtp_session_query_send_rtcp_src); gst_rtp_session_query_send_rtcp_src);
gst_pad_set_event_function (rtpsession->send_rtcp_src, gst_pad_set_event_function (rtpsession->send_rtcp_src,