pbx_builtins: Allow custom tone for WaitExten.

Currently, the 'd' option will play dial tone while waiting
for digits. Allow it to accept an argument for any tone from
indications.conf.

Resolves: #1396

UserNote: The tone used while waiting for digits in WaitExten
can now be overridden by specifying an argument for the 'd'
option.

(cherry picked from commit d063257ab7)
This commit is contained in:
Naveen Albert
2025-08-25 13:58:31 -04:00
committed by Asterisk Development Team
parent 9c2e869be3
commit 411001353e

View File

@@ -798,8 +798,11 @@
</argument>
</option>
<option name="d">
<para>Play <literal>dial</literal> indications tone on channel while waiting
for digits.</para>
<para>Play indications tone on channel while waiting for digits.</para>
<argument name="x">
<para>Specify the indications tone to play.
Default is <literal>dial</literal> tone.</para>
</argument>
</option>
</optionlist>
</parameter>
@@ -828,12 +831,21 @@ AST_APP_OPTIONS(background_opts, {
AST_APP_OPTION('p', BACKGROUND_PLAYBACK),
});
#define WAITEXTEN_MOH (1 << 0)
#define WAITEXTEN_DIALTONE (1 << 1)
enum {
WAITEXTEN_MOH = (1 << 0),
WAITEXTEN_DIALTONE = (1 << 1),
};
enum read_option_flags {
WAITEXTEN_ARG_MOH,
WAITEXTEN_ARG_DIALTONE,
/* note: this entry _MUST_ be the last one in the enum */
WAITEXTEN_ARRAY_SIZE,
};
AST_APP_OPTIONS(waitexten_opts, {
AST_APP_OPTION_ARG('m', WAITEXTEN_MOH, 0),
AST_APP_OPTION_ARG('d', WAITEXTEN_DIALTONE, 0),
AST_APP_OPTION_ARG('m', WAITEXTEN_MOH, WAITEXTEN_ARG_MOH),
AST_APP_OPTION_ARG('d', WAITEXTEN_DIALTONE, WAITEXTEN_ARG_DIALTONE),
});
int pbx_builtin_raise_exception(struct ast_channel *chan, const char *reason)
@@ -1203,7 +1215,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
{
int ms, res;
struct ast_flags flags = {0};
char *opts[1] = { NULL };
char *opt_args[WAITEXTEN_ARRAY_SIZE];
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(timeout);
@@ -1217,15 +1229,17 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
memset(&args, 0, sizeof(args));
if (args.options)
ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
ast_app_parse_options(waitexten_opts, &flags, opt_args, args.options);
if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
} else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL),
!ast_strlen_zero(opts[0]) ? strlen(opts[0]) + 1 : 0);
if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
if (ast_strlen_zero(opt_args[WAITEXTEN_ARG_MOH])) {
ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
}
ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opt_args[WAITEXTEN_ARG_MOH], NULL),
!ast_strlen_zero(opt_args[WAITEXTEN_ARG_MOH]) ? strlen(opt_args[WAITEXTEN_ARG_MOH]) + 1 : 0);
} else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
const char *tone = !ast_strlen_zero(opt_args[WAITEXTEN_ARG_DIALTONE]) ? opt_args[WAITEXTEN_ARG_DIALTONE] : "dial";
struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), tone);
if (ts) {
ast_playtones_start(chan, 0, ts->data, 0);
ts = ast_tone_zone_sound_unref(ts);