]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ami: Add AMI event for Wink
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 3 Jan 2022 17:10:03 +0000 (17:10 +0000)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Wed, 5 Jan 2022 17:44:53 +0000 (11:44 -0600)
Adds an AMI event for a wink frame.

ASTERISK-29830 #close

Change-Id: I83e426de5e37baed79a4dbcc91e9e8d030ef1b56

configs/samples/stasis.conf.sample
doc/CHANGES-staging/ami_wink.txt [new file with mode: 0644]
include/asterisk/stasis_channels.h
main/channel.c
main/manager_channels.c
main/stasis.c
main/stasis_channels.c

index 6fadc74073eea23813bbe699206d5fa6e1a1144c..b62d1c60ae3064a451269d4733d2458ebf403db1 100644 (file)
@@ -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 (file)
index 0000000..9d27cca
--- /dev/null
@@ -0,0 +1,3 @@
+Subject: ami
+
+An AMI event now exists for "Wink".
index 0905dc5341ecf4f9c8b67919330d315c08c561f6..0f28abcff8255ba6225ed186b3126e74a66dbeb4 100644 (file)
@@ -419,6 +419,13 @@ struct stasis_message_type *ast_channel_dtmf_end_type(void);
  */
 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.
index cd7513a1629e5056de09327c168a0177a8803a8f..d2f0e18f9d4a5f89e095d55df7e6a83980211de1 100644 (file)
@@ -3417,6 +3417,11 @@ static void send_flash_event(struct ast_channel *chan)
        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 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
                                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:
index 4a5def7fe43c993f2015210ccd70130c29b9601e..c0f7bc79ba6ebb94924d147fe9765334248a4647 100644 (file)
@@ -1017,6 +1017,34 @@ static void channel_flash_cb(void *data, struct stasis_subscription *sub,
        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)
 {
@@ -1379,6 +1407,9 @@ int manager_channels_init(void)
        ret |= stasis_message_router_add(message_router,
                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);
index 6dba7b644b318cf52b12d5b5f0b2b9bcabc30f1c..5ca35ecaf75848ca3c33778b8217c1dfac6f6524 100644 (file)
                                                        <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" />
index 1da2db5753512cc98dd07612d8851714b311af8a..934de2becf6687706f6cfbd981b9784ed8210067 100644 (file)
@@ -1308,6 +1308,7 @@ STASIS_MESSAGE_TYPE_DEFN(ast_channel_unhold_type,
        .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 @@ static void stasis_channels_cleanup(void)
        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 @@ int ast_stasis_channels_init(void)
        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);