From 43ef01fbbe10d790c42c9ac631a3aab2f0f09376 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 23 Sep 2015 11:58:57 -0500 Subject: [PATCH] correct version of proposed patch --- src/include/switch_core_media.h | 3 +++ src/mod/endpoints/mod_sofia/mod_sofia.c | 24 ++++++----------- src/mod/endpoints/mod_sofia/sofia.c | 35 ++++++++++++++++++++++--- src/switch_channel.c | 8 +++--- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 5c7c993238..9a60b7a5d1 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -1,3 +1,4 @@ + /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * Copyright (C) 2005-2014, Anthony Minessale II @@ -107,6 +108,8 @@ typedef struct switch_core_media_params_s { char *local_sdp_str; char *last_sdp_str; char *last_sdp_response; + char *prev_sdp_str; + char *prev_sdp_response; char *stun_ip; switch_port_t stun_port; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8b141ef2eb..5cb2ff744b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1541,7 +1541,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi break; case SWITCH_MESSAGE_INDICATE_MESSAGE: { - char *ct = "text/plain"; + char ct[256] = "text/plain"; int ok = 0; if (!zstr(msg->string_array_arg[3]) && !strcmp(msg->string_array_arg[3], tech_pvt->caller_profile->uuid)) { @@ -1550,7 +1550,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { - ct = switch_core_session_sprintf(session, "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]); + switch_snprintf(ct, sizeof(ct), "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]); ok = 1; } @@ -1582,26 +1582,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi break; case SWITCH_MESSAGE_INDICATE_INFO: { - char *ct = "freeswitch/data"; + char ct[256] = "freeswitch/data"; int ok = 0; - if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { - ct = switch_core_session_sprintf(session, "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]); - ok = 1; - } - if (switch_stristr("send_info", tech_pvt->x_freeswitch_support_remote)) { ok = 1; } - /* TODO: 1.4 remove this stanza */ - if (switch_true(switch_channel_get_variable(channel, "fs_send_unspported_info"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "fs_send_unspported_info is deprecated in favor of correctly spelled fs_send_unsupported_info\n"); - ok = 1; - } - - if (switch_true(switch_channel_get_variable(channel, "fs_send_unsupported_info"))) { + if (switch_true(switch_channel_get_variable_dup(channel, "fs_send_unsupported_info", SWITCH_FALSE, -1))) { ok = 1; } @@ -1609,6 +1597,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi char *headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_INFO_HEADER_PREFIX); const char *pl = NULL; + if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { + switch_snprintf(ct, sizeof(ct), "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]); + } + if (!zstr(msg->string_array_arg[2])) { pl = msg->string_array_arg[2]; } diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 4b6662ce03..e979618a8a 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -5977,14 +5977,24 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_channel_set_variable_printf(channel, "sip_network_ip", "%s", network_ip); switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port); - if ((caller_profile = switch_channel_get_caller_profile(channel))) { + if ((caller_profile = switch_channel_get_caller_profile(channel)) && !zstr(network_ip) && + (zstr(caller_profile->network_addr) || strcmp(caller_profile->network_addr, network_ip))) { caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip); } + if (tech_pvt->mparams.last_sdp_response) { + tech_pvt->mparams.prev_sdp_response = tech_pvt->mparams.last_sdp_response; + } tech_pvt->mparams.last_sdp_response = NULL; + if (sip->sip_payload && sip->sip_payload->pl_data) { switch_core_media_set_sdp_codec_string(session, sip->sip_payload->pl_data, SDP_TYPE_RESPONSE); - tech_pvt->mparams.last_sdp_response = switch_core_session_strdup(session, sip->sip_payload->pl_data); + + if (!zstr(tech_pvt->mparams.prev_sdp_response) && !strcmp(tech_pvt->mparams.prev_sdp_response, sip->sip_payload->pl_data)) { + tech_pvt->mparams.last_sdp_response = tech_pvt->mparams.prev_sdp_response; + } else { + tech_pvt->mparams.last_sdp_response = switch_core_session_strdup(session, sip->sip_payload->pl_data); + } } if (status > 299 && switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ)) { @@ -6662,6 +6672,15 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } } } + + if (tech_pvt->mparams.last_sdp_str) { + tech_pvt->mparams.prev_sdp_str = tech_pvt->mparams.last_sdp_str; + } + + if (tech_pvt->mparams.last_sdp_response) { + tech_pvt->mparams.prev_sdp_response = tech_pvt->mparams.last_sdp_response; + } + tech_pvt->mparams.last_sdp_str = NULL; tech_pvt->mparams.last_sdp_response = NULL; @@ -9095,10 +9114,18 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session, } if (channel) { + if (tech_pvt->mparams.last_sdp_str) { + tech_pvt->mparams.prev_sdp_str = tech_pvt->mparams.last_sdp_str; + } tech_pvt->mparams.last_sdp_str = NULL; + if (sip->sip_payload && sip->sip_payload->pl_data) { - switch_channel_set_variable(channel, "sip_reinvite_sdp", sip->sip_payload->pl_data); - tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data); + if (!zstr(tech_pvt->mparams.prev_sdp_str) && strcmp(tech_pvt->mparams.prev_sdp_str, sip->sip_payload->pl_data)) { + switch_channel_set_variable(channel, "sip_reinvite_sdp", sip->sip_payload->pl_data); + tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data); + } else { + tech_pvt->mparams.last_sdp_str = tech_pvt->mparams.prev_sdp_str; + } } switch_channel_execute_on(channel, "execute_on_sip_reinvite"); } diff --git a/src/switch_channel.c b/src/switch_channel.c index dfc23213f6..f528f84a9d 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2523,21 +2523,21 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *chann switch_channel_test_flag(channel, CF_DIALPLAN) ? "true" : "false"); - if ((v = switch_channel_get_variable(channel, "presence_id"))) { + if ((v = switch_channel_get_variable_dup(channel, "presence_id", SWITCH_FALSE, -1))) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Presence-ID", v); } - if ((v = switch_channel_get_variable(channel, "presence_data"))) { + if ((v = switch_channel_get_variable_dup(channel, "presence_data", SWITCH_FALSE, -1))) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Presence-Data", v); } - if ((v = switch_channel_get_variable(channel, "presence_data_cols"))) { + if ((v = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1))) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Data-Cols", v); switch_event_add_presence_data_cols(channel, event, "PD-"); } - if ((v = switch_channel_get_variable(channel, "call_uuid"))) { + if ((v = switch_channel_get_variable_dup(channel, "call_uuid", SWITCH_FALSE, -1))) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", v); } else { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", switch_core_session_get_uuid(channel->session));