From f7408f8829d65e6429b759c6dee01d4149dc2449 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 12:31:40 -0500 Subject: [PATCH 01/18] FS-4903 --resolve some of these are better of reverted but not all, this should work --- src/mod/applications/mod_fifo/mod_fifo.c | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 5d21fc141e..b232349643 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -759,7 +759,7 @@ static switch_status_t fifo_execute_sql_queued(char **sqlp, switch_bool_t sql_al if (switch_stristr("insert", sql)) { index = 0; } - + if (block) { switch_sql_queue_manager_push_confirm(globals.qm, sql, index, !sql_already_dynamic); } else { @@ -1409,7 +1409,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } @@ -1451,7 +1451,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1 " "where uuid='%q' and ring_count > 0", h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } } @@ -1465,7 +1465,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void "outbound_fail_total_count = outbound_fail_total_count+1, " "next_avail=%ld + lag + 1 where uuid='%q' and ring_count > 0", (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } } @@ -1522,7 +1522,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void for (i = 0; i < cbh->rowcount; i++) { struct call_helper *h = cbh->rows[i]; char *sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1 where uuid='%q' and ring_count > 0", h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } end: @@ -1632,7 +1632,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) sql = switch_mprintf("update fifo_outbound set ring_count=ring_count+1 where uuid='%s'", h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); status = switch_ivr_originate(NULL, &session, &cause, originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL); free(originate_string); @@ -1642,7 +1642,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) sql = switch_mprintf("update fifo_outbound set ring_count=ring_count-1, " "outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag + 1 where uuid='%q'", (long) switch_epoch_time_now(NULL), h->uuid); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", node->name); @@ -2150,7 +2150,7 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve del_bridge_call(outbound_id); sql = switch_mprintf("update fifo_outbound set use_count=use_count-1, stop_time=%ld, next_avail=%ld + lag + 1 where use_count > 0 and uuid='%q'", now, now, outbound_id); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } if (send_event) { @@ -2217,7 +2217,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function) sql = switch_mprintf("update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'", (long) switch_epoch_time_now(NULL), col1, col1, col2, col2, data); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { @@ -3038,7 +3038,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_epoch_time_now(NULL), outbound_id); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); } add_bridge_call(switch_core_session_get_uuid(other_session)); @@ -3073,7 +3073,7 @@ SWITCH_STANDARD_APP(fifo_function) "outbound_call_count=outbound_call_count+1, next_avail=%ld + lag + 1 where uuid='%s' and use_count > 0", now, now, outbound_id); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); del_bridge_call(outbound_id); @@ -4072,7 +4072,7 @@ static switch_status_t load_config(int reload, int del_all) if (!reload) { char *sql= "update fifo_outbound set start_time=0,stop_time=0,ring_count=0,use_count=0,outbound_call_count=0,outbound_fail_count=0 where static=0"; - fifo_execute_sql_queued(&sql, SWITCH_FALSE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_FALSE, SWITCH_TRUE); } if (reload) { @@ -4095,7 +4095,7 @@ static switch_status_t load_config(int reload, int del_all) sql = switch_mprintf("delete from fifo_outbound where static=1 and hostname='%q'", globals.hostname); } - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); if (!(node = switch_core_hash_find(globals.fifo_hash, MANUAL_QUEUE_NAME))) { node = create_node(MANUAL_QUEUE_NAME, 0, globals.sql_mutex); From 3b50675d25622a095162139320033bc1a3389973 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 12:41:17 -0500 Subject: [PATCH 02/18] FS-5231 --resolve --- src/include/switch_ivr.h | 9 ++++++++ .../applications/mod_commands/mod_commands.c | 4 +++- src/switch_ivr.c | 22 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index e4e8517781..daa97cc364 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -591,6 +591,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi */ SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh); +/*! + \brief Toggles channel hold state of session + \param uuid the uuid of the session to hold + \param message optional message + \param moh play music-on-hold + \return SWITCH_STATUS_SUCCESS if all is well +*/ +SWITCH_DECLARE(switch_status_t) switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh); + /*! \brief Signal the session with a protocol specific unhold message. \param uuid the uuid of the session to hold diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index a560e7f905..62fa59a6b9 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -3184,7 +3184,7 @@ SWITCH_STANDARD_API(sched_broadcast_function) return SWITCH_STATUS_SUCCESS; } -#define HOLD_SYNTAX "[off] []" +#define HOLD_SYNTAX "[off|toggle] []" SWITCH_STANDARD_API(uuid_hold_function) { char *mycmd = NULL, *argv[4] = { 0 }; @@ -3200,6 +3200,8 @@ SWITCH_STANDARD_API(uuid_hold_function) } else { if (!strcasecmp(argv[0], "off")) { status = switch_ivr_unhold_uuid(argv[1]); + } else if (!strcasecmp(argv[0], "toggle")) { + status = switch_ivr_hold_toggle_uuid(argv[1], argv[2], 1); } else { status = switch_ivr_hold_uuid(argv[0], argv[1], 1); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index c57ace9be4..8256b861b4 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1445,6 +1445,28 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const cha return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(switch_status_t) switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh) +{ + switch_core_session_t *session; + switch_channel_t *channel; + switch_channel_callstate_t callstate; + + if ((session = switch_core_session_locate(uuid))) { + if ((channel = switch_core_session_get_channel(session))) { + callstate = switch_channel_get_callstate(channel); + + if (callstate == CCS_ACTIVE) { + switch_ivr_hold(session, message, moh); + } else if (callstate == CCS_HELD) { + switch_ivr_unhold(session); + } + } + switch_core_session_rwunlock(session); + } + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session) { switch_core_session_message_t msg = { 0 }; From 8efaea29af4fc302ba2916f96c404c05c1d1ecd3 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 13:40:51 -0500 Subject: [PATCH 03/18] FS-5228 --resolve problem was actually in the send_silence code as used from park not uuid_displace but uuid_displace relies on the write stream so thus it was a symptom --- src/switch_ivr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 8256b861b4..92440ce78f 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -931,7 +931,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, if (switch_core_codec_init(&codec, "L16", NULL, - imp.samples_per_second, + imp.actual_samples_per_second, imp.microseconds_per_packet / 1000, imp.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, From eed868af6cd104ab71fca99e2f039fc78238f4c6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 13:52:03 -0500 Subject: [PATCH 04/18] FS-5230 --resolve this was actually a bug in the -1 val in send_silence_when_idle --- src/switch_resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_resample.c b/src/switch_resample.c index 6722d6f448..9e7c07117a 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -191,7 +191,7 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples assert(divisor); if (divisor == (uint32_t)-1) { - memset(data, 0, sizeof(*data)); + memset(data, 0, samples * 2); return; } From 861c3e3ccce7d29b5c62a24dc03eaa6118de9093 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 14:54:01 -0500 Subject: [PATCH 05/18] add switch_core_get_variables and allow execute_on funcs to see global vars too --- src/include/switch_core.h | 1 + src/switch_channel.c | 9 ++++++--- src/switch_core.c | 9 +++++++++ src/switch_ivr_bridge.c | 6 +++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 78b3827aa9..21e80e28d5 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -811,6 +811,7 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void); \param value the value of the variable */ SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value); +SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event); /*! \brief Conditionally add a global variable to the core diff --git a/src/switch_channel.c b/src/switch_channel.c index 655dea39c0..827d7ea65b 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3337,7 +3337,7 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) char *app; app = switch_core_session_strdup(channel->session, variable); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "EXEC %s\n", app); for(p = app; p && *p; p++) { if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) { *p++ = '\0'; @@ -3360,10 +3360,12 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix) { switch_event_header_t *hp; - switch_event_t *event; + switch_event_t *event, *cevent; int x = 0; - switch_channel_get_variables(channel, &event); + switch_core_get_variables(&event); + switch_channel_get_variables(channel, &cevent); + switch_event_merge(event, cevent); for (hp = event->headers; hp; hp = hp->next) { char *var = hp->name; @@ -3384,6 +3386,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *chan } switch_event_destroy(&event); + switch_event_destroy(&cevent); return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; } diff --git a/src/switch_core.c b/src/switch_core.c index 60e133c730..64ad73c685 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -307,6 +307,15 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void) } +SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event) +{ + switch_status_t status; + switch_thread_rwlock_rdlock(runtime.global_var_rwlock); + status = switch_event_dup(event, runtime.global_vars); + switch_thread_rwlock_unlock(runtime.global_var_rwlock); + return status; +} + SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname) { char *val; diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 7a20f87b5c..2d80d93573 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -358,8 +358,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) } #endif - if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { - + if (read_frame_count == DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE); if (!inner_bridge) { @@ -373,8 +372,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_execute_application_async(session_a, exec_app, exec_data); exec_app = exec_data = NULL; } + } - + if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED) && switch_channel_test_flag(chan_b, CF_ANSWERED)) { switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE); From c510a811774c73ed6b9022c7331eea00d62695f9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 15:18:54 -0500 Subject: [PATCH 06/18] do not pause callers when they come out of a bridge --- src/mod/applications/mod_fifo/mod_fifo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index b232349643..7e75326147 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -3108,8 +3108,9 @@ SWITCH_STANDARD_APP(fifo_function) fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); - switch_core_media_bug_pause(session); - switch_core_media_bug_pause(other_session); + if (switch_channel_ready(channel)) { + switch_core_media_bug_pause(session); + } if (record_template) { switch_ivr_stop_record_session(session, expanded); From b4e21fd3f6eb3b11773a9588d2da2fb10b470dd2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 15:39:10 -0500 Subject: [PATCH 07/18] FS-5229 --resolve oops, i missed the part that its subsequent calls to displace --- src/switch_ivr_async.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 1e1e10eeaa..e2ef526af8 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -844,8 +844,9 @@ static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user } } else { st = switch_core_file_read(&dh->fh, rframe->data, &len); - rframe->samples = (uint32_t) len; - rframe->datalen = rframe->samples * 2; + if (len < rframe->samples) { + memset(rframe->data, 0, rframe->datalen - len * 2); + } } if (st != SWITCH_STATUS_SUCCESS || len == 0) { From 14e3570848dd7e4680d954b9a76781b3d6c5dae0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 15:51:23 -0500 Subject: [PATCH 08/18] add switch_core_session_findall to get a list of all open uuid --- src/include/switch_core.h | 2 +- src/switch_core_session.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 21e80e28d5..1bad6377e8 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -848,7 +848,7 @@ SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const switch_call_cause_t cause, switch_hup_type_t type); SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall_matching_var(const char *var_name, const char *var_val); #define switch_core_session_hupall_matching_var(_vn, _vv, _c) switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED) - +SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall(void); /*! \brief Hangup all sessions that belong to an endpoint \param endpoint_interface The endpoint interface diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 3c0672276f..410ffa711b 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -381,6 +381,29 @@ SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause) } +SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall(void) +{ + switch_hash_index_t *hi; + void *val; + switch_core_session_t *session; + switch_console_callback_match_t *my_matches = NULL; + + switch_mutex_lock(runtime.session_hash_mutex); + for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + if (val) { + session = (switch_core_session_t *) val; + if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { + switch_console_push_match(&my_matches, session->uuid_str); + switch_core_session_rwunlock(session); + } + } + } + switch_mutex_unlock(runtime.session_hash_mutex); + + return my_matches; +} + SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(const char *uuid_str, switch_core_session_message_t *message) { switch_core_session_t *session = NULL; From e3ac7c50acf8c28225f584e7088d86eaaa68367d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 16:50:10 -0500 Subject: [PATCH 09/18] FS-5238 --resolve --- src/switch.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/switch.c b/src/switch.c index f86b080996..68f6af341d 100644 --- a/src/switch.c +++ b/src/switch.c @@ -929,16 +929,6 @@ int main(int argc, char *argv[]) } #endif - if (nc) { -#ifdef WIN32 - FreeConsole(); -#else - if (!nf) { - daemonize(do_wait); - } -#endif - } - switch (priority) { case 2: set_realtime_priority(); @@ -956,7 +946,6 @@ int main(int argc, char *argv[]) switch_core_setrlimits(); - #ifndef WIN32 if (runas_user || runas_group) { if (change_user_group(runas_user, runas_group) < 0) { @@ -966,7 +955,19 @@ int main(int argc, char *argv[]) return 255; } } +#endif + + if (nc) { +#ifdef WIN32 + FreeConsole(); #else + if (!nf) { + daemonize(do_wait); + } +#endif + } + +#ifdef WIN32 if (win32_service) { /* Attempt to start service */ SERVICE_TABLE_ENTRY dispatchTable[] = { From 7818c3c9edf99c95a32c0f5dae6c7f66ecc7c56e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 17:19:40 -0500 Subject: [PATCH 10/18] add SMBF_ONE_ONLY flag and use it on dtmf detectors --- src/include/switch_types.h | 3 ++- .../mod_spandsp/mod_spandsp_dsp.c | 2 +- src/switch_core_media_bug.c | 20 ++++++++++++++++++- src/switch_ivr_async.c | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 9f89289d86..903d083ccb 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1510,7 +1510,8 @@ typedef enum { SMBF_STEREO_SWAP = (1 << 11), SMBF_LOCK = (1 << 12), SMBF_TAP_NATIVE_READ = (1 << 13), - SMBF_TAP_NATIVE_WRITE = (1 << 14) + SMBF_TAP_NATIVE_WRITE = (1 << 14), + SMBF_ONE_ONLY = (1 << 15) } switch_media_bug_flag_enum_t; typedef uint32_t switch_media_bug_flag_t; diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index 906d7787e6..eec68dce91 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -505,7 +505,7 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session) } if ((status = switch_core_media_bug_add(session, "spandsp_dtmf_detect", NULL, - inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { + inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE | SMBF_ONE_ONLY, &bug)) != SWITCH_STATUS_SUCCESS) { return status; } diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 9999c644e7..c340b71e63 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -411,10 +411,28 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t switch_media_bug_t *bug, *bp; switch_size_t bytes; switch_event_t *event; - int tap_only = 1; + int tap_only = 1, punt = 0; const char *p; + if (!zstr(function)) { + if ((flags & SMBF_ONE_ONLY)) { + switch_thread_rwlock_wrlock(session->bug_rwlock); + for (bp = session->bugs; bp; bp = bp->next) { + if (!zstr(bp->function) && !strcasecmp(function, bp->function)) { + punt = 1; + break; + } + } + switch_thread_rwlock_unlock(session->bug_rwlock); + } + } + + if (punt) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!\n"); + } + + if (!switch_channel_media_ready(session->channel)) { if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index e2ef526af8..45d7711835 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -2588,7 +2588,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_session(switch_core_sessi } if ((status = switch_core_media_bug_add(session, "inband_dtmf", NULL, - inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) { + inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE | SMBF_ONE_ONLY, &bug)) != SWITCH_STATUS_SUCCESS) { return status; } From 6cedccd6fe543704a261c02e5ff9236310cf8f42 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 27 Mar 2013 18:47:13 -0500 Subject: [PATCH 11/18] FS-5229 missed a spot --- src/switch_ivr_async.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 45d7711835..f1ff4ae399 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -845,7 +845,7 @@ static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user } else { st = switch_core_file_read(&dh->fh, rframe->data, &len); if (len < rframe->samples) { - memset(rframe->data, 0, rframe->datalen - len * 2); + memset(rframe->data + len * 2, 0, rframe->datalen - len * 2); } } From b8b71760863f7ffb91dcac79d906803ccfffe457 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 27 Mar 2013 22:19:58 -0500 Subject: [PATCH 12/18] remove debug line left in by accident --- src/switch_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index 827d7ea65b..f673c8659f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3337,7 +3337,7 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) char *app; app = switch_core_session_strdup(channel->session, variable); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "EXEC %s\n", app); + for(p = app; p && *p; p++) { if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) { *p++ = '\0'; From fe1a7583386bc39437de3ae14629564e797015cd Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 28 Mar 2013 17:36:01 +0800 Subject: [PATCH 13/18] fix void * arithmatic warning --- src/switch_ivr_async.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index f1ff4ae399..40852b9768 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -845,7 +845,7 @@ static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user } else { st = switch_core_file_read(&dh->fh, rframe->data, &len); if (len < rframe->samples) { - memset(rframe->data + len * 2, 0, rframe->datalen - len * 2); + memset((char *)rframe->data + len * 2, 0, rframe->datalen - len * 2); } } From b15ac31174a8c04a4f1e71be243e870880d70c91 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 28 Mar 2013 11:24:49 -0400 Subject: [PATCH 14/18] dont ever return success when we don't end up with a new session --- src/switch_ivr_originate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index f204ee1f4e..1f16473949 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -3756,6 +3756,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess *bleg = NULL; } + if (bleg && !*bleg && status == SWITCH_STATUS_SUCCESS) { + status = SWITCH_STATUS_FALSE; + } + if (bleg && *bleg) { switch_channel_t *bchan = switch_core_session_get_channel(*bleg); From 3b6ae8966df127cd7f7d33e6d1c384a69c96e61c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 28 Mar 2013 10:12:00 -0500 Subject: [PATCH 15/18] set bridge times before firing the bridge event --- src/switch_ivr_bridge.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 2d80d93573..5d75d9bd5d 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -201,8 +201,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) chan_a = switch_core_session_get_channel(session_a); chan_b = switch_core_session_get_channel(session_b); - switch_channel_set_bridge_time(chan_a); - + if ((exec_app = switch_channel_get_variable(chan_a, "bridge_pre_execute_app"))) { exec_data = switch_channel_get_variable(chan_a, "bridge_pre_execute_data"); } @@ -972,6 +971,9 @@ static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE)); switch_channel_set_variable(channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE)); + + switch_channel_set_bridge_time(channel); + if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) { if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) { @@ -982,6 +984,9 @@ static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session switch_channel_event_set_data(channel, event); if ((other_session = switch_core_session_locate(msg.string_arg))) { switch_channel_t *other_channel = switch_core_session_get_channel(other_session); + + switch_channel_set_bridge_time(other_channel); + switch_event_add_presence_data_cols(other_channel, event, "Bridge-B-PD-"); switch_core_session_rwunlock(other_session); } @@ -1162,9 +1167,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t * switch_event_fire(&event); } - switch_channel_set_bridge_time(caller_channel); - switch_channel_set_bridge_time(peer_channel); - switch_channel_set_state_flag(caller_channel, CF_RESET); switch_channel_set_state_flag(peer_channel, CF_RESET); @@ -1263,6 +1265,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session)); + switch_channel_set_bridge_time(caller_channel); + switch_channel_set_bridge_time(peer_channel); + if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", switch_core_session_get_uuid(peer_session)); From e6ef517354da6d6653463f37e3fc2d27bb14e872 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 28 Mar 2013 10:41:28 -0500 Subject: [PATCH 16/18] FS-5011 add sync up flags so neither file writes data until audio is moving both ways --- src/switch_ivr_async.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 40852b9768..b545748cb2 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1090,6 +1090,8 @@ struct record_helper { switch_file_handle_t in_fh; switch_file_handle_t out_fh; int native; + int rready; + int wready; uint32_t packet_len; int min_sec; switch_bool_t hangup_on_error; @@ -1115,16 +1117,24 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s break; case SWITCH_ABC_TYPE_TAP_NATIVE_READ: { - nframe = switch_core_media_bug_get_native_read_frame(bug); - len = nframe->datalen; - switch_core_file_write(&rh->in_fh, nframe->data, &len); + rh->rready = 1; + + if (rh->rready && rh->wready) { + nframe = switch_core_media_bug_get_native_read_frame(bug); + len = nframe->datalen; + switch_core_file_write(&rh->in_fh, nframe->data, &len); + } } break; case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE: { - nframe = switch_core_media_bug_get_native_write_frame(bug); - len = nframe->datalen; - switch_core_file_write(&rh->out_fh, nframe->data, &len); + rh->wready = 1; + + if (rh->rready && rh->wready) { + nframe = switch_core_media_bug_get_native_write_frame(bug); + len = nframe->datalen; + switch_core_file_write(&rh->out_fh, nframe->data, &len); + } } break; case SWITCH_ABC_TYPE_CLOSE: From 32b7673cdefa18aa02dec85743f684cf412eb7cd Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 28 Mar 2013 14:19:23 -0500 Subject: [PATCH 17/18] Fix Execute on in early media situations --- src/switch_ivr_bridge.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 5d75d9bd5d..96d664e5fd 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -170,7 +170,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_t *session_a, *session_b; uint32_t read_frame_count = 0; const char *app_name = NULL, *app_arg = NULL; - int inner_bridge = 0; + int inner_bridge = 0, exec_check = 0; switch_codec_t silence_codec = { 0 }; switch_frame_t silence_frame = { 0 }; int16_t silence_data[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 }; @@ -357,11 +357,15 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) } #endif - if (read_frame_count == DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { - switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE); + if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { - if (!inner_bridge) { - switch_channel_api_on(chan_a, SWITCH_API_BRIDGE_START_VARIABLE); + if (!exec_check) { + switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE); + + if (!inner_bridge) { + switch_channel_api_on(chan_a, SWITCH_API_BRIDGE_START_VARIABLE); + } + exec_check = 1; } if (exec_app) { @@ -371,9 +375,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_execute_application_async(session_a, exec_app, exec_data); exec_app = exec_data = NULL; } - } - - if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { + if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED) && switch_channel_test_flag(chan_b, CF_ANSWERED)) { switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE); From aca9257f93e6ebca0e3f2a63a83b1b30ff449698 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 28 Mar 2013 22:17:28 -0500 Subject: [PATCH 18/18] tweaks for caller id in certian uuid_bridge situations --- src/include/switch_channel.h | 8 ++++++-- src/mod/applications/mod_fifo/mod_fifo.c | 21 +++++++++++++++++---- src/switch_channel.c | 14 ++++++++++++-- src/switch_ivr_bridge.c | 12 ++++++++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 73eb7f1026..6af8cfb72c 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -187,6 +187,7 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel); \param caller_profile the profile to assign */ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) switch_channel_step_caller_profile(switch_channel_t *channel); /*! \brief Retrieve the given channel's caller profile @@ -200,7 +201,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit \param channel channel to assign the profile to \param caller_profile the profile to assign */ -SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) _switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +#define switch_channel_set_originator_caller_profile(_c, _cp) switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(_c), SWITCH_LOG_CRIT, "%s SET ORIGINATOR\n", switch_channel_get_name(_c)); _switch_channel_set_originator_caller_profile(_c, _cp) SWITCH_DECLARE(void) switch_channel_set_hunt_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); @@ -216,7 +218,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_p \param channel channel to assign the profile to \param caller_profile the profile to assign */ -SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +SWITCH_DECLARE(void) _switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); +#define switch_channel_set_originatee_caller_profile(_c, _cp) switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(_c), SWITCH_LOG_CRIT, "%s SET ORIGINATEE\n", switch_channel_get_name(_c)); _switch_channel_set_originatee_caller_profile(_c, _cp) /*! \brief Retrieve the given channel's originatee caller profile @@ -651,6 +654,7 @@ SWITCH_DECLARE(void) switch_channel_state_thread_lock(switch_channel_t *channel) SWITCH_DECLARE(void) switch_channel_state_thread_unlock(switch_channel_t *channel); SWITCH_DECLARE(switch_status_t) switch_channel_state_thread_trylock(switch_channel_t *channel); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 7e75326147..685517beef 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2906,7 +2906,7 @@ SWITCH_STANDARD_APP(fifo_function) if (node && other_session) { switch_channel_t *other_channel = switch_core_session_get_channel(other_session); - switch_caller_profile_t *cloned_profile; + switch_caller_profile_t *cloned_profile, *a_cp, *b_cp; const char *o_announce = NULL; const char *record_template = switch_channel_get_variable(channel, "fifo_record_template"); char *expanded = NULL; @@ -2931,7 +2931,6 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_set_variable(other_channel, "fifo_serviced_by", my_id); switch_channel_set_variable(other_channel, "fifo_serviced_uuid", switch_core_session_get_uuid(session)); - switch_channel_set_flag(other_channel, CF_BREAK); while (switch_channel_ready(channel) && switch_channel_ready(other_channel) && @@ -2981,15 +2980,29 @@ SWITCH_STANDARD_APP(fifo_function) } switch_channel_answer(channel); - cloned_profile = switch_caller_profile_clone(other_session, switch_channel_get_caller_profile(channel)); + + a_cp = switch_channel_get_caller_profile(channel); + b_cp = switch_channel_get_caller_profile(other_channel); + + + + cloned_profile = switch_caller_profile_clone(other_session, a_cp); switch_assert(cloned_profile); switch_channel_set_originator_caller_profile(other_channel, cloned_profile); - cloned_profile = switch_caller_profile_clone(session, switch_channel_get_caller_profile(other_channel)); + a_cp->callee_id_name = switch_core_strdup(a_cp->pool, b_cp->caller_id_name); + a_cp->callee_id_number = switch_core_strdup(a_cp->pool, b_cp->caller_id_number); + + + cloned_profile = switch_caller_profile_clone(session, b_cp); switch_assert(cloned_profile); switch_assert(cloned_profile->next == NULL); switch_channel_set_originatee_caller_profile(channel, cloned_profile); + b_cp->callee_id_name = switch_core_strdup(b_cp->pool, a_cp->caller_id_name); + b_cp->callee_id_number = switch_core_strdup(b_cp->pool, a_cp->caller_id_number); + + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); epoch_start = (long)switch_epoch_time_now(NULL); diff --git a/src/switch_channel.c b/src/switch_channel.c index f673c8659f..95b7fe0756 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2497,8 +2497,18 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw switch_mutex_unlock(channel->profile_mutex); } +SWITCH_DECLARE(void) switch_channel_step_caller_profile(switch_channel_t *channel) +{ + switch_caller_profile_t *cp; + switch_mutex_lock(channel->profile_mutex); + cp = switch_caller_profile_clone(channel->session, channel->caller_profile); + switch_mutex_unlock(channel->profile_mutex); + + switch_channel_set_caller_profile(channel, cp); +} + SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) { char *uuid = NULL; @@ -2561,7 +2571,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit return profile; } -SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) +SWITCH_DECLARE(void) _switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) { switch_assert(channel != NULL); switch_assert(channel->caller_profile != NULL); @@ -2625,7 +2635,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_origination_caller_ } -SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) +SWITCH_DECLARE(void) _switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) { switch_assert(channel != NULL); switch_assert(channel->caller_profile != NULL); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 96d664e5fd..695105b8da 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1648,9 +1648,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu switch_channel_set_variable(originator_channel, "original_caller_id_name", originator_cp->caller_id_name); switch_channel_set_variable(originator_channel, "original_caller_id_number", originator_cp->caller_id_number); + switch_channel_step_caller_profile(originatee_channel); + switch_channel_step_caller_profile(originator_channel); + + originator_cp = switch_channel_get_caller_profile(originator_channel); + originatee_cp = switch_channel_get_caller_profile(originatee_channel); switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp)); switch_channel_set_originatee_caller_profile(originator_channel, switch_caller_profile_clone(originator_session, originatee_cp)); + + originator_cp->callee_id_name = switch_core_strdup(originator_cp->pool, originatee_cp->caller_id_name); + originator_cp->callee_id_number = switch_core_strdup(originator_cp->pool, originatee_cp->caller_id_number); + + originatee_cp->callee_id_name = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_name); + originatee_cp->callee_id_number = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_number); + switch_channel_stop_broadcast(originator_channel); switch_channel_stop_broadcast(originatee_channel);