From 9c88a5ea45c780dc75a15d746b2a63983a219b76 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Mar 2008 22:19:17 +0000 Subject: [PATCH] death star will be in firing range in 10 minutes git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7866 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_ivr.h | 3 ++- .../applications/mod_dptools/mod_dptools.c | 27 ++++++++++++++----- src/switch_ivr_async.c | 15 ++++++++--- src/switch_ivr_bridge.c | 2 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 4544c51e60..3e19a09c46 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -747,7 +747,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, uint32_t timeout, const char *valid_terminators); -SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, const char *app); +SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, + switch_bool_t dial_b, switch_bool_t exec_b, const char *app); SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 9e9337200d..da1fe6fc38 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -79,19 +79,20 @@ SWITCH_STANDARD_APP(exe_function) } } -#define BIND_SYNTAX " " +#define BIND_SYNTAX " [a|b] [a|b] " SWITCH_STANDARD_APP(dtmf_bind_function) { - char *argv[2] = { 0 }; + char *argv[4] = { 0 }; int argc; char *lbuf = NULL; if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) - && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 2) { + && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) { int kval = atoi(argv[0]); - if (switch_ivr_bind_dtmf_meta_session(session, kval, argv[1]) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound: %s %s\n", argv[0], argv[1]); - } else { + char a1 = tolower(*argv[1]); + char a2 = tolower(*argv[2]); + + if (switch_ivr_bind_dtmf_meta_session(session, kval, a1 == 'b', a2 == 'b', argv[3]) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bind Error!\n"); } } else { @@ -207,7 +208,19 @@ SWITCH_STANDARD_APP(transfer_function) if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { - switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); + if (!strcasecmp(argv[0], "-bleg")) { + const char *uuid; + switch_channel_t *channel = switch_core_session_get_channel(session); + if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + switch_core_session_t *b_session; + if ((b_session = switch_core_session_locate(uuid))) { + switch_ivr_session_transfer(b_session, argv[1], argv[2], argv[3]); + switch_core_session_rwunlock(b_session); + } + } + } else { + switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); + } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No extension specified.\n"); } diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index ed3cb19385..77b3519e54 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1260,6 +1260,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi typedef struct { const char *app; + uint32_t flags; } dtmf_meta_app_t; typedef struct { @@ -1307,7 +1308,7 @@ static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch if (md->map[dval].app) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n", switch_channel_get_name(channel), dtmf->digit, md->map[dval].app); - switch_ivr_broadcast(switch_core_session_get_uuid(session), md->map[dval].app, SMF_ECHO_ALEG); + switch_ivr_broadcast(switch_core_session_get_uuid(session), md->map[dval].app, md->map[dval].flags); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n", switch_channel_get_name(channel), dtmf->digit); @@ -1329,7 +1330,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_ return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, const char *app) +SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, + switch_bool_t dial_b, switch_bool_t exec_b, const char *app) { switch_channel_t *channel = switch_core_session_get_channel(session); dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY); @@ -1342,12 +1344,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se if (!md) { md = switch_core_session_alloc(session, sizeof(*md)); switch_channel_set_private(channel, SWITCH_META_VAR_KEY, md); - switch_core_event_hook_add_recv_dtmf(session, meta_on_dtmf); + if (dial_b) { + switch_core_event_hook_add_send_dtmf(session, meta_on_dtmf); + } else { + switch_core_event_hook_add_recv_dtmf(session, meta_on_dtmf); + } } if (!switch_strlen_zero(app)) { md->map[key].app = switch_core_session_strdup(session, app); + md->map[key].flags = exec_b ? SMF_ECHO_BLEG : SMF_ECHO_ALEG; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound: %d %s\n", key, app); } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "UnBound: %d\n", key); md->map[key].app = NULL; } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index b6eed0255a..f52e164d09 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -137,7 +137,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) break; } - if (switch_channel_test_flag(chan_a, CF_TRANSFER)) { + if (switch_channel_test_flag(chan_a, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_TRANSFER)) { switch_channel_clear_flag(chan_a, CF_HOLD); switch_channel_clear_flag(chan_a, CF_SUSPEND); break;