]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
correct version of proposed patch
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 23 Sep 2015 16:58:57 +0000 (11:58 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 23 Sep 2015 16:58:57 +0000 (11:58 -0500)
src/include/switch_core_media.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_channel.c

index 5c7c993238b1371087e143bd980056248175ae31..9a60b7a5d108aa23587ce8cd8ccafecea4a14b9b 100644 (file)
@@ -1,3 +1,4 @@
+
 /* 
  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
@@ -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;
index 8b141ef2eb7e3cd176f3055c6ea6a0a667484822..5cb2ff744b9619903d75c8c61e7e5079d9a8ac4a 100644 (file)
@@ -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];
                                }
index 4b6662ce031348e0cdc60ae682d308e8e34d3131..e979618a8a6069a58c418b7b938dbd69a0d3dc6f 100644 (file)
@@ -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");
        }
index dfc23213f638288e121dd8c0a1162426ddcd14d4..f528f84a9da1458022f22d604d6d62312af65992 100644 (file)
@@ -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));