]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Fix recovery reinvite issue
authorsurendrasignalwire <surendra.tiwari@siganlwire.com>
Thu, 13 Aug 2020 10:49:47 +0000 (14:49 +0400)
committerAndrey Volk <andywolk@gmail.com>
Tue, 16 Mar 2021 21:16:32 +0000 (00:16 +0300)
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 7f7b0c2b75450f1d4bf13dedc6e9231976042fc0..4975ca8feb29493869d616cd1a3fc12dfbe06686 100644 (file)
@@ -1733,6 +1733,10 @@ static void our_sofia_event_callback(nua_event_t event,
                                        switch_channel_set_variable(channel, "sip_call_id", sip->sip_call_id->i_id);
                                }
 
+                               if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                                       switch_channel_set_variable(channel, "dlg_req_swap_direction", "true");
+                               }
+
                                extract_header_vars(profile, sip, session, nh);
                                switch_core_recovery_track(session);
                                sofia_set_flag(tech_pvt, TFLAG_GOT_ACK);
@@ -7111,8 +7115,13 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
                        }
 
+                       if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+                                switch_channel_set_variable(channel, "dlg_req_swap_direction", "true");
+                       }
+
                        extract_header_vars(profile, sip, session, nh);
                        extract_vars(profile, sip, session);
+                       switch_core_recovery_track(session);
                        switch_channel_clear_flag(tech_pvt->channel, CF_RECOVERING);
                }
 
index a49bd998a9ea4718604cee1044b3cd80d14ade5a..2eea09bd5e08a0bd944a9e54d3520360c3c49f73 100644 (file)
@@ -2235,7 +2235,7 @@ int sofia_recover_callback(switch_core_session_t *session)
        const char *rr;
        int r = 0;
        const char *profile_name = switch_channel_get_variable_dup(channel, "recovery_profile_name", SWITCH_FALSE, -1);
-
+       int swap = switch_channel_var_true(channel, "dlg_req_swap_direction");
 
        if (zstr(profile_name)) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing profile\n");
@@ -2275,10 +2275,9 @@ int sofia_recover_callback(switch_core_session_t *session)
        rr = switch_channel_get_variable(channel, "sip_invite_record_route");
 
        if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
-               int break_rfc = switch_true(switch_channel_get_variable(channel, "sip_recovery_break_rfc"));
                tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_req_uri"));
-               switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, break_rfc ? "sip_full_to" : "sip_full_from"));
-               switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, break_rfc ? "sip_full_from" : "sip_full_to"));
+               switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, swap ? "sip_full_to" : "sip_full_from"));
+               switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, swap ? "sip_full_from" : "sip_full_to"));
        } else {
                const char *contact_params = switch_channel_get_variable(channel, "sip_contact_params");
                const char *contact_uri = switch_channel_get_variable(channel, "sip_contact_uri");
@@ -2297,11 +2296,11 @@ int sofia_recover_callback(switch_core_session_t *session)
                tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_from_uri"));
 
                if (!switch_channel_get_variable_dup(channel, "sip_handle_full_from", SWITCH_FALSE, -1)) {
-                       switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, "sip_full_to"));
+                       switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, swap ? "sip_full_from" :"sip_full_to"));
                }
 
                if (!switch_channel_get_variable_dup(channel, "sip_handle_full_to", SWITCH_FALSE, -1)) {
-                       switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_from"));
+                       switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, swap ? "sip_full_to" : "sip_full_from"));
                }
        }