From 000a483d31bf307370ef3dd990c991ed34dd0ef9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 26 Aug 2009 17:02:45 +0200 Subject: [PATCH] rtp: Use new gst_iterator_new_single() for the internal linked pads iteration --- configure.ac | 2 +- gst/rtpmanager/gstrtpjitterbuffer.c | 85 ++++---------------------- gst/rtpmanager/gstrtpsession.c | 86 +++++--------------------- gst/rtpmanager/gstrtpssrcdemux.c | 94 ++++++----------------------- gst/rtpmanager/rtpstats.c | 2 +- 5 files changed, 49 insertions(+), 220 deletions(-) diff --git a/configure.ac b/configure.ac index 8f42827581..080eae38d7 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,7 @@ AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL dnl *** required versions of GStreamer stuff *** -GST_REQ=0.10.24 +GST_REQ=0.10.24.1 GSTPB_REQ=0.10.24 dnl *** autotools stuff **** diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index c0ee8464c7..e3d6ed090e 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -466,88 +466,29 @@ gst_rtp_jitter_buffer_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } -typedef struct -{ - GstIterator parent; - - GstRtpJitterBuffer *jitterbuffer; - GstPad *pad; - gboolean start; -} GstRtpJitterBufferIterator; - -static void -_iterate_free (GstIterator * it) -{ - GstRtpJitterBufferIterator *jit = (GstRtpJitterBufferIterator *) it; - - g_object_unref (jit->jitterbuffer); - g_object_unref (jit->pad); - - g_free (it); -} - -static GstIteratorResult -_iterate_next (GstIterator * it, gpointer * result) -{ - GstRtpJitterBufferIterator *jit = (GstRtpJitterBufferIterator *) it; - GstPad *res = NULL; - GstRtpJitterBufferPrivate *priv; - - priv = jit->jitterbuffer->priv; - - if (!jit->start) { - /* go out */ - } else if (jit->pad == priv->sinkpad) { - res = priv->srcpad; - } else if (jit->pad == priv->srcpad) { - res = priv->sinkpad; - } else if (jit->pad == priv->rtcpsinkpad) { - res = NULL; - } - - *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) -{ - GstRtpJitterBufferIterator *jit = (GstRtpJitterBufferIterator *) it; - - jit->start = TRUE; -} - static GstIterator * gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad) { GstRtpJitterBuffer *jitterbuffer; - GstRtpJitterBufferIterator *it; + GstPad *otherpad = NULL; + GstIterator *it; jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad)); - it = (GstRtpJitterBufferIterator *) - gst_iterator_new (sizeof (GstRtpJitterBufferIterator), - GST_TYPE_PAD, - GST_OBJECT_CAST (jitterbuffer)->lock, - &GST_ELEMENT_CAST (jitterbuffer)->pads_cookie, - _iterate_next, _iterate_item, _iterate_resync, _iterate_free); - it->start = TRUE; - it->jitterbuffer = gst_object_ref (jitterbuffer); - it->pad = gst_object_ref (pad); + if (pad == jitterbuffer->priv->sinkpad) { + otherpad = jitterbuffer->priv->srcpad; + } else if (pad == jitterbuffer->priv->srcpad) { + otherpad = jitterbuffer->priv->sinkpad; + } else if (pad == jitterbuffer->priv->rtcpsinkpad) { + otherpad = NULL; + } + + it = gst_iterator_new_single (GST_TYPE_PAD, otherpad, + (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); gst_object_unref (jitterbuffer); - return (GstIterator *) it; + return it; } static GstPad * diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 3809abc094..55903da1d8 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -1236,87 +1236,31 @@ gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event) } -typedef struct -{ - 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; - GstRtpSessionIterator *it; + GstPad *otherpad = NULL; + GstIterator *it; rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad)); - it = (GstRtpSessionIterator *) - gst_iterator_new (sizeof (GstRtpSessionIterator), - GST_TYPE_PAD, - rtpsession->priv->lock, - &GST_ELEMENT_CAST (rtpsession)->pads_cookie, - _iterate_next, _iterate_item, _iterate_resync, _iterate_free); - it->start = TRUE; - it->rtpsession = gst_object_ref (rtpsession); - it->pad = gst_object_ref (pad); + if (pad == rtpsession->recv_rtp_src) { + otherpad = rtpsession->recv_rtp_sink; + } else if (pad == rtpsession->recv_rtp_sink) { + otherpad = rtpsession->recv_rtp_src; + } else if (pad == rtpsession->send_rtp_src) { + otherpad = rtpsession->send_rtp_sink; + } else if (pad == rtpsession->send_rtp_sink) { + otherpad = rtpsession->send_rtp_src; + } + + it = gst_iterator_new_single (GST_TYPE_PAD, otherpad, + (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); gst_object_unref (rtpsession); - return (GstIterator *) it; + return it; } static gboolean diff --git a/gst/rtpmanager/gstrtpssrcdemux.c b/gst/rtpmanager/gstrtpssrcdemux.c index cbf56193d9..6c5b045088 100644 --- a/gst/rtpmanager/gstrtpssrcdemux.c +++ b/gst/rtpmanager/gstrtpssrcdemux.c @@ -619,95 +619,39 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event) return res; } -typedef struct +static GstIterator * +gst_rtp_ssrc_demux_iterate_internal_links (GstPad * pad) { - GstIterator parent; - GstRtpSsrcDemux *demux; - GstPad *pad; + GstPad *otherpad = NULL; + GstIterator *it; GSList *current; -} GstRtpSsrcDemuxIterator; - -static void -_iterate_free (GstIterator * it) -{ - GstRtpSsrcDemuxIterator *dit = (GstRtpSsrcDemuxIterator *) it; - - g_object_unref (dit->demux); - g_object_unref (dit->pad); - - g_free (it); -} -static GstIteratorResult -_iterate_next (GstIterator * it, gpointer * result) -{ - GstRtpSsrcDemuxIterator *dit = (GstRtpSsrcDemuxIterator *) it; - GSList *current; - GstPad *res = NULL; + demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad)); - for (current = dit->current; current; current = g_slist_next (current)) { + GST_PAD_LOCK (demux); + for (current = demux->srcpads; current; current = g_slist_next (current)) { GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) current->data; - if (dit->pad == dit->demux->rtp_sink) { - res = dpad->rtp_pad; + if (pad == demux->rtp_sink) { + otherpad = dpad->rtp_pad; break; - } else if (dit->pad == dit->demux->rtcp_sink) { - res = dpad->rtcp_pad; - } else if (dit->pad == dpad->rtp_pad) { - res = dit->demux->rtp_sink; + } else if (pad == demux->rtcp_sink) { + otherpad = dpad->rtcp_pad; + } else if (pad == dpad->rtp_pad) { + otherpad = demux->rtp_sink; break; - } else if (dit->pad == dpad->rtcp_pad) { - res = dit->demux->rtcp_sink; + } else if (pad == dpad->rtcp_pad) { + otherpad = demux->rtcp_sink; break; } } - - *result = res; - - dit->current = current; - - 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) -{ - GstRtpSsrcDemuxIterator *dit = (GstRtpSsrcDemuxIterator *) it; - - dit->current = dit->demux->srcpads; -} - -static GstIterator * -gst_rtp_ssrc_demux_iterate_internal_links (GstPad * pad) -{ - GstRtpSsrcDemux *demux; - GstRtpSsrcDemuxIterator *it; - - demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad)); - - it = (GstRtpSsrcDemuxIterator *) - gst_iterator_new (sizeof (GstRtpSsrcDemuxIterator), - GST_TYPE_PAD, - demux->padlock, - &GST_ELEMENT_CAST (demux)->pads_cookie, - _iterate_next, _iterate_item, _iterate_resync, _iterate_free); - - it->demux = gst_object_ref (demux); - it->pad = gst_object_ref (pad); - it->current = demux->srcpads; + it = gst_iterator_new_single (GST_TYPE_PAD, otherpad, + (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); + GST_PAD_UNLOCK (demux); gst_object_unref (demux); - return (GstIterator *) it; + return it; } static gboolean diff --git a/gst/rtpmanager/rtpstats.c b/gst/rtpmanager/rtpstats.c index 640c319420..04849ff0cc 100644 --- a/gst/rtpmanager/rtpstats.c +++ b/gst/rtpmanager/rtpstats.c @@ -148,7 +148,7 @@ rtp_stats_calculate_bye_interval (RTPSessionStats * stats) /* no interval when we have less than 50 members */ if (stats->active_sources < 50) return 0; - + rtcp_min_time = (stats->min_interval) / 2.0; /* Dedicate a fraction of the RTCP bandwidth to senders unless -- 2.34.1