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

FreeSWITCH SVN brian at freeswitch.org
Wed Jan 14 12:29:17 PST 2009


Author: brian
Date: Wed Jan 14 14:29:16 2009
New Revision: 11201

Log:
<action application="play_and_get_digits" data="1 3 3 3000 # ivr/ivr-please.wav ivr/ivr-not.wav \d{2}"/> 

You can use play and get digits in the dialplan as an application now.



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

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Wed Jan 14 14:29:16 2009
@@ -354,10 +354,10 @@
 														   uint32_t max_digits,
 														   uint32_t max_tries,
 														   uint32_t timeout,
-														   char *valid_terminators,
-														   char *audio_file,
-														   char *bad_input_audio_file, char *digit_buffer, uint32_t digit_buffer_length,
-														   char *digits_regex);
+														   const char *valid_terminators,
+														   const char *audio_file,
+														   const char *bad_input_audio_file, char *digit_buffer, uint32_t digit_buffer_length,
+														   const char *digits_regex);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session_t *session,
 															 switch_speech_handle_t *sh,

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	Wed Jan 14 14:29:16 2009
@@ -1613,7 +1613,65 @@
 	switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators);
 }
 
+SWITCH_STANDARD_APP(play_and_get_digits_function)
+{
+	char *mydata;
+	char *argv[8] = { 0 };
+	int argc;
+	int32_t min_digits = 0;
+	int32_t max_digits = 0;
+	int32_t max_tries = 0;
+	int timeout = 1000;
+	char digit_buffer[128] = "";
+	const char *prompt_audio_file = NULL;
+	const char *bad_input_audio_file = NULL;
+	const char *valid_terminators = NULL;
+	const char *digits_regex = NULL;
+
+	if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
+		argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No arguments specified.\n");
+		return;
+	}
+
+	min_digits = atoi(argv[0]);
+
+	if (argc > 1) {
+		max_digits = atoi(argv[1]);
+	}
+
+	if (argc > 2) {
+		max_tries = atoi(argv[2]);
+	}
 
+	if (argc > 3) {
+		timeout = atoi(argv[3]);
+	}
+
+	if (argc > 4) {
+		valid_terminators = argv[4];
+	}
+
+	if (argc > 5) {
+		prompt_audio_file = argv[5];
+	}
+
+	if (argc > 6) {
+		bad_input_audio_file = argv[6];
+	}
+
+	if (argc > 7) {
+		digits_regex = argv[7];
+	}
+
+	if (switch_strlen_zero(valid_terminators)) {
+		valid_terminators = "#";
+	}
+
+	switch_play_and_get_digits(session, min_digits, max_digits, max_tries, timeout, valid_terminators,
+							   prompt_audio_file, bad_input_audio_file, digit_buffer, sizeof(digit_buffer), digits_regex);
+}
 
 #define SAY_SYNTAX "<module_name> <say_type> <say_method> <text>"
 SWITCH_STANDARD_APP(say_function)
@@ -2554,6 +2612,8 @@
 	SWITCH_ADD_APP(app_interface, "playback", "Playback File", "Playback a file to the channel", playback_function, "<path>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "<channel_url>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function, "<min> <max> <file> <var name> <timeout> <terminators>", SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits", 
+				   play_and_get_digits_function, "<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <regexp>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "stop_record_session", "Stop Record Session", STOP_SESS_REC_DESC, stop_record_session_function, "<path>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "record_session", "Record Session", SESS_REC_DESC, record_session_function, "<path> [+<timeout>]", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "record", "Record File", "Record a file from the channels input", record_function,

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	Wed Jan 14 14:29:16 2009
@@ -1500,12 +1500,12 @@
 														   uint32_t max_digits,
 														   uint32_t max_tries,
 														   uint32_t timeout,
-														   char *valid_terminators,
-														   char *prompt_audio_file,
-														   char *bad_input_audio_file, 
+														   const char *valid_terminators,
+														   const char *prompt_audio_file,
+														   const char *bad_input_audio_file, 
 														   char *digit_buffer, 
 														   uint32_t digit_buffer_length,
-														   char *digits_regex)
+														   const char *digits_regex)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 



More information about the Freeswitch-svn mailing list