From 9868741717441e9b435df80e826fe9c637a47c95 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 26 Dec 2007 22:33:46 +0000 Subject: [PATCH] sip updates git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6987 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 12 ++++++------ src/mod/endpoints/mod_sofia/sofia.c | 15 ++++++++++++++- src/switch_ivr_bridge.c | 6 +++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 60b362deea..f82a79edc8 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -251,7 +251,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) cause = switch_channel_get_cause(channel); -#if 0 if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) { const char *buuid; switch_core_session_t *bsession; @@ -266,11 +265,13 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { if ((bsession = switch_core_session_locate(buuid))) { bchannel = switch_core_session_get_channel(bsession); - if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) { - switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL); + if (switch_channel_test_flag(bchannel, CF_BROADCAST)) { + if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) { + switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL); + } + switch_channel_clear_flag(bchannel, CF_BROADCAST); + switch_channel_set_flag(bchannel, CF_BREAK); } - switch_channel_clear_flag(bchannel, CF_BROADCAST); - switch_channel_set_flag(bchannel, CF_BREAK); switch_core_session_rwunlock(bsession); } } @@ -278,7 +279,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); } -#endif sip_cause = hangup_cause_to_sip(cause); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index d8193e4ec1..f59400baa4 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1765,7 +1765,8 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END()); switch_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD); - switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER); + switch_ivr_park_session(b_session); + //switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER); } else { if (!br_a && !br_b) { switch_set_flag_locked(tech_pvt, TFLAG_NOHUP); @@ -1943,6 +1944,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t /* placeholder for string searching */ const char *signal_ptr; const char *rec_header; + const char *clientcode_header; switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION }; if (session) { @@ -2001,6 +2003,17 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t } } + if ((clientcode_header = sofia_glue_get_unknown_header(sip, "x-clientcode"))) { + if(!switch_strlen_zero(clientcode_header)) { + switch_channel_set_variable(channel, "call_clientcode", clientcode_header); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Setting CMC to %s\n", clientcode_header); + nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END()); + } else { + goto fail; + } + return; + } + if ((rec_header = sofia_glue_get_unknown_header(sip, "record"))) { if (switch_strlen_zero(profile->record_template)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Record attempted but no template defined.\n"); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index a1b9ef9431..38d4bd6b58 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -222,8 +222,8 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) end: switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK); - switch_channel_clear_flag(chan_b, CF_BROADCAST); - switch_channel_set_flag(chan_b, CF_BREAK); + //switch_channel_clear_flag(chan_b, CF_BROADCAST); + //switch_channel_set_flag(chan_b, CF_BREAK); switch_core_session_reset(session_a); switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a)); @@ -252,7 +252,7 @@ static switch_status_t audio_bridge_on_loopback(switch_core_session_t *session) } switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers); - if (!switch_channel_test_flag(channel, CF_TRANSFER)) { + if (!switch_channel_test_flag(channel, CF_TRANSFER) && switch_channel_get_state(channel) == CS_LOOPBACK) { switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); }