[Freeswitch-svn] [commit] r8343 - in freeswitch/trunk/src: . include mod/applications/mod_dptools

Freeswitch SVN anthm at freeswitch.org
Fri May 9 18:16:08 EDT 2008


Author: anthm
Date: Fri May  9 18:16:08 2008
New Revision: 8343

Modified:
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_play_say.c

Log:
doh should probably expose say

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Fri May  9 18:16:08 2008
@@ -756,7 +756,10 @@
 																  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);
 
 /** @} */
 

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Fri May  9 18:16:08 2008
@@ -128,6 +128,23 @@
 	}
 }
 
+
+#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_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);
 

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Fri May  9 18:16:08 2008
@@ -1668,6 +1668,21 @@
 	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:

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Fri May  9 18:16:08 2008
@@ -65,7 +65,7 @@
 	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 @@
 	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 @@
 							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);
 						}



More information about the Freeswitch-svn mailing list