From 8839d61523474fa0d012528b61411625de69e1a6 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 2 Apr 2013 13:37:04 -0500 Subject: [PATCH] fix typo --- src/switch_rtp.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 7650dd9c84..7fbe1b6c7c 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -178,6 +178,7 @@ typedef struct { uint8_t ready; uint8_t rready; int missed_count; + int flips; } switch_rtp_ice_t; struct switch_rtp; @@ -726,7 +727,7 @@ static switch_status_t ice_out(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice) switch_snprintf(sw, sizeof(sw), "FreeSWITCH (%s)", SWITCH_VERSION_REVISION_HUMAN); switch_stun_packet_attribute_add_software(packet, sw, strlen(sw)); - if ((ice->type && ICE_CONTROLLED)) { + if ((ice->type & ICE_CONTROLLED)) { switch_stun_packet_attribute_add_controlled(packet); } else { switch_stun_packet_attribute_add_controlling(packet); @@ -799,11 +800,26 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d } -#if 0 - if (ice->sending && (packet->header.type == SWITCH_STUN_BINDING_RESPONSE || packet->header.type == SWITCH_STUN_BINDING_ERROR_RESPONSE)) { - ice->sending = 0; + + if (packet->header.type == SWITCH_STUN_BINDING_ERROR_RESPONSE) { + + if (ice->flips < 4) { + if ((ice->type & ICE_CONTROLLED)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "Changing role to CONTROLLING\n"); + ice->type &= ~ICE_CONTROLLED; + ice->flips++; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "Changing role to CONTROLLED\n"); + ice->type |= ICE_CONTROLLED; + ice->flips++; + } + + packet->header.type = SWITCH_STUN_BINDING_RESPONSE; + } + + } else { + ice->flips = 0; } -#endif end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));