session: generate reconfigure on collision

When we detect a collision, change the SSRC that we suggest upstream
and trigger RECONFIGURE. This should make upstream select a new SSRC.
This commit is contained in:
Wim Taymans 2013-07-26 10:00:58 +02:00
parent 495d43c089
commit e0a1ce1291
2 changed files with 27 additions and 12 deletions

View file

@ -313,8 +313,20 @@ on_new_ssrc (RTPSession * session, RTPSource * src, GstRtpSession * sess)
static void static void
on_ssrc_collision (RTPSession * session, RTPSource * src, GstRtpSession * sess) on_ssrc_collision (RTPSession * session, RTPSource * src, GstRtpSession * sess)
{ {
GstPad *recv_rtp_sink;
g_signal_emit (sess, gst_rtp_session_signals[SIGNAL_ON_SSRC_COLLISION], 0, g_signal_emit (sess, gst_rtp_session_signals[SIGNAL_ON_SSRC_COLLISION], 0,
src->ssrc); src->ssrc);
GST_RTP_SESSION_LOCK (sess);
if ((recv_rtp_sink = sess->recv_rtp_sink))
gst_object_ref (recv_rtp_sink);
GST_RTP_SESSION_UNLOCK (sess);
if (recv_rtp_sink) {
gst_pad_push_event (recv_rtp_sink, gst_event_new_reconfigure ());
gst_object_unref (recv_rtp_sink);
}
} }
static void static void

View file

@ -1173,10 +1173,14 @@ static gboolean
check_collision (RTPSession * sess, RTPSource * source, check_collision (RTPSession * sess, RTPSource * source,
RTPArrivalStats * arrival, gboolean rtp) RTPArrivalStats * arrival, gboolean rtp)
{ {
guint32 ssrc;
/* If we have no arrival address, we can't do collision checking */ /* If we have no arrival address, we can't do collision checking */
if (!arrival->address) if (!arrival->address)
return FALSE; return FALSE;
ssrc = rtp_source_get_ssrc (source);
if (!source->internal) { if (!source->internal) {
GSocketAddress *from; GSocketAddress *from;
@ -1193,16 +1197,15 @@ check_collision (RTPSession * sess, RTPSource * source,
/* Address is the same */ /* Address is the same */
return FALSE; return FALSE;
} else { } else {
GST_LOG ("we have a third-party collision or loop ssrc:%x", GST_LOG ("we have a third-party collision or loop ssrc:%x", ssrc);
rtp_source_get_ssrc (source));
if (sess->favor_new) { if (sess->favor_new) {
if (rtp_source_find_conflicting_address (source, if (rtp_source_find_conflicting_address (source,
arrival->address, arrival->current_time)) { arrival->address, arrival->current_time)) {
gchar *buf1; gchar *buf1;
buf1 = __g_socket_address_to_string (arrival->address); buf1 = __g_socket_address_to_string (arrival->address);
GST_LOG ("Known conflict on %x for %s, dropping packet", GST_LOG ("Known conflict on %x for %s, dropping packet", ssrc,
rtp_source_get_ssrc (source), buf1); buf1);
g_free (buf1); g_free (buf1);
return TRUE; return TRUE;
@ -1219,8 +1222,7 @@ check_collision (RTPSession * sess, RTPSource * source,
buf2 = __g_socket_address_to_string (arrival->address); buf2 = __g_socket_address_to_string (arrival->address);
GST_DEBUG ("New conflict for ssrc %x, replacing %s with %s," GST_DEBUG ("New conflict for ssrc %x, replacing %s with %s,"
" saving old as known conflict", " saving old as known conflict", ssrc, buf1, buf2);
rtp_source_get_ssrc (source), buf1, buf2);
if (rtp) if (rtp)
rtp_source_set_rtp_from (source, arrival->address); rtp_source_set_rtp_from (source, arrival->address);
@ -1252,7 +1254,6 @@ check_collision (RTPSession * sess, RTPSource * source,
*/ */
} else { } else {
/* This is sending with our ssrc, is it an address we already know */ /* This is sending with our ssrc, is it an address we already know */
if (rtp_source_find_conflicting_address (source, arrival->address, if (rtp_source_find_conflicting_address (source, arrival->address,
arrival->current_time)) { arrival->current_time)) {
/* Its a known conflict, its probably a loop, not a collision /* Its a known conflict, its probably a loop, not a collision
@ -1261,16 +1262,18 @@ check_collision (RTPSession * sess, RTPSource * source,
GST_DEBUG ("Our packets are being looped back to us, dropping"); GST_DEBUG ("Our packets are being looped back to us, dropping");
} else { } else {
/* Its a new collision, lets change our SSRC */ /* Its a new collision, lets change our SSRC */
rtp_source_add_conflicting_address (source, arrival->address, rtp_source_add_conflicting_address (source, arrival->address,
arrival->current_time); arrival->current_time);
GST_DEBUG ("Collision for SSRC %x", rtp_source_get_ssrc (source)); GST_DEBUG ("Collision for SSRC %x", ssrc);
/* mark the source BYE */
rtp_source_mark_bye (source, "SSRC Collision");
/* if we were suggesting this SSRC, change to something else */
if (sess->suggested_ssrc == ssrc)
sess->suggested_ssrc = rtp_session_create_new_ssrc (sess);
on_ssrc_collision (sess, source); on_ssrc_collision (sess, source);
sess->change_ssrc = TRUE;
rtp_source_mark_bye (source, "SSRC Collision");
rtp_session_schedule_bye_locked (sess, arrival->current_time); rtp_session_schedule_bye_locked (sess, arrival->current_time);
} }
} }