<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14889">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, approved
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, but someone else must approve
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_chanspy: Spyee information missing in ChanSpyStop AMI Event<br><br>The documentation in the wiki says there should be spyee-channel<br>information elements in the ChanSpyStop AMI event.<br><br> https://wiki.asterisk.org/wiki/x/Xc5uAg<br><br>However, this is not the case in Asterisk <= 16.10.0 Version. We're<br>using these Spyee* arguments since Asterisk 11.x, so these arguments<br>vanished in Asterisk 12 or higher.<br><br>For maximum compatibility, we still send the ChanSpyStop event even if<br>we are not able to find any 'Spyee' information.<br><br>ASTERISK-28883 #close<br><br>Change-Id: I81ce397a3fd614c094d043ffe5b1b1d76188835f<br>---<br>M apps/app_chanspy.c<br>M main/manager_channels.c<br>M res/res_stasis_snoop.c<br>3 files changed, 25 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c</span><br><span>index c66d250..e02f25d 100644</span><br><span>--- a/apps/app_chanspy.c</span><br><span>+++ b/apps/app_chanspy.c</span><br><span>@@ -845,13 +845,13 @@</span><br><span> ast_audiohook_unlock(&csth.spy_audiohook);</span><br><span> ast_audiohook_destroy(&csth.spy_audiohook);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(2, "Done Spying on channel %s\n", name);</span><br><span style="color: hsl(120, 100%, 40%);">+ publish_chanspy_message(chan, spyee_autochan->chan, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (spyee_bridge_autochan) {</span><br><span> ast_autochan_destroy(spyee_bridge_autochan);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_verb(2, "Done Spying on channel %s\n", name);</span><br><span style="color: hsl(0, 100%, 40%);">- publish_chanspy_message(chan, NULL, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> return running;</span><br><span> }</span><br><span> </span><br><span>diff --git a/main/manager_channels.c b/main/manager_channels.c</span><br><span>index c964033..25f94da 100644</span><br><span>--- a/main/manager_channels.c</span><br><span>+++ b/main/manager_channels.c</span><br><span>@@ -825,12 +825,15 @@</span><br><span> struct stasis_message *message)</span><br><span> {</span><br><span> RAII_VAR(struct ast_str *, spyer_channel_string, NULL, ast_free);</span><br><span style="color: hsl(120, 100%, 40%);">+ RAII_VAR(struct ast_str *, spyee_channel_string, NULL, ast_free);</span><br><span> struct ast_channel_snapshot *spyer;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_channel_snapshot *spyee;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *spyee_info = "";</span><br><span> struct ast_multi_channel_blob *payload = stasis_message_data(message);</span><br><span> </span><br><span> spyer = ast_multi_channel_blob_get_channel(payload, "spyer_channel");</span><br><span> if (!spyer) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(AST_LOG_WARNING, "Received ChanSpy Start event with no spyer channel!\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "Received ChanSpy Stop event with no spyer channel!\n");</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span>@@ -839,9 +842,18 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ spyee = ast_multi_channel_blob_get_channel(payload, "spyee_channel");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (spyee) {</span><br><span style="color: hsl(120, 100%, 40%);">+ spyee_channel_string = ast_manager_build_channel_state_string_prefix(spyee, "Spyee");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (spyee_channel_string) {</span><br><span style="color: hsl(120, 100%, 40%);">+ spyee_info = ast_str_buffer(spyee_channel_string);</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%);">+</span><br><span> manager_event(EVENT_FLAG_CALL, "ChanSpyStop",</span><br><span style="color: hsl(0, 100%, 40%);">- "%s",</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_buffer(spyer_channel_string));</span><br><span style="color: hsl(120, 100%, 40%);">+ "%s%s",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_buffer(spyer_channel_string),</span><br><span style="color: hsl(120, 100%, 40%);">+ spyee_info);</span><br><span> }</span><br><span> </span><br><span> static void channel_chanspy_start_cb(void *data, struct stasis_subscription *sub,</span><br><span>diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c</span><br><span>index b234de1..7e87611 100644</span><br><span>--- a/res/res_stasis_snoop.c</span><br><span>+++ b/res/res_stasis_snoop.c</span><br><span>@@ -66,12 +66,12 @@</span><br><span> struct ast_str *app;</span><br><span> /*! \brief Snoop channel */</span><br><span> struct ast_channel *chan;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief The channel that the Snoop channel is snooping on */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_channel *spyee_chan;</span><br><span> /*! \brief Whether the spy capability is active or not */</span><br><span> unsigned int spy_active:1;</span><br><span> /*! \brief Whether the whisper capability is active or not */</span><br><span> unsigned int whisper_active:1;</span><br><span style="color: hsl(0, 100%, 40%);">- /*! \brief Uniqueid of the channel this snoop is snooping on */</span><br><span style="color: hsl(0, 100%, 40%);">- char uniqueid[AST_MAX_UNIQUEID];</span><br><span> /*! \brief A frame of silence to use when the audiohook returns null */</span><br><span> struct ast_frame silence;</span><br><span> };</span><br><span>@@ -100,6 +100,7 @@</span><br><span> </span><br><span> ast_free(snoop->app);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_cleanup(snoop->spyee_chan);</span><br><span> ast_channel_cleanup(snoop->chan);</span><br><span> }</span><br><span> </span><br><span>@@ -134,7 +135,7 @@</span><br><span> }</span><br><span> ast_multi_channel_blob_add_channel(payload, "spyer_channel", snoop_snapshot);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- spyee_snapshot = ast_channel_snapshot_get_latest(snoop->uniqueid);</span><br><span style="color: hsl(120, 100%, 40%);">+ spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));</span><br><span> if (spyee_snapshot) {</span><br><span> ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);</span><br><span> }</span><br><span>@@ -354,8 +355,6 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(snoop->uniqueid, ast_channel_uniqueid(chan), sizeof(snoop->uniqueid));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* To keep the channel valid on the Snoop structure until it is destroyed we bump the ref up here */</span><br><span> ast_channel_ref(snoop->chan);</span><br><span> </span><br><span>@@ -425,6 +424,9 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Keep a reference to the channel we are spying on */</span><br><span style="color: hsl(120, 100%, 40%);">+ snoop->spyee_chan = ast_channel_ref(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> publish_chanspy_message(snoop, 1);</span><br><span> </span><br><span> /* The caller of this has a reference as well */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14889">change 14889</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/+/14889"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I81ce397a3fd614c094d043ffe5b1b1d76188835f </div>
<div style="display:none"> Gerrit-Change-Number: 14889 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Hendrik Wedhorn <hwedhorn@addix.net> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-CC: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>