[Asterisk-code-review] app_senddtmf: Add option to answer target channel. (asterisk[18])

Friendly Automation asteriskteam at digium.com
Mon Feb 27 11:16:42 CST 2023


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19894 )

Change subject: app_senddtmf: Add option to answer target channel.
......................................................................

app_senddtmf: Add option to answer target channel.

Adds a new option to SendDTMF() which will answer the specified
channel if it is not already up. If no channel is specified, the
current channel will be answered instead.

ASTERISK-30422

Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085
---
M apps/app_senddtmf.c
A doc/CHANGES-staging/app_senddtmf_answer.txt
2 files changed, 51 insertions(+), 0 deletions(-)

Approvals:
  N A: Looks good to me, but someone else must approve
  Michael Bradeen: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit




diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index ea75a9e..c119d8c 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -57,6 +57,15 @@
 			<parameter name="channel" required="false">
 				<para>Channel where digits will be played</para>
 			</parameter>
+			<parameter name="options">
+				<optionlist>
+					<option name="a">
+						<para>Answer the channel specified by the <literal>channel</literal>
+						parameter if it is not already up. If no <literal>channel</literal>
+						parameter is provided, the current channel will be answered.</para>
+					</option>
+				</optionlist>
+			</parameter>
 		</syntax>
 		<description>
 			<para>It will send all digits or terminate if it encounters an error.</para>
@@ -90,6 +99,19 @@
 	</manager>
  ***/
 
+enum read_option_flags {
+	OPT_ANSWER = (1 << 0),
+};
+
+AST_APP_OPTIONS(senddtmf_app_options, {
+	AST_APP_OPTION('a', OPT_ANSWER),
+});
+
+enum {
+	/* note: this entry _MUST_ be the last one in the enum */
+	OPT_ARG_ARRAY_SIZE,
+};
+
 static const char senddtmf_name[] = "SendDTMF";
 
 static int senddtmf_exec(struct ast_channel *chan, const char *vdata)
@@ -100,11 +122,14 @@
 	struct ast_channel *chan_found = NULL;
 	struct ast_channel *chan_dest = chan;
 	struct ast_channel *chan_autoservice = NULL;
+	char *opt_args[OPT_ARG_ARRAY_SIZE];
+	struct ast_flags flags = {0};
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(digits);
 		AST_APP_ARG(dinterval);
 		AST_APP_ARG(duration);
 		AST_APP_ARG(channel);
+		AST_APP_ARG(options);
 	);
 
 	if (ast_strlen_zero(vdata)) {
@@ -136,6 +161,12 @@
 			chan_autoservice = chan;
 		}
 	}
+	if (!ast_strlen_zero(args.options)) {
+		ast_app_parse_options(senddtmf_app_options, &flags, opt_args, args.options);
+	}
+	if (ast_test_flag(&flags, OPT_ANSWER)) {
+		ast_auto_answer(chan_dest);
+	}
 	res = ast_dtmf_stream(chan_dest, chan_autoservice, args.digits,
 		dinterval <= 0 ? 250 : dinterval, duration);
 	if (chan_found) {
diff --git a/doc/CHANGES-staging/app_senddtmf_answer.txt b/doc/CHANGES-staging/app_senddtmf_answer.txt
new file mode 100644
index 0000000..76811e3
--- /dev/null
+++ b/doc/CHANGES-staging/app_senddtmf_answer.txt
@@ -0,0 +1,5 @@
+Subject: app_senddtmf
+
+A new option has been added to SendDTMF() which will answer the
+specified channel if it is not already up. If no channel is specified,
+the current channel will be answered instead.

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

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085
Gerrit-Change-Number: 19894
Gerrit-PatchSet: 3
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-Reviewer: N A <asterisk at phreaknet.org>
Gerrit-CC: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230227/bbb01c0a/attachment-0001.html>


More information about the asterisk-code-review mailing list