From 628e1b4c4c99d35802a0fcaccfd41e82e9280236 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 9 May 2008 22:16:08 +0000 Subject: [PATCH] doh should probably expose say git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8343 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_ivr.h | 3 +++ src/mod/applications/mod_dptools/mod_dptools.c | 18 ++++++++++++++++++ src/switch_ivr.c | 15 +++++++++++++++ src/switch_ivr_play_say.c | 6 +++--- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index cdaefd832f..4e7ac3069e 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -756,7 +756,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se 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); SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b); +SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, switch_input_args_t *args); +SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name); +SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name); /** @} */ diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index ca744cf7d8..a1986e1f4f 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -128,6 +128,23 @@ SWITCH_STANDARD_APP(exe_function) } } + +#define SAY_SYNTAX " " +SWITCH_STANDARD_APP(say_function) +{ + 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])))) == 4) { + switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], NULL); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX); + } + +} + #define SOFT_HOLD_SYNTAX " [] []" SWITCH_STANDARD_APP(soft_hold_function) { @@ -2012,6 +2029,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "clear_speech_cache", "Clear Speech Handle Cache", "Clear Speech Handle Cache", clear_speech_cache_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE); SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 580e35ebe2..0f0315abef 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1668,6 +1668,21 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3 stfu_n_destroy(&jb); } +SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, switch_input_args_t *args) +{ + switch_say_interface_t *si; + switch_status_t status = SWITCH_STATUS_SUCCESS; + + if ((si = switch_loadable_module_get_say_interface(module_name))) { + // should go back and proto all the say mods to const.... + status = si->say_function(session, (char *)tosay, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name); + status = SWITCH_STATUS_FALSE; + } + + return status; +} /* For Emacs: * Local Variables: diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index b0ec8c7e1b..5015a66586 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -65,7 +65,7 @@ static char *SAY_TYPE_NAMES[] = { NULL }; -static switch_say_method_t get_say_method_by_name(char *name) +SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name) { int x = 0; for (x = 0; SAY_METHOD_NAMES[x]; x++) { @@ -77,7 +77,7 @@ static switch_say_method_t get_say_method_by_name(char *name) return (switch_say_method_t) x; } -static switch_say_type_t get_say_type_by_name(char *name) +SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name) { int x = 0; for (x = 0; SAY_TYPE_NAMES[x]; x++) { @@ -286,7 +286,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s char *say_type = (char *) switch_xml_attr_soft(action, "type"); char *say_method = (char *) switch_xml_attr_soft(action, "method"); - status = si->say_function(session, odata, get_say_type_by_name(say_type), get_say_method_by_name(say_method), args); + status = si->say_function(session, odata, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name); }