[Freeswitch-users] patch for sofia_sip_i_invite to support replaces with action

Luis Azedo luis.azedo at factorlusitano.com
Wed Apr 22 14:38:11 MSD 2015


Hi,

i need a inline custom action passed with an INVITE msg with a replaces header
or a better to use this scenario.

right now, for calls with replaces header there is support for sla,
intercept and attendant transfer.

my problem is that intercept requires the bridge_uuid which is not set
on one leg calls (on hold playing music) so the intercept condition
won't be hit.

the attendant transfer takes app/data applies and then hangs up the call.

i need a simple answer,intercept:(sip->sip_replaces->rp_call_id)
instead of bridge_uuid.

i tried to set signal_bond and originate_signal_bound on the channel
to see if i could bypass this, but with no luck.

i created a small patch that i am attaching here with the hope that
FreeSWITCH will look and possibly merge it.

Best
-------------- next part --------------
diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index f8ccbd6..7111a1c 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -9885,7 +9885,19 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
 																						   "%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
 					}
 				} else {
-					if (!zstr(bridge_uuid)) {
+					char* rep_app = NULL;
+					char* rep_data = NULL;
+					if(sip->sip_replaces->rq_url->url_params && sip->sip_replaces->rp_call_id) {
+						rep_app = switch_find_parameter(sip->sip_replaces->rq_url->url_params,"fs-app", switch_core_session_get_pool(session));
+						rep_data = switch_find_parameter(sip->sip_replaces->rq_url->url_params,"fs-data", switch_core_session_get_pool(session));
+					} 
+					if(rep_app && rep_data) {
+						switch_channel_mark_hold(b_channel, SWITCH_FALSE);
+						tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", rep_app, rep_data);
+					} else if(rep_app) {
+						switch_channel_mark_hold(b_channel, SWITCH_FALSE);
+						tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", rep_app);
+					} else if (!zstr(bridge_uuid)) {
 						switch_channel_mark_hold(b_channel, SWITCH_FALSE);
 						tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
 					} else {


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list