From 687ae1b3524ec571b4e2c6a5622c391d8b6e8c80 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 12 Apr 2008 16:17:09 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8098 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_ivr.h | 5 +++- .../applications/mod_dptools/mod_dptools.c | 22 ++++++++------ src/switch_ivr_async.c | 30 ++++++++++++++++++- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index fb48133783..1c5ac2bda8 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -211,7 +211,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c \return SWITCH_STATUS_SUCCESS if all is well */ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh); -SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags); +SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, + const char *uuid, + const char *require_group, + switch_eavesdrop_flag_t flags); SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags); SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index adcf4f6940..6f6b6b262d 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -146,18 +146,20 @@ SWITCH_STANDARD_APP(eavesdrop_function) if (switch_strlen_zero(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", eavesdrop_SYNTAX); } else { + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *require_group = switch_channel_get_variable(channel, "eavesdrop_require_group"); if (!strcasecmp((char *)data, "all")) { switch_core_db_t *db = switch_core_db_handle(); char *errmsg = NULL; struct e_data e_data = {{ 0 }}; char *sql = switch_mprintf("select uuid from channels where uuid != '%q'", switch_core_session_get_uuid(session)); - switch_channel_t *channel = switch_core_session_get_channel(session); const char *file = NULL; int x = 0; char buf[2] = ""; switch_size_t buflen = sizeof(buf); char terminator; - + switch_status_t status; + while(switch_channel_ready(channel)) { for(x = 0; x < MAX_SPY; x++) { switch_safe_free(e_data.uuid_list[x]); @@ -179,12 +181,14 @@ SWITCH_STANDARD_APP(eavesdrop_function) if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_new"))) { switch_ivr_play_file(session, NULL, file, NULL); } - if (switch_ivr_eavesdrop_session(session, e_data.uuid_list[x], ED_DTMF) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Spy: %s Failed\n", e_data.uuid_list[x]); - if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed"))) { - switch_ivr_play_file(session, NULL, file, NULL); + if ((status = switch_ivr_eavesdrop_session(session, e_data.uuid_list[x], require_group, ED_DTMF)) != SWITCH_STATUS_SUCCESS) { + if (status != SWITCH_STATUS_BREAK) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Spy: %s Failed\n", e_data.uuid_list[x]); + if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed"))) { + switch_ivr_play_file(session, NULL, file, NULL); + } + switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0); } - switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0); } } } else { @@ -202,7 +206,7 @@ SWITCH_STANDARD_APP(eavesdrop_function) switch_core_db_close(db); } else { - switch_ivr_eavesdrop_session(session, data, ED_DTMF); + switch_ivr_eavesdrop_session(session, data, require_group, ED_DTMF); } } } @@ -214,7 +218,7 @@ SWITCH_STANDARD_APP(three_way_function) if (switch_strlen_zero(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", threeway_SYNTAX); } else { - switch_ivr_eavesdrop_session(session, data, ED_MUX_READ | ED_MUX_WRITE); + switch_ivr_eavesdrop_session(session, data, NULL, ED_MUX_READ | ED_MUX_WRITE); } } diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 8524fb98ad..f47230032c 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -489,7 +489,10 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data return SWITCH_TRUE; } -SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags) +SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, + const char *uuid, + const char *require_group, + switch_eavesdrop_flag_t flags) { switch_core_session_t *tsession; switch_status_t status = SWITCH_STATUS_FALSE; @@ -505,11 +508,36 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE/2]; switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession); uint32_t tlen; + const char *macro_name = "eavesdrop_announce"; + const char *id_name = NULL; if (!switch_channel_media_ready(channel)) { goto end; } + if (!switch_channel_media_ready(tchannel)) { + goto end; + } + + if ((id_name = switch_channel_get_variable(tchannel, "eavesdrop_announce_id"))) { + const char *tmp = switch_channel_get_variable(tchannel, "eavesdrop_annnounce_macro"); + if (tmp) { + macro_name = tmp; + } + + switch_ivr_phrase_macro(session, macro_name, id_name, NULL, NULL); + } + + + if (!switch_strlen_zero(require_group)) { + const char *group_name = switch_channel_get_variable(tchannel, "eavesdrop_group"); + if (!group_name || strcmp(group_name, require_group)) { + status = SWITCH_STATUS_BREAK; + goto end; + } + } + + ep = switch_core_session_alloc(session, sizeof(*ep)); tlen = tread_codec->implementation->bytes_per_frame;