Skip to content

Commit

Permalink
pbx_builtins: Allow Answer to return immediately.
Browse files Browse the repository at this point in the history
The Answer application currently waits for up to 500ms
for media, even if users specify a different timeout.

This adds an option to not wait for media on the channel
by doing a raw answer instead. The default 500ms threshold
is also documented.

ASTERISK-30308 #close

Change-Id: Id59cd340c44b8b8b2384c479e17e5123e917cba4
  • Loading branch information
InterLinked1 authored and Friendly Automation committed Nov 29, 2022
1 parent 67186aa commit b1d21f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/CHANGES-staging/answer.txt
@@ -0,0 +1,5 @@
Subject: pbx_builtins

It is now possible to not wait for media on
a channel when answering it using Answer,
by specifying the i option.
17 changes: 17 additions & 0 deletions main/pbx_builtins.c
Expand Up @@ -49,11 +49,23 @@
<parameter name="delay">
<para>Asterisk will wait this number of milliseconds before returning to
the dialplan after answering the call.</para>
<para>The minimum is 500 ms. To answer immediately without waiting for media,
use the i option.</para>
</parameter>
<parameter name="options">
<optionlist>
<option name="i">
<para>Answer the channel immediately without waiting for media.</para>
</option>
</optionlist>
</parameter>
</syntax>
<description>
<para>If the call has not been answered, this application will
answer it. Otherwise, it has no effect on the call.</para>
<para>By default, Asterisk will wait for media for up to 500 ms, or
the user specified delay, whichever is longer. If you do not want
to wait for media at all, use the i option.</para>
</description>
<see-also>
<ref type="application">Hangup</ref>
Expand Down Expand Up @@ -836,6 +848,11 @@ static int pbx_builtin_answer(struct ast_channel *chan, const char *data)
delay = 0;
}

if (!ast_strlen_zero(args.answer_cdr) && !strcmp(args.answer_cdr, "i")) {
/*! \todo We will remove the nocdr stuff for 21 entirely, as part of another review. */
return ast_raw_answer(chan);
}

if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
ast_log(AST_LOG_WARNING, "The nocdr option for the Answer application has been removed and is no longer supported.\n");
}
Expand Down

0 comments on commit b1d21f7

Please sign in to comment.