]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
doh should probably expose say
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 9 May 2008 22:16:08 +0000 (22:16 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 9 May 2008 22:16:08 +0000 (22:16 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8343 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_ivr.h
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_ivr.c
src/switch_ivr_play_say.c

index cdaefd832f83baf14a8d54c6f922efd484b3f65b..4e7ac3069e10de7dd9500213b1f71ea36b427d05 100644 (file)
@@ -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);
 
 /** @} */
 
index ca744cf7d81e9134cb0da7df2f23395756175110..a1986e1f4f215e21fd97ece0f922c73c3efb9454 100644 (file)
@@ -128,6 +128,23 @@ SWITCH_STANDARD_APP(exe_function)
        }
 }
 
+
+#define SAY_SYNTAX "<module_name> <say_type> <say_method> <text>"
+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 "<unhold key> [<moh_a>] [<moh_b>]"
 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, "<channel_url>", SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>", 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);
 
index 580e35ebe297ade922cf94c7a8a8ac7b6375de43..0f0315abefb31c1500c45f5907fbdc75c0a4e020 100644 (file)
@@ -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:
index b0ec8c7e1bf0e1937c2f954367b4fa4134c62332..5015a66586fe4c1dd36343743747b1a4d874770e 100644 (file)
@@ -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);
                                                }