Skip to content

Commit 68f1e5d

Browse files
InterLinked1Friendly Automation
authored andcommitted
ami: Add AMI event for Wink
Adds an AMI event for a wink frame. ASTERISK-29830 #close Change-Id: I83e426de5e37baed79a4dbcc91e9e8d030ef1b56
1 parent 5b8d68d commit 68f1e5d

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-0
lines changed

configs/samples/stasis.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
; decline=ast_channel_dtmf_begin_type
5555
; decline=ast_channel_dtmf_end_type
5656
; decline=ast_channel_flash_type
57+
; decline=ast_channel_wink_type
5758
; decline=ast_channel_hold_type
5859
; decline=ast_channel_unhold_type
5960
; decline=ast_channel_chanspy_start_type

doc/CHANGES-staging/ami_wink.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Subject: ami
2+
3+
An AMI event now exists for "Wink".

include/asterisk/stasis_channels.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,13 @@ struct stasis_message_type *ast_channel_dtmf_end_type(void);
528528
*/
529529
struct stasis_message_type *ast_channel_flash_type(void);
530530

531+
/*!
532+
* \brief Message type for when a wink occurs on a channel.
533+
*
534+
* \return A stasis message type
535+
*/
536+
struct stasis_message_type *ast_channel_wink_type(void);
537+
531538
/*!
532539
* \since 12
533540
* \brief Message type for when a channel is placed on hold.

main/channel.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,6 +3405,11 @@ static void send_flash_event(struct ast_channel *chan)
34053405
ast_channel_publish_blob(chan, ast_channel_flash_type(), NULL);
34063406
}
34073407

3408+
static void send_wink_event(struct ast_channel *chan)
3409+
{
3410+
ast_channel_publish_blob(chan, ast_channel_wink_type(), NULL);
3411+
}
3412+
34083413
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
34093414
{
34103415
struct ast_generator *generator;
@@ -3873,6 +3878,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
38733878
f = &ast_null_frame;
38743879
} else if (f->subclass.integer == AST_CONTROL_FLASH) {
38753880
send_flash_event(chan);
3881+
} else if (f->subclass.integer == AST_CONTROL_WINK) {
3882+
send_wink_event(chan);
38763883
}
38773884
break;
38783885
case AST_FRAME_DTMF_END:

main/manager_channels.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,34 @@ static void channel_flash_cb(void *data, struct stasis_subscription *sub,
10001000
ast_free(channel_event_string);
10011001
}
10021002

1003+
static void channel_wink_cb(void *data, struct stasis_subscription *sub,
1004+
struct stasis_message *message)
1005+
{
1006+
struct ast_channel_blob *obj = stasis_message_data(message);
1007+
struct ast_str *channel_event_string;
1008+
1009+
channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
1010+
if (!channel_event_string) {
1011+
return;
1012+
}
1013+
1014+
/*** DOCUMENTATION
1015+
<managerEvent language="en_US" name="Wink">
1016+
<managerEventInstance class="EVENT_FLAG_CALL">
1017+
<synopsis>Raised when a wink occurs on a channel.</synopsis>
1018+
<syntax>
1019+
<channel_snapshot/>
1020+
</syntax>
1021+
</managerEventInstance>
1022+
</managerEvent>
1023+
***/
1024+
manager_event(EVENT_FLAG_CALL, "Wink",
1025+
"%s",
1026+
ast_str_buffer(channel_event_string));
1027+
1028+
ast_free(channel_event_string);
1029+
}
1030+
10031031
static void channel_hangup_handler_cb(void *data, struct stasis_subscription *sub,
10041032
struct stasis_message *message)
10051033
{
@@ -1362,6 +1390,9 @@ int manager_channels_init(void)
13621390
ret |= stasis_message_router_add(message_router,
13631391
ast_channel_flash_type(), channel_flash_cb, NULL);
13641392

1393+
ret |= stasis_message_router_add(message_router,
1394+
ast_channel_wink_type(), channel_wink_cb, NULL);
1395+
13651396
ret |= stasis_message_router_add(message_router,
13661397
ast_channel_hangup_request_type(), channel_hangup_request_cb,
13671398
NULL);

main/stasis.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<enum name="ast_channel_dtmf_begin_type" />
122122
<enum name="ast_channel_dtmf_end_type" />
123123
<enum name="ast_channel_flash_type" />
124+
<enum name="ast_channel_wink_type" />
124125
<enum name="ast_channel_hold_type" />
125126
<enum name="ast_channel_unhold_type" />
126127
<enum name="ast_channel_chanspy_start_type" />

main/stasis_channels.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ STASIS_MESSAGE_TYPE_DEFN(ast_channel_unhold_type,
15991599
.to_json = unhold_to_json,
16001600
);
16011601
STASIS_MESSAGE_TYPE_DEFN(ast_channel_flash_type);
1602+
STASIS_MESSAGE_TYPE_DEFN(ast_channel_wink_type);
16021603
STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_start_type);
16031604
STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_stop_type);
16041605
STASIS_MESSAGE_TYPE_DEFN(ast_channel_fax_type);
@@ -1644,6 +1645,7 @@ static void stasis_channels_cleanup(void)
16441645
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_begin_type);
16451646
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_end_type);
16461647
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_flash_type);
1648+
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_wink_type);
16471649
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_hold_type);
16481650
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_unhold_type);
16491651
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_chanspy_start_type);
@@ -1698,6 +1700,7 @@ int ast_stasis_channels_init(void)
16981700
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
16991701
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
17001702
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_flash_type);
1703+
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_wink_type);
17011704
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
17021705
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
17031706
res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);

0 commit comments

Comments
 (0)