<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15889">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">AMI: Add AMI event to expose hook flash events<br><br>Although Asterisk can receive and propogate flash events, it currently<br>provides no mechanism for doing anything with them itself.<br><br>This AMI event allows flash events to be processed by Asterisk.<br>Additionally, AST_CONTROL_FLASH is included in a switch statement<br>in channel.c to avoid throwing a warning when we shouldn't.<br><br>ASTERISK-29380<br><br>Change-Id: Ie17ffe65086e0282c88542e38eed6a461ec79e81<br>---<br>M configs/samples/stasis.conf.sample<br>M include/asterisk/stasis_channels.h<br>M main/channel.c<br>M main/manager_channels.c<br>M main/stasis.c<br>M main/stasis_channels.c<br>6 files changed, 42 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/89/15889/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/stasis.conf.sample b/configs/samples/stasis.conf.sample</span><br><span>index 46a240e..6fadc74 100644</span><br><span>--- a/configs/samples/stasis.conf.sample</span><br><span>+++ b/configs/samples/stasis.conf.sample</span><br><span>@@ -53,6 +53,7 @@</span><br><span> ; decline=ast_channel_hangup_request_type</span><br><span> ; decline=ast_channel_dtmf_begin_type</span><br><span> ; decline=ast_channel_dtmf_end_type</span><br><span style="color: hsl(120, 100%, 40%);">+; decline=ast_channel_flash_type</span><br><span> ; decline=ast_channel_hold_type</span><br><span> ; decline=ast_channel_unhold_type</span><br><span> ; decline=ast_channel_chanspy_start_type</span><br><span>diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h</span><br><span>index 02654e9..56d785e 100644</span><br><span>--- a/include/asterisk/stasis_channels.h</span><br><span>+++ b/include/asterisk/stasis_channels.h</span><br><span>@@ -526,6 +526,14 @@</span><br><span> struct stasis_message_type *ast_channel_dtmf_end_type(void);</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \since 18</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Message type for when a hook flash occurs on a channel.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval A stasis message type</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct stasis_message_type *ast_channel_flash_type(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span> * \since 12</span><br><span> * \brief Message type for when a channel is placed on hold.</span><br><span> *</span><br><span>diff --git a/main/channel.c b/main/channel.c</span><br><span>index e92eaf8..42083c3 100644</span><br><span>--- a/main/channel.c</span><br><span>+++ b/main/channel.c</span><br><span>@@ -3315,6 +3315,7 @@</span><br><span> case AST_CONTROL_UPDATE_RTP_PEER:</span><br><span> case AST_CONTROL_HOLD:</span><br><span> case AST_CONTROL_UNHOLD:</span><br><span style="color: hsl(120, 100%, 40%);">+ case AST_CONTROL_FLASH:</span><br><span> case -1:</span><br><span> /* Unimportant */</span><br><span> break;</span><br><span>@@ -3393,6 +3394,11 @@</span><br><span> ast_channel_publish_blob(chan, ast_channel_dtmf_end_type(), blob);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void send_flash_event(struct ast_channel *chan)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_publish_blob(chan, ast_channel_flash_type(), NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)</span><br><span> {</span><br><span> struct ast_generator *generator;</span><br><span>@@ -3859,6 +3865,8 @@</span><br><span> */</span><br><span> ast_frfree(f);</span><br><span> f = &ast_null_frame;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (f->subclass.integer == AST_CONTROL_FLASH) {</span><br><span style="color: hsl(120, 100%, 40%);">+ send_flash_event(chan);</span><br><span> }</span><br><span> break;</span><br><span> case AST_FRAME_DTMF_END:</span><br><span>diff --git a/main/manager_channels.c b/main/manager_channels.c</span><br><span>index 7f40efe..dae737c 100644</span><br><span>--- a/main/manager_channels.c</span><br><span>+++ b/main/manager_channels.c</span><br><span>@@ -968,6 +968,24 @@</span><br><span> digit, duration_ms, direction);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void channel_flash_cb(void *data, struct stasis_subscription *sub,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct stasis_message *message)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_channel_blob *obj = stasis_message_data(message);</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_str *channel_event_string;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!channel_event_string) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ manager_event(EVENT_FLAG_CALL, "Flash",</span><br><span style="color: hsl(120, 100%, 40%);">+ "%s",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_buffer(channel_event_string));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(channel_event_string);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void channel_hangup_handler_cb(void *data, struct stasis_subscription *sub,</span><br><span> struct stasis_message *message)</span><br><span> {</span><br><span>@@ -1328,6 +1346,9 @@</span><br><span> ast_channel_dtmf_end_type(), channel_dtmf_end_cb, NULL);</span><br><span> </span><br><span> ret |= stasis_message_router_add(message_router,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_flash_type(), channel_flash_cb, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ret |= stasis_message_router_add(message_router,</span><br><span> ast_channel_hangup_request_type(), channel_hangup_request_cb,</span><br><span> NULL);</span><br><span> </span><br><span>diff --git a/main/stasis.c b/main/stasis.c</span><br><span>index 4ae6d6a..bc11b7f 100644</span><br><span>--- a/main/stasis.c</span><br><span>+++ b/main/stasis.c</span><br><span>@@ -120,6 +120,7 @@</span><br><span> <enum name="ast_channel_hangup_request_type" /></span><br><span> <enum name="ast_channel_dtmf_begin_type" /></span><br><span> <enum name="ast_channel_dtmf_end_type" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <enum name="ast_channel_flash_type" /></span><br><span> <enum name="ast_channel_hold_type" /></span><br><span> <enum name="ast_channel_unhold_type" /></span><br><span> <enum name="ast_channel_chanspy_start_type" /></span><br><span>diff --git a/main/stasis_channels.c b/main/stasis_channels.c</span><br><span>index 3f3312b..5e39c07 100644</span><br><span>--- a/main/stasis_channels.c</span><br><span>+++ b/main/stasis_channels.c</span><br><span>@@ -1598,6 +1598,7 @@</span><br><span> STASIS_MESSAGE_TYPE_DEFN(ast_channel_unhold_type,</span><br><span> .to_json = unhold_to_json,</span><br><span> );</span><br><span style="color: hsl(120, 100%, 40%);">+STASIS_MESSAGE_TYPE_DEFN(ast_channel_flash_type);</span><br><span> STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_start_type);</span><br><span> STASIS_MESSAGE_TYPE_DEFN(ast_channel_chanspy_stop_type);</span><br><span> STASIS_MESSAGE_TYPE_DEFN(ast_channel_fax_type);</span><br><span>@@ -1642,6 +1643,7 @@</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_masquerade_type);</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_begin_type);</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_dtmf_end_type);</span><br><span style="color: hsl(120, 100%, 40%);">+ STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_flash_type);</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_hold_type);</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_unhold_type);</span><br><span> STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_chanspy_start_type);</span><br><span>@@ -1695,6 +1697,7 @@</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_masquerade_type);</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_flash_type);</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);</span><br><span> res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15889">change 15889</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15889"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie17ffe65086e0282c88542e38eed6a461ec79e81 </div>
<div style="display:none"> Gerrit-Change-Number: 15889 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>