[Asterisk-code-review] ami: Add AMI event for Wink (asterisk[16])
Friendly Automation
asteriskteam at digium.com
Wed Jan 5 11:44:54 CST 2022
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/17818 )
Change subject: ami: Add AMI event for Wink
......................................................................
ami: Add AMI event for Wink
Adds an AMI event for a wink frame.
ASTERISK-29830 #close
Change-Id: I83e426de5e37baed79a4dbcc91e9e8d030ef1b56
---
M configs/samples/stasis.conf.sample
A doc/CHANGES-staging/ami_wink.txt
M include/asterisk/stasis_channels.h
M main/channel.c
M main/manager_channels.c
M main/stasis.c
M main/stasis_channels.c
7 files changed, 53 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/configs/samples/stasis.conf.sample b/configs/samples/stasis.conf.sample
index 6fadc74..b62d1c6 100644
--- a/configs/samples/stasis.conf.sample
+++ b/configs/samples/stasis.conf.sample
@@ -54,6 +54,7 @@
; decline=ast_channel_dtmf_begin_type
; decline=ast_channel_dtmf_end_type
; decline=ast_channel_flash_type
+; decline=ast_channel_wink_type
; decline=ast_channel_hold_type
; decline=ast_channel_unhold_type
; decline=ast_channel_chanspy_start_type
diff --git a/doc/CHANGES-staging/ami_wink.txt b/doc/CHANGES-staging/ami_wink.txt
new file mode 100644
index 0000000..9d27cca
--- /dev/null
+++ b/doc/CHANGES-staging/ami_wink.txt
@@ -0,0 +1,3 @@
+Subject: ami
+
+An AMI event now exists for "Wink".
diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h
index 0905dc5..0f28abc 100644
--- a/include/asterisk/stasis_channels.h
+++ b/include/asterisk/stasis_channels.h
@@ -420,6 +420,13 @@
struct stasis_message_type *ast_channel_flash_type(void);
/*!
+ * \brief Message type for when a wink occurs on a channel.
+ *
+ * \return A stasis message type
+ */
+struct stasis_message_type *ast_channel_wink_type(void);
+
+/*!
* \since 12
* \brief Message type for when a channel is placed on hold.
*
diff --git a/main/channel.c b/main/channel.c
index cd7513a..d2f0e18 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3417,6 +3417,11 @@
ast_channel_publish_blob(chan, ast_channel_flash_type(), NULL);
}
+static void send_wink_event(struct ast_channel *chan)
+{
+ ast_channel_publish_blob(chan, ast_channel_wink_type(), NULL);
+}
+
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
{
struct ast_generator *generator;
@@ -3885,6 +3890,8 @@
f = &ast_null_frame;
} else if (f->subclass.integer == AST_CONTROL_FLASH) {
send_flash_event(chan);
+ } else if (f->subclass.integer == AST_CONTROL_WINK) {
+ send_wink_event(chan);
}
break;
case AST_FRAME_DTMF_END:
diff --git a/main/manager_channels.c b/main/manager_channels.c
index 4a5def7..c0f7bc7 100644
--- a/main/manager_channels.c
+++ b/main/manager_channels.c
@@ -1017,6 +1017,34 @@
ast_free(channel_event_string);
}
+static void channel_wink_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *obj = stasis_message_data(message);
+ struct ast_str *channel_event_string;
+
+ channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+ if (!channel_event_string) {
+ return;
+ }
+
+ /*** DOCUMENTATION
+ <managerEvent language="en_US" name="Wink">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when a wink occurs on a channel.</synopsis>
+ <syntax>
+ <channel_snapshot/>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ ***/
+ manager_event(EVENT_FLAG_CALL, "Wink",
+ "%s",
+ ast_str_buffer(channel_event_string));
+
+ ast_free(channel_event_string);
+}
+
static void channel_hangup_handler_cb(void *data, struct stasis_subscription *sub,
struct stasis_message *message)
{
@@ -1380,6 +1408,9 @@
ast_channel_flash_type(), channel_flash_cb, NULL);
ret |= stasis_message_router_add(message_router,
+ ast_channel_wink_type(), channel_wink_cb, NULL);
+
+ ret |= stasis_message_router_add(message_router,
ast_channel_hangup_request_type(), channel_hangup_request_cb,
NULL);
diff --git a/main/stasis.c b/main/stasis.c
index 6dba7b6..5ca35ec 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -121,6 +121,7 @@
<enum name="ast_channel_dtmf_begin_type" />
<enum name="ast_channel_dtmf_end_type" />
<enum name="ast_channel_flash_type" />
+ <enum name="ast_channel_wink_type" />
<enum name="ast_channel_hold_type" />
<enum name="ast_channel_unhold_type" />
<enum name="ast_channel_chanspy_start_type" />
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index 1da2db5..934de2b 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -1308,6 +1308,7 @@
.to_json = unhold_to_json,
);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_flash_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_wink_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_start_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_stop_type);
STASIS_MESSAGE_TYPE_DEFN(ast_channel_fax_type);
@@ -1353,6 +1354,7 @@
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_begin_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_end_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_flash_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_wink_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_hold_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_unhold_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_chanspy_start_type);
@@ -1408,6 +1410,7 @@
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_flash_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_wink_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17818
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I83e426de5e37baed79a4dbcc91e9e8d030ef1b56
Gerrit-Change-Number: 17818
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
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/20220105/513f1f06/attachment.html>
More information about the asterisk-code-review
mailing list