[asterisk-commits] jrose: trunk r402819 - in /trunk: CHANGES apps/app_sayunixtime.c main/pbx.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Nov 14 14:32:48 CST 2013
Author: jrose
Date: Thu Nov 14 14:32:45 2013
New Revision: 402819
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402819
Log:
Say: If SAY_DTMF_INTERRUPT is set to an ast_true value, jump on DTMF
Similar to how background works, if a say application is called with
this variable set to 'true', 'yes', 'on', etc. then using DTMF while
the say action is in progress will result in the channel jumping to
that extension in the dialplan.
Review: https://reviewboard.asterisk.org/r/3011/
Modified:
trunk/CHANGES
trunk/apps/app_sayunixtime.c
trunk/main/pbx.c
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=402819&r1=402818&r2=402819
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Nov 14 14:32:45 2013
@@ -20,6 +20,15 @@
* CONFBRIDGE dialplan function is now capable of removing dynamic conference
menus, bridge settings, and user settings that have been applied by the
CONFBRIDGE dialplan function.
+
+Say
+--------------------------
+ * If a channel variable SAY_DTMF_INTERRUPT is present on a channel and set
+ to 'true' (case insensitive), then any Say application (SayNumber,
+ SayDigits, SayAlpha, SayAlphaCase, SayUnixTime, and SayCounted) will
+ anticipate DTMF. If DTMF is received, these applications will behave like
+ the background application and jump to the received extension once a match
+ is established or after a short period of inactivity.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 11 to Asterisk 12 --------------------
Modified: trunk/apps/app_sayunixtime.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_sayunixtime.c?view=diff&rev=402819&r1=402818&r2=402819
==============================================================================
--- trunk/apps/app_sayunixtime.c (original)
+++ trunk/apps/app_sayunixtime.c Thu Nov 14 14:32:45 2013
@@ -59,7 +59,10 @@
<parameter name="options" required="false">
<optionlist>
<option name="j">
- <para>Allow the calling user to dial digits to jump to that extension.</para>
+ <para>Allow the calling user to dial digits to jump to that extension.
+ This option is automatically enabled if
+ <variable>SAY_DTMF_INTERRUPT</variable> is present on the channel and
+ set to 'true' (case insensitive)</para>
</option>
</optionlist>
</parameter>
@@ -129,6 +132,7 @@
const char * haltondigits = AST_DIGIT_NONE;
struct ast_flags64 opts = { 0, };
char *opt_args[OPT_ARG_ARRAY_SIZE];
+ const char *interrupt_string;
if (!data) {
return 0;
@@ -145,6 +149,14 @@
haltondigits = AST_DIGIT_ANY;
}
}
+
+ /* Check if 'SAY_DTMF_INTERRUPT' is true and apply the same behavior as the j flag. */
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ haltondigits = AST_DIGIT_ANY;
+ }
+ ast_channel_unlock(chan);
ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=402819&r1=402818&r2=402819
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Thu Nov 14 14:32:45 2013
@@ -491,8 +491,11 @@
<parameter name="string" required="true" />
</syntax>
<description>
- <para>This application will play the sounds that correspond to the letters of the
- given <replaceable>string</replaceable>.</para>
+ <para>This application will play the sounds that correspond to the letters
+ of the given <replaceable>string</replaceable>. If the channel variable
+ <variable>SAY_DTMF_INTERRUPT</variable> is set to 'true' (case insensitive),
+ then this application will react to DTMF in the same way as
+ <literal>Background</literal>.</para>
</description>
<see-also>
<ref type="application">SayDigits</ref>
@@ -531,7 +534,9 @@
<description>
<para>This application will play the sounds that correspond to the letters of the
given <replaceable>string</replaceable>. Optionally, a <replaceable>casetype</replaceable> may be
- specified. This will be used for case-insensitive or case-sensitive pronunciations.</para>
+ specified. This will be used for case-insensitive or case-sensitive pronunciations. If the channel
+ variable <variable>SAY_DTMF_INTERRUPT</variable> is set to 'true' (case insensitive), then this
+ application will react to DTMF in the same way as <literal>Background</literal>.</para>
</description>
<see-also>
<ref type="application">SayDigits</ref>
@@ -550,7 +555,10 @@
</syntax>
<description>
<para>This application will play the sounds that correspond to the digits of
- the given number. This will use the language that is currently set for the channel.</para>
+ the given number. This will use the language that is currently set for the channel.
+ If the channel variable <variable>SAY_DTMF_INTERRUPT</variable> is set to 'true'
+ (case insensitive), then this application will react to DTMF in the same way as
+ <literal>Background</literal>.</para>
</description>
<see-also>
<ref type="application">SayAlpha</ref>
@@ -568,9 +576,12 @@
<parameter name="gender" />
</syntax>
<description>
- <para>This application will play the sounds that correspond to the given <replaceable>digits</replaceable>.
- Optionally, a <replaceable>gender</replaceable> may be specified. This will use the language that is currently
- set for the channel. See the CHANNEL() function for more information on setting the language for the channel.</para>
+ <para>This application will play the sounds that correspond to the given
+ <replaceable>digits</replaceable>. Optionally, a <replaceable>gender</replaceable> may be
+ specified. This will use the language that is currently set for the channel. See the CHANNEL()
+ function for more information on setting the language for the channel. If the channel variable
+ <variable>SAY_DTMF_INTERRUPT</variable> is set to 'true' (case insensitive), then this
+ application will react to DTMF in the same way as <literal>Background</literal>.</para>
</description>
<see-also>
<ref type="application">SayAlpha</ref>
@@ -588,7 +599,9 @@
</syntax>
<description>
<para>This application will play the sounds from the phonetic alphabet that correspond to the
- letters in the given <replaceable>string</replaceable>.</para>
+ letters in the given <replaceable>string</replaceable>. If the channel variable
+ <variable>SAY_DTMF_INTERRUPT</variable> is set to 'true' (case insensitive), then this
+ application will react to DTMF in the same way as <literal>Background</literal>.</para>
</description>
<see-also>
<ref type="application">SayAlpha</ref>
@@ -11288,7 +11301,18 @@
{
char tmp[256];
char *number = tmp;
+ int number_val;
char *options;
+ int res;
+ int interrupt = 0;
+ const char *interrupt_string;
+
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ interrupt = 1;
+ }
+ ast_channel_unlock(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
@@ -11296,6 +11320,12 @@
}
ast_copy_string(tmp, data, sizeof(tmp));
strsep(&number, ",");
+
+ if (sscanf(tmp, "%d", &number_val) != 1) {
+ ast_log(LOG_WARNING, "argument '%s' to SayNumber could not be parsed as a number.\n", tmp);
+ return 0;
+ }
+
options = strsep(&number, ",");
if (options) {
if ( strcasecmp(options, "f") && strcasecmp(options, "m") &&
@@ -11305,19 +11335,32 @@
}
}
- if (ast_say_number(chan, atoi(tmp), "", ast_channel_language(chan), options)) {
+ res = ast_say_number(chan, number_val, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), options);
+
+ if (res < 0) {
ast_log(LOG_WARNING, "We were unable to say the number %s, is it too large?\n", tmp);
}
- return 0;
+ return interrupt ? res : 0;
}
static int pbx_builtin_saydigits(struct ast_channel *chan, const char *data)
{
int res = 0;
-
- if (data)
- res = ast_say_digit_str(chan, data, "", ast_channel_language(chan));
+ int interrupt = 0;
+ const char *interrupt_string;
+
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ interrupt = 1;
+ }
+ ast_channel_unlock(chan);
+
+ if (data) {
+ res = ast_say_digit_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));
+ }
+
return res;
}
@@ -11326,10 +11369,20 @@
int res = 0;
int sensitivity = 0;
char *parse;
+ int interrupt = 0;
+ const char *interrupt_string;
+
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(options);
AST_APP_ARG(characters);
);
+
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ interrupt = 1;
+ }
+ ast_channel_unlock(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SayAlphaCase requires two arguments (options, characters)\n");
@@ -11362,7 +11415,7 @@
return 0;
}
- res = ast_say_character_str(chan, args.characters, "", ast_channel_language(chan), sensitivity);
+ res = ast_say_character_str(chan, args.characters, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), sensitivity);
return res;
}
@@ -11370,9 +11423,18 @@
static int pbx_builtin_saycharacters(struct ast_channel *chan, const char *data)
{
int res = 0;
+ int interrupt = 0;
+ const char *interrupt_string;
+
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ interrupt = 1;
+ }
+ ast_channel_unlock(chan);
if (data) {
- res = ast_say_character_str(chan, data, "", ast_channel_language(chan), AST_SAY_CASE_NONE);
+ res = ast_say_character_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), AST_SAY_CASE_NONE);
}
return res;
@@ -11381,9 +11443,18 @@
static int pbx_builtin_sayphonetic(struct ast_channel *chan, const char *data)
{
int res = 0;
+ int interrupt = 0;
+ const char *interrupt_string;
+
+ ast_channel_lock(chan);
+ interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
+ if (ast_true(interrupt_string)) {
+ interrupt = 1;
+ }
+ ast_channel_unlock(chan);
if (data)
- res = ast_say_phonetic_str(chan, data, "", ast_channel_language(chan));
+ res = ast_say_phonetic_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));
return res;
}
More information about the asterisk-commits
mailing list