From c06482a2cb1f0c6f3e33f38ff3991326554df728 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 26 Jul 2013 01:14:04 +0200 Subject: [PATCH] session: make method to suggest available SSRC Make a method to suggest the best available SSRC. This is the SSRC of the last created internal source and is used to instruct upstream to produce this SSRC. --- gst/rtpmanager/gstrtpsession.c | 3 ++- gst/rtpmanager/rtpsession.c | 27 ++++++++++++++++++++++++++- gst/rtpmanager/rtpsession.h | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 98912fb560..b971fd3e3c 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -1762,6 +1762,7 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstObject * parent, * because we stop sending. */ ret = gst_pad_push_event (rtpsession->send_rtp_src, event); current_time = gst_clock_get_time (rtpsession->priv->sysclock); + GST_DEBUG_OBJECT (rtpsession, "scheduling BYE message"); rtp_session_mark_all_bye (rtpsession->priv->session, "End Of Stream"); rtp_session_schedule_bye (rtpsession->priv->session, current_time); @@ -1826,7 +1827,7 @@ gst_rtp_session_getcaps_send_rtp (GstPad * pad, GstRtpSession * rtpsession, priv = rtpsession->priv; - ssrc = rtp_session_get_internal_ssrc (priv->session); + ssrc = rtp_session_suggest_ssrc (priv->session); /* we can basically accept anything but we prefer to receive packets with our * internal SSRC so that we don't have to patch it. Create a structure with diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index fffec31c58..29bf7b6ea2 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -1297,8 +1297,11 @@ add_source (RTPSession * sess, RTPSource * src) sess->total_sources++; if (RTP_SOURCE_IS_ACTIVE (src)) sess->stats.active_sources++; - if (src->internal) + if (src->internal) { sess->stats.internal_sources++; + if (sess->suggested_ssrc != src->ssrc) + sess->suggested_ssrc = src->ssrc; + } } /* must be called with the session lock, the returned source needs to be @@ -1457,6 +1460,28 @@ rtp_session_get_internal_ssrc (RTPSession * sess) return ssrc; } +/** + * rtp_session_suggest_ssrc: + * @sess: a #RTPSession + * + * Suggest an unused SSRC in @sess. + * + * Returns: a free unused SSRC + */ +guint32 +rtp_session_suggest_ssrc (RTPSession * sess) +{ + guint32 result; + + g_return_val_if_fail (RTP_IS_SESSION (sess), 0); + + RTP_SESSION_LOCK (sess); + result = sess->suggested_ssrc; + RTP_SESSION_UNLOCK (sess); + + return result; +} + /** * rtp_session_add_source: * @sess: a #RTPSession diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h index a9d8b6525e..301b92e2c3 100644 --- a/gst/rtpmanager/rtpsession.h +++ b/gst/rtpmanager/rtpsession.h @@ -199,6 +199,7 @@ struct _RTPSession { guint rtcp_rs_bandwidth; RTPSource *source; + guint32 suggested_ssrc; /* for sender/receiver counting */ guint32 key; @@ -310,6 +311,7 @@ RTPSource* rtp_session_get_internal_source (RTPSession *sess); void rtp_session_set_internal_ssrc (RTPSession *sess, guint32 ssrc); guint32 rtp_session_get_internal_ssrc (RTPSession *sess); +guint32 rtp_session_suggest_ssrc (RTPSession *sess); gboolean rtp_session_add_source (RTPSession *sess, RTPSource *src); guint rtp_session_get_num_sources (RTPSession *sess);