aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_speech_utils.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-30 00:04:17 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-30 00:04:17 +0000
commite2f5175dcdd9a46d7220506bb5e047f38e55d9c6 (patch)
tree227c4ba453b84f642108803f955b6ab2c60ae50e /apps/app_speech_utils.c
parent57ff6ade4ab333f8987c1861835e8b45385a642a (diff)
Add the 'n' option to SpeechBackground, which has the application not answer the
channel if it has not already been answered. (closes SPD-51) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@101082 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_speech_utils.c')
-rw-r--r--apps/app_speech_utils.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 327e7922f..2445955f4 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -56,15 +56,17 @@ static char *speechstart_descrip =
"fed to it. This has no arguments.\n";
static char *speechbackground_descrip =
-" SpeechBackground(Sound File,Timeout):\n"
+" SpeechBackground(<Sound File>[,Timeout[,options]]):\n"
"This application plays a sound file and waits for the person to speak. Once they start speaking playback\n"
"of the file stops, and silence is heard. Once they stop talking the processing sound is played to indicate\n"
"the speech recognition engine is working. Once results are available the application returns and results \n"
"(score and text) are available using dialplan functions.\n"
-"The first text and score are ${SPEECH_TEXT(0)} AND ${SPEECH_SCORE(0)} while the second are ${SPEECH_TEXT(1)}\n"
+" The first text and score are ${SPEECH_TEXT(0)} AND ${SPEECH_SCORE(0)} while the second are ${SPEECH_TEXT(1)}\n"
"and ${SPEECH_SCORE(1)}.\n"
-"The first argument is the sound file and the second is the timeout integer in seconds. Note the timeout will\n"
-"only start once the sound file has stopped playing.\n";
+" The first argument is the sound file and the second is the timeout integer in seconds. Note the timeout will\n"
+"only start once the sound file has stopped playing. The third argument specifies options:\n"
+" Valid Options:\n"
+" n - Don't answer the channel if it has not already been answered.\n";
static char *speechdeactivategrammar_descrip =
" SpeechDeactivateGrammar(Grammar Name):\n"
@@ -487,6 +489,14 @@ static int speech_streamfile(struct ast_channel *chan, const char *filename, con
return 0;
}
+enum {
+ SB_OPT_NOANSWER = (1 << 0),
+};
+
+AST_APP_OPTIONS(speech_background_options, BEGIN_OPTIONS
+ AST_APP_OPTION('n', SB_OPT_NOANSWER),
+END_OPTIONS );
+
/*! \brief SpeechBackground(Sound File,Timeout) Dialplan Application */
static int speech_background(struct ast_channel *chan, void *data)
{
@@ -500,9 +510,11 @@ static int speech_background(struct ast_channel *chan, void *data)
struct ast_datastore *datastore = NULL;
char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
const char *tmp2 = NULL;
+ struct ast_flags options = { 0 };
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(soundfile);
AST_APP_ARG(timeout);
+ AST_APP_ARG(options);
);
parse = ast_strdupa(data);
@@ -511,9 +523,16 @@ static int speech_background(struct ast_channel *chan, void *data)
if (speech == NULL)
return -1;
+ if (!ast_strlen_zero(args.options)) {
+ char *options_buf = ast_strdupa(args.options);
+ ast_app_parse_options(speech_background_options, &options, NULL, options_buf);
+ }
+
/* If channel is not already answered, then answer it */
- if (chan->_state != AST_STATE_UP && ast_answer(chan))
- return -1;
+ if (chan->_state != AST_STATE_UP && !ast_test_flag(&options, SB_OPT_NOANSWER)
+ && ast_answer(chan)) {
+ return -1;
+ }
/* Record old read format */
oldreadformat = chan->readformat;