Index: res/res_agi.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v retrieving revision 1.13 diff -u -r1.13 res_agi.c --- res/res_agi.c 17 Oct 2004 05:16:22 -0000 1.13 +++ res/res_agi.c 2 Nov 2004 18:11:10 -0000 @@ -420,23 +420,42 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) { int res; + int timeout = 0; + char *timeoutstr = NULL; struct ast_filestream *fs; long sample_offset = 0; long max_length; - if (argc < 4) return RESULT_SHOWUSAGE; - if (argc > 5) + if (argc > 6) return RESULT_SHOWUSAGE; - if ((argc > 4) && (sscanf(argv[4], "%ld", &sample_offset) != 1)) + if (argc > 4) { + timeoutstr = strchr(argv[4],'t'); + } + if ((argc > 6) && (sscanf(argv[6], "%ld", &sample_offset) != 1)) { return RESULT_SHOWUSAGE; - + } + if (timeoutstr) { + if (strlen(timeoutstr) > 2) { + if ((timeoutstr[0] == 't') && (timeoutstr[1] == '=')) { + timeoutstr+=2; + if (timeoutstr) { + timeout = atoi(timeoutstr); + } + } + } + } + + fs = ast_openstream(chan, argv[2], chan->language); if(!fs){ fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset); ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]); return RESULT_FAILURE; } + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (timeout %d)\n", argv[2], timeout); + ast_seekstream(fs, 0, SEEK_END); max_length = ast_tellstream(fs); ast_seekstream(fs, sample_offset, SEEK_SET); @@ -458,6 +477,16 @@ /* Stop this command, don't print a result line, as there is a new command */ return RESULT_SUCCESS; } + /*Patch for the WAIT FOR DIGIT */ + if (res == 0 ) { + res = ast_waitfordigit_full(chan, timeout, agi->audio, agi->ctrl); + /* Make sure the result is in the escape digits */ + if ( !strchr(argv[3],res) ) { + ast_log(LOG_WARNING,"if\n"); + res=0; + } + } + /* End Patch WAIT FOR DIGIT */ fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset); if (res >= 0) return RESULT_SUCCESS; @@ -1170,14 +1199,16 @@ " should not include extensions.\n"; static char usage_streamfile[] = -" Usage: STREAM FILE [sample offset]\n" +" Usage: STREAM FILE [t=timeout] [sample offset]\n" " Send the given file, allowing playback to be interrupted by the given\n" " digits, if any. Use double quotes for the digits if you wish none to be\n" " permitted. If sample offset is provided then the audio will seek to sample\n" " offset before play starts. Returns 0 if playback completes without a digit\n" " being pressed, or the ASCII numerical value of the digit if one was pressed,\n" " or -1 on error or if the channel was disconnected. Remember, the file\n" -" extension must not be included in the filename.\n"; +" extension must not be included in the filename.\n" +" The timeout is in msec and it's by default at 0. This add the possibility to wait\n" +" msec after the stream for the user can press any DTMFs entered in the escape digits\n"; static char usage_saynumber[] = " Usage: SAY NUMBER \n"