rtp: Use new gst_iterator_new_single() for the internal linked pads iteration

This commit is contained in:
Sebastian Dröge 2009-08-26 17:02:45 +02:00
parent a1cddb3fd6
commit 000a483d31
5 changed files with 53 additions and 224 deletions

View file

@ -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 ****

View file

@ -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 *

View file

@ -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

View file

@ -619,95 +619,39 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
return res;
}
typedef struct
{
GstIterator parent;
GstRtpSsrcDemux *demux;
GstPad *pad;
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;
for (current = dit->current; current; current = g_slist_next (current)) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) current->data;
if (dit->pad == dit->demux->rtp_sink) {
res = 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;
break;
} else if (dit->pad == dpad->rtcp_pad) {
res = dit->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;
GstPad *otherpad = NULL;
GstIterator *it;
GSList *current;
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);
GST_PAD_LOCK (demux);
for (current = demux->srcpads; current; current = g_slist_next (current)) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) current->data;
it->demux = gst_object_ref (demux);
it->pad = gst_object_ref (pad);
it->current = demux->srcpads;
if (pad == demux->rtp_sink) {
otherpad = dpad->rtp_pad;
break;
} else if (pad == demux->rtcp_sink) {
otherpad = dpad->rtcp_pad;
} else if (pad == dpad->rtp_pad) {
otherpad = demux->rtp_sink;
break;
} else if (pad == dpad->rtcp_pad) {
otherpad = demux->rtcp_sink;
break;
}
}
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

View file

@ -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