From 59b0f331ad214c21684e2964ecdc4fa99ea12417 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 26 Aug 2015 13:53:11 -0400 Subject: [PATCH] ignore endpoint changes when ICE is in use --- daemon/call.c | 19 ++++++++++++++----- daemon/ice.h | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index f1381d6a3..c1f2a62f1 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1892,8 +1892,11 @@ static int __num_media_streams(struct call_media *media, unsigned int num_ports) return ret; } -static void __fill_stream(struct packet_stream *ps, const struct endpoint *epp, unsigned int port_off) { +static void __fill_stream(struct packet_stream *ps, const struct endpoint *epp, unsigned int port_off, + const struct stream_params *sp) +{ struct endpoint ep; + struct call_media *media = ps->media; ep = *epp; ep.port += port_off; @@ -1902,9 +1905,15 @@ static void __fill_stream(struct packet_stream *ps, const struct endpoint *epp, if (PS_ISSET(ps, FILLED) && !memcmp(&ps->advertised_endpoint, &ep, sizeof(ep))) return; - ps->endpoint = ep; ps->advertised_endpoint = ep; + /* ignore endpoint changes if we're ICE-enabled and ICE data hasn't changed */ + if (PS_ISSET(ps, FILLED) && MEDIA_ISSET(media, ICE) && media->ice_agent && sp + && !ice_ufrag_cmp(media->ice_agent, &sp->ice_ufrag)) + return; + + ps->endpoint = ep; + if (PS_ISSET(ps, FILLED)) { /* we reset crypto params whenever the endpoint changes */ crypto_reset(&ps->crypto); @@ -2020,7 +2029,7 @@ static int __init_streams(struct call_media *A, struct call_media *B, const stru __rtp_stats_update(a->rtp_stats, A->rtp_payload_types); if (sp) { - __fill_stream(a, &sp->rtp_endpoint, port_off); + __fill_stream(a, &sp->rtp_endpoint, port_off, sp); bf_copy_same(&a->ps_flags, &sp->sp_flags, SHARED_FLAG_STRICT_SOURCE | SHARED_FLAG_MEDIA_HANDOVER); } @@ -2065,11 +2074,11 @@ static int __init_streams(struct call_media *A, struct call_media *B, const stru if (sp) { if (!SP_ISSET(sp, IMPLICIT_RTCP)) { - __fill_stream(a, &sp->rtcp_endpoint, port_off); + __fill_stream(a, &sp->rtcp_endpoint, port_off, sp); PS_CLEAR(a, IMPLICIT_RTCP); } else { - __fill_stream(a, &sp->rtp_endpoint, port_off + 1); + __fill_stream(a, &sp->rtp_endpoint, port_off + 1, sp); PS_SET(a, IMPLICIT_RTCP); } bf_copy_same(&a->ps_flags, &sp->sp_flags, diff --git a/daemon/ice.h b/daemon/ice.h index cd7922ee4..bbf057123 100644 --- a/daemon/ice.h +++ b/daemon/ice.h @@ -203,6 +203,9 @@ INLINE const char *ice_candidate_type_str(enum ice_candidate_type type) { return 0; return ice_type_strings[type]; } +INLINE int ice_ufrag_cmp(struct ice_agent *ag, const str *s) { + return str_cmp_str0(&ag->ufrag[0], s); +}