From 5ddf6a5e3274d433409f4cbd7d4c6a942df1376e Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 26 Dec 2013 12:05:19 +0200 Subject: [PATCH] gstrtpsession: suggest upstream to use the new "internal-ssrc" after a collision When a collision is found on the internal ssrc, we have to change it. Ideally, we want also the payloader upstream to follow this change and use the new internal ssrc. Ideally we want this condition to be always met: if there is one payloader sending on this session, its ssrc should match the internal ssrc. --- gst/rtpmanager/gstrtpsession.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index f51b61353e..80ac1c1677 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -333,9 +333,25 @@ on_ssrc_collision (RTPSession * session, RTPSource * src, GstRtpSession * sess) GST_RTP_SESSION_UNLOCK (sess); if (send_rtp_sink) { - GstEvent *event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, - gst_structure_new ("GstRTPCollision", "ssrc", G_TYPE_UINT, - (guint) src->ssrc, NULL)); + GstStructure *structure; + GstEvent *event; + RTPSource *internal_src; + guint32 suggested_ssrc; + + structure = gst_structure_new ("GstRTPCollision", "ssrc", G_TYPE_UINT, + (guint) src->ssrc, NULL); + + /* if there is no source using the suggested ssrc, most probably because + * this ssrc has just collided, suggest upstream to use it */ + suggested_ssrc = rtp_session_suggest_ssrc (session); + internal_src = rtp_session_get_source_by_ssrc (session, suggested_ssrc); + if (!internal_src) + gst_structure_set (structure, "suggested-ssrc", G_TYPE_UINT, + (guint) suggested_ssrc, NULL); + else + g_object_unref (internal_src); + + event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure); gst_pad_push_event (send_rtp_sink, event); gst_object_unref (send_rtp_sink); }