[Asterisk-code-review] app_senddtmf: Add SendFlash AMI action. (asterisk[master])

Friendly Automation asteriskteam at digium.com
Thu Mar 16 08:23:11 CDT 2023


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

Change subject: app_senddtmf: Add SendFlash AMI action.
......................................................................

app_senddtmf: Add SendFlash AMI action.

Adds an AMI action to send a flash event
on a channel.

ASTERISK-30440 #close

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

Approvals:
  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 c119d8c..ed54809 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -97,6 +97,23 @@
 			<para>Plays a dtmf digit on the specified channel.</para>
 		</description>
 	</manager>
+	<manager name="SendFlash" language="en_US">
+		<synopsis>
+			Send a hook flash on a specific channel.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Channel" required="true">
+				<para>Channel name to send hook flash to.</para>
+			</parameter>
+			<parameter name="Receive" required="false">
+				<para>Emulate receiving a hook flash on this channel instead of sending it out.</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>Sends a hook flash on the specified channel.</para>
+		</description>
+	</manager>
  ***/
 
 enum read_option_flags {
@@ -218,12 +235,41 @@
 	return 0;
 }
 
+static int manager_send_flash(struct mansession *s, const struct message *m)
+{
+	const char *channel = astman_get_header(m, "Channel");
+	const char *receive_s = astman_get_header(m, "Receive");
+	struct ast_channel *chan;
+
+	if (!(chan = ast_channel_get_by_name(channel))) {
+		astman_send_error(s, m, "Channel not found");
+		return 0;
+	}
+
+	if (ast_true(receive_s)) {
+		struct ast_frame f = { AST_FRAME_CONTROL, };
+		f.subclass.integer = AST_CONTROL_FLASH;
+		ast_queue_frame(chan, &f);
+	} else {
+		struct ast_frame f = { AST_FRAME_CONTROL, };
+		f.subclass.integer = AST_CONTROL_FLASH;
+		ast_channel_lock(chan);
+		ast_write(chan, &f);
+		ast_channel_unlock(chan);
+	}
+
+	chan = ast_channel_unref(chan);
+	astman_send_ack(s, m, "Flash successfully queued");
+	return 0;
+}
+
 static int unload_module(void)
 {
 	int res;
 
 	res = ast_unregister_application(senddtmf_name);
 	res |= ast_manager_unregister("PlayDTMF");
+	res |= ast_manager_unregister("SendFlash");
 
 	return res;
 }
@@ -233,6 +279,7 @@
 	int res;
 
 	res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf);
+	res |= ast_manager_register_xml("SendFlash", EVENT_FLAG_CALL, manager_send_flash);
 	res |= ast_register_application_xml(senddtmf_name, senddtmf_exec);
 
 	return res;
diff --git a/doc/CHANGES-staging/ami_hook_flash.txt b/doc/CHANGES-staging/ami_hook_flash.txt
new file mode 100644
index 0000000..5bf1e34
--- /dev/null
+++ b/doc/CHANGES-staging/ami_hook_flash.txt
@@ -0,0 +1,4 @@
+Subject: app_senddtmf
+
+The SendFlash AMI action now allows sending
+a hook flash event on a channel.

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I4707aeecb3cd8f3e63fd0c3fe009798943c369c9
Gerrit-Change-Number: 19927
Gerrit-PatchSet: 2
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230316/9fbbee63/attachment.html>


More information about the asterisk-code-review mailing list