[Asterisk-code-review] pbx_builtins: Allow Answer to return immediately. (asterisk[master])

N A asteriskteam at digium.com
Fri Nov 11 14:33:33 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19561 )


Change subject: pbx_builtins: Allow Answer to return immediately.
......................................................................

pbx_builtins: Allow Answer to return immediately.

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
---
A doc/CHANGES-staging/answer.txt
M main/pbx_builtins.c
2 files changed, 41 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/61/19561/1

diff --git a/doc/CHANGES-staging/answer.txt b/doc/CHANGES-staging/answer.txt
new file mode 100644
index 0000000..c57715b
--- /dev/null
+++ b/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 r option.
diff --git a/main/pbx_builtins.c b/main/pbx_builtins.c
index 7ef4d03..bcf45bf 100644
--- a/main/pbx_builtins.c
+++ b/main/pbx_builtins.c
@@ -49,11 +49,24 @@
 			<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 r option.</para>
+			</parameter>
+			<parameter name="options">
+				<optionlist>
+					<option name="r">
+						<para>Raw answer.</para>
+						<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 r option.</para>
 		</description>
 		<see-also>
 			<ref type="application">Hangup</ref>
@@ -836,6 +849,11 @@
 		delay = 0;
 	}
 
+	if (!ast_strlen_zero(args.answer_cdr) && !strcmp(args.answer_cdr, "r")) {
+		/*! \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");
 	}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19561
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Id59cd340c44b8b8b2384c479e17e5123e917cba4
Gerrit-Change-Number: 19561
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221111/51e856fb/attachment.html>


More information about the asterisk-code-review mailing list