]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
<action application="play_and_get_digits" data="1 3 3 3000 # ivr/ivr-please.wav ivr...
authorBrian West <brian@freeswitch.org>
Wed, 14 Jan 2009 20:29:16 +0000 (20:29 +0000)
committerBrian West <brian@freeswitch.org>
Wed, 14 Jan 2009 20:29:16 +0000 (20:29 +0000)
You can use play and get digits in the dialplan as an application now.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11201 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 058e5a1b57106bb636ec5579c51af8620c225329..bf517c800411e55bf9e477c98dc2769aca914a63 100644 (file)
@@ -354,10 +354,10 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
                                                                                                                   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,
index a07bf84a399459f389a8ff8bb959fedcd267ed1e..e3e52f01e31acae3e3e1d263b27e0cd2a7b4feb9 100644 (file)
@@ -1613,7 +1613,65 @@ SWITCH_STANDARD_APP(read_function)
        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_MODULE_LOAD_FUNCTION(mod_dptools_load)
        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,
index 11e0972a91a04baf1f5e345e2da8bb4463d9b5de..c77d40c35d9d14e558e34ca94a529d780f891427 100644 (file)
@@ -1500,12 +1500,12 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
                                                                                                                   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);