Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
- index c058efb..b74571c 100644
- --- a/src/mod/endpoints/mod_sofia/mod_sofia.c
- +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
- @@ -2454,6 +2454,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
- case SWITCH_MESSAGE_INDICATE_RINGING:
- {
- switch_ring_ready_t ring_ready_val = msg->numeric_arg;
- + const char *val = NULL;
- if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
- switch_channel_mark_ring_ready(channel);
- @@ -2464,7 +2465,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
- }
- if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
- - !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
- + (((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)) ||
- + !switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
- char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
- const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
- char *cid = generate_pai_str(tech_pvt);
- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
- index 759d8f1..1c41a2b 100644
- --- a/src/mod/endpoints/mod_sofia/sofia.c
- +++ b/src/mod/endpoints/mod_sofia/sofia.c
- @@ -5293,6 +5293,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
- int is_dup_sdp = 0;
- switch_event_t *s_event = NULL;
- char *p;
- + int forward_180_after_183 = 0;
- + //const char *igor;
- tl_gets(tags,
- NUTAG_CALLSTATE_REF(ss_state),
- @@ -5310,7 +5312,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
- goto done;
- }
- }
- -
- +/*
- + if ((igor = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(igor)) {
- + forward_180_after_183 = 1;
- + }
- +*/
- if (status > 100 && status < 300 && tech_pvt && !sofia_use_soa(tech_pvt) && !r_sdp && tech_pvt->last_sdp_str) {
- r_sdp = tech_pvt->last_sdp_str;
- }
- @@ -5354,12 +5360,36 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
- }
- if (session) {
- - if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
- + const char *val = NULL;
- + const char *bnumber = NULL;
- + bnumber = switch_channel_get_variable(channel, "destination_number");
- + if ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)) {
- + forward_180_after_183 = 1;
- + }
- +
- + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && (status == 180 || status == 183) &&
- + ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val))) {
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IGOR %s Channel %s skipping state [%s][%d][%s]\n", bnumber,
- + switch_channel_get_name(channel), nua_callstate_name(ss_state), status, val);
- + forward_180_after_183 = 1;
- +
- +/*
- + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) &&
- + ((status == 180) && (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) &&
- + ((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)))) {
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IGOR %s Channel %s skipping state [%s][%d][%s]\n", bnumber,
- + switch_channel_get_name(channel), nua_callstate_name(ss_state), status, val);
- + forward_180_after_183 = 1;
- +*/
- + } else if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
- /* Must you send 180 after 183 w/sdp ? sheesh */
- - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
- +// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "IIII %s Channel %s skipping state [%s][%d]\n", bnumber,
- switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
- goto done;
- } else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (status == 180 || status == 183) && r_sdp) {
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "ZZZZ Channel %s skipping state [%s][%d]\n",
- + switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
- sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
- }
- @@ -5452,14 +5482,32 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
- case nua_callstate_calling:
- break;
- case nua_callstate_proceeding:
- -
- + if (1 == 1) {
- + const char *bnumber;
- + bnumber = switch_channel_get_variable(channel, "destination_number");
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "WWWW %s Channel %s status %i - %i\n", bnumber,
- + switch_channel_get_name(channel), status, forward_180_after_183);
- + }
- switch (status) {
- case 180:
- switch_channel_mark_ring_ready(channel);
- + if (forward_180_after_183) {
- +// IGOR switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
- + switch_channel_get_name(channel));
- + }
- break;
- case 182:
- switch_channel_mark_ring_ready_value(channel, SWITCH_RING_READY_QUEUED);
- break;
- + case 183:
- + if (forward_180_after_183) {
- +// IGOR switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Forwarding 180 Ringing after 183 (Early-Media) %s\n",
- + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "QQQQ Forwarding 180 Ringing after 183 (Early-Media) %s\n",
- + switch_channel_get_name(channel));
- + switch_channel_mark_ring_ready(channel);
- + }
- + break;
- default:
- break;
- }
- diff --git a/src/switch_channel.c b/src/switch_channel.c
- index a0b5b9c..372addf 100644
- --- a/src/switch_channel.c
- +++ b/src/switch_channel.c
- @@ -2983,6 +2983,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
- {
- switch_core_session_message_t msg = { 0 };
- switch_status_t status = SWITCH_STATUS_SUCCESS;
- + const char *val = NULL;
- switch_assert(channel != NULL);
- @@ -2994,7 +2995,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
- return SWITCH_STATUS_SUCCESS;
- }
- - if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
- + if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && (!((val = switch_channel_get_variable(channel, "forward_180_after_183")) && switch_true(val)))) {
- return SWITCH_STATUS_SUCCESS;
- }
- diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c
- index 6fd926d..60acde2 100644
- --- a/src/switch_ivr_bridge.c
- +++ b/src/switch_ivr_bridge.c
- @@ -161,7 +161,7 @@ typedef struct switch_ivr_bridge_data switch_ivr_bridge_data_t;
- static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
- {
- switch_ivr_bridge_data_t *data = obj;
- - int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, originator = 0;
- + int stream_id = 0, pre_b = 0, ans_a = 0, ans_b = 0, ring_b = 0, originator = 0;
- switch_input_callback_function_t input_callback;
- switch_core_session_message_t msg = { 0 };
- void *user_data;
- @@ -182,6 +182,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
- time_t answer_limit = 0;
- const char *exec_app = NULL;
- const char *exec_data = NULL;
- + uint8_t forward_180_after_183 = 0;
- #ifdef SWITCH_VIDEO_IN_THREADS
- switch_thread_t *vid_thread = NULL;
- @@ -228,7 +229,11 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
- }
- }
- -
- + if (!switch_channel_test_flag(chan_a, CF_ANSWERED)) {
- + const char *val = switch_channel_get_variable(chan_a, "forward_180_after_183");
- + forward_180_after_183 = switch_true(val);
- + }
- +
- switch_channel_set_flag(chan_a, CF_BRIDGED);
- switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
- @@ -425,6 +430,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
- goto end_of_bridge_loop;
- }
- pre_b = 1;
- + } else if (!ring_b && switch_channel_test_flag(chan_b, CF_RING_READY) && switch_channel_test_flag(chan_b, CF_EARLY_MEDIA) && forward_180_after_183) {
- + switch_channel_ring_ready(chan_a);
- + ring_b = 1;
- }
- if (!pre_b) {
- switch_yield(10000);
- diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c
- index 582ca2e..508f473 100644
- --- a/src/switch_ivr_originate.c
- +++ b/src/switch_ivr_originate.c
- @@ -113,6 +113,7 @@ typedef struct {
- uint8_t gen_ringback;
- uint8_t ignore_early_media;
- uint8_t ignore_ring_ready;
- + uint8_t forward_180_after_183;
- int monitor_early_media_ring_count;
- int monitor_early_media_ring_total;
- int cancel_timeout;
- @@ -473,6 +474,10 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
- if (oglobals->sending_ringback == 1) {
- send_ringback++;
- pindex = (uint32_t) i;
- +
- + if (oglobals->forward_180_after_183 && switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA)) {
- + switch_channel_ring_ready_value(caller_channel, ring_ready_val);
- + }
- } else {
- if (!oglobals->ring_ready) {
- oglobals->ring_ready = ring_ready_val;
- @@ -483,6 +488,9 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
- switch_channel_ring_ready_value(caller_channel, ring_ready_val);
- oglobals->sent_ring = ring_ready_val;
- }
- + } else if (!oglobals->sent_ring) {
- + switch_channel_ring_ready_value(caller_channel, ring_ready_val);
- + oglobals->sent_ring = ring_ready_val;
- }
- }
- }
- @@ -1961,6 +1969,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
- ok = 1;
- } else if (!strcasecmp((char *) hi->name, "language")) {
- ok = 1;
- + } else if (!strcasecmp((char *) hi->name, "forward_180_after_183")) {
- + ok = 1;
- }
- if (ok && !switch_event_get_header(var_event, hi->name)) {
- @@ -2080,6 +2090,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
- }
- }
- + if ((var_val = switch_event_get_header(var_event, "forward_180_after_183"))) {
- + if (switch_true(var_val)) {
- + oglobals.forward_180_after_183 = 1;
- + }
- + }
- +
- if ((var_val = switch_event_get_header(var_event, "originate_continue_on_timeout")) && switch_true(var_val)) {
- oglobals.continue_on_timeout = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement