<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18350">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip: Add ability to send flash events.<br><br>PJSIP currently is capable of receiving flash events<br>and converting them to FLASH control frames, but it<br>currently lacks support for doing the reverse: taking<br>a FLASH control frame and converting it into a flash<br>event in the SIP domain.<br><br>This adds the ability for PJSIP to process flash control<br>frames by converting them into the appropriate SIP INFO<br>message, which can then be sent to the peer. This allows,<br>for example, flash events to be sent between Asterisk<br>systems using PJSIP.<br><br>ASTERISK-29941 #close<br><br>Change-Id: I1590221a4d238597f79672fa5825dd4a920c94dd<br>---<br>M channels/chan_pjsip.c<br>A doc/CHANGES-staging/chan_pjsip_flash.txt<br>2 files changed, 28 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/50/18350/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index e8fbb3d..a303b32 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -1609,6 +1609,10 @@</span><br><span>      SCOPE_EXIT_RTN_VALUE(res, "RC: %d\n", res);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Forward declarations */</span><br><span style="color: hsl(120, 100%, 40%);">+static int transmit_info_dtmf(void *data);</span><br><span style="color: hsl(120, 100%, 40%);">+static struct info_dtmf_data *info_dtmf_data_alloc(struct ast_sip_session *session, char digit, unsigned int duration);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Function called by core to ask the channel to indicate some sort of condition */</span><br><span> static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)</span><br><span> {</span><br><span>@@ -1629,6 +1633,10 @@</span><br><span>           .data.ptr = (void *)data,</span><br><span>    };</span><br><span>   char condition_name[256];</span><br><span style="color: hsl(120, 100%, 40%);">+     unsigned int duration;</span><br><span style="color: hsl(120, 100%, 40%);">+        char digit;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct info_dtmf_data *dtmf_data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  SCOPE_ENTER(3, "%s: Indicated %s\n", ast_channel_name(ast),</span><br><span>                ast_frame_subclass2str(&f, condition_name, sizeof(condition_name), NULL, 0));</span><br><span> </span><br><span>@@ -1684,6 +1692,22 @@</span><br><span>               }</span><br><span>            ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "PJSIP/%s", ast_sorcery_object_get_id(channel->session->endpoint));</span><br><span>          break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case AST_CONTROL_FLASH:</span><br><span style="color: hsl(120, 100%, 40%);">+               duration = 300;</span><br><span style="color: hsl(120, 100%, 40%);">+               digit = '!';</span><br><span style="color: hsl(120, 100%, 40%);">+          dtmf_data = info_dtmf_data_alloc(channel->session, digit, duration);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+             if (!dtmf_data) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     res = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+                     break;</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%);">+           if (ast_sip_push_task(channel->session->serializer, transmit_info_dtmf, dtmf_data)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   ast_log(LOG_WARNING, "Error sending FLASH via INFO on channel %s\n", ast_channel_name(ast));</span><br><span style="color: hsl(120, 100%, 40%);">+                        ao2_ref(dtmf_data, -1); /* dtmf_data can't be null here */</span><br><span style="color: hsl(120, 100%, 40%);">+                        res = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span style="color: hsl(120, 100%, 40%);">+             break;</span><br><span>       case AST_CONTROL_VIDUPDATE:</span><br><span>          for (i = 0; i < AST_VECTOR_SIZE(&channel->session->active_media_state->sessions); ++i) {</span><br><span>                     media = AST_VECTOR_GET(&channel->session->active_media_state->sessions, i);</span><br><span>diff --git a/doc/CHANGES-staging/chan_pjsip_flash.txt b/doc/CHANGES-staging/chan_pjsip_flash.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..34da796</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/chan_pjsip_flash.txt</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: chan_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Hook flash events can now be sent on a PJSIP channel</span><br><span style="color: hsl(120, 100%, 40%);">+if requested to do so.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18350">change 18350</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/+/18350"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I1590221a4d238597f79672fa5825dd4a920c94dd </div>
<div style="display:none"> Gerrit-Change-Number: 18350 </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>