<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.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11201 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-01-14 20:29:16 +00:00
parent cbc680adc0
commit c0a531f597
3 changed files with 68 additions and 8 deletions

View 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,

View 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,

View 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);