Skip to content

Commit cec0c5c

Browse files
InterLinked1Friendly Automation
authored and
Friendly Automation
committed
app_senddtmf: Add SendFlash AMI action.
Adds an AMI action to send a flash event on a channel. ASTERISK-30440 #close Change-Id: I4707aeecb3cd8f3e63fd0c3fe009798943c369c9
1 parent e971396 commit cec0c5c

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

apps/app_senddtmf.c

+47
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@
9797
<para>Plays a dtmf digit on the specified channel.</para>
9898
</description>
9999
</manager>
100+
<manager name="SendFlash" language="en_US">
101+
<synopsis>
102+
Send a hook flash on a specific channel.
103+
</synopsis>
104+
<syntax>
105+
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
106+
<parameter name="Channel" required="true">
107+
<para>Channel name to send hook flash to.</para>
108+
</parameter>
109+
<parameter name="Receive" required="false">
110+
<para>Emulate receiving a hook flash on this channel instead of sending it out.</para>
111+
</parameter>
112+
</syntax>
113+
<description>
114+
<para>Sends a hook flash on the specified channel.</para>
115+
</description>
116+
</manager>
100117
***/
101118

102119
enum read_option_flags {
@@ -218,12 +235,41 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
218235
return 0;
219236
}
220237

238+
static int manager_send_flash(struct mansession *s, const struct message *m)
239+
{
240+
const char *channel = astman_get_header(m, "Channel");
241+
const char *receive_s = astman_get_header(m, "Receive");
242+
struct ast_channel *chan;
243+
244+
if (!(chan = ast_channel_get_by_name(channel))) {
245+
astman_send_error(s, m, "Channel not found");
246+
return 0;
247+
}
248+
249+
if (ast_true(receive_s)) {
250+
struct ast_frame f = { AST_FRAME_CONTROL, };
251+
f.subclass.integer = AST_CONTROL_FLASH;
252+
ast_queue_frame(chan, &f);
253+
} else {
254+
struct ast_frame f = { AST_FRAME_CONTROL, };
255+
f.subclass.integer = AST_CONTROL_FLASH;
256+
ast_channel_lock(chan);
257+
ast_write(chan, &f);
258+
ast_channel_unlock(chan);
259+
}
260+
261+
chan = ast_channel_unref(chan);
262+
astman_send_ack(s, m, "Flash successfully queued");
263+
return 0;
264+
}
265+
221266
static int unload_module(void)
222267
{
223268
int res;
224269

225270
res = ast_unregister_application(senddtmf_name);
226271
res |= ast_manager_unregister("PlayDTMF");
272+
res |= ast_manager_unregister("SendFlash");
227273

228274
return res;
229275
}
@@ -233,6 +279,7 @@ static int load_module(void)
233279
int res;
234280

235281
res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf);
282+
res |= ast_manager_register_xml("SendFlash", EVENT_FLAG_CALL, manager_send_flash);
236283
res |= ast_register_application_xml(senddtmf_name, senddtmf_exec);
237284

238285
return res;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Subject: app_senddtmf
2+
3+
The SendFlash AMI action now allows sending
4+
a hook flash event on a channel.

0 commit comments

Comments
 (0)