app_chanspy: Spyee information missing in ChanSpyStop AMI Event

The documentation in the wiki says there should be spyee-channel
information elements in the ChanSpyStop AMI event.

    https://wiki.asterisk.org/wiki/x/Xc5uAg

However, this is not the case in Asterisk <= 16.10.0 Version. We're
using these Spyee* arguments since Asterisk 11.x, so these arguments
vanished in Asterisk 12 or higher.

For maximum compatibility, we still send the ChanSpyStop event even if
we are not able to find any 'Spyee' information.

ASTERISK-28883 #close

Change-Id: I81ce397a3fd614c094d043ffe5b1b1d76188835f
This commit is contained in:
Sean Bright
2020-12-11 14:27:56 -05:00
committed by George Joseph
parent 91fc57f56b
commit 357510cec3
3 changed files with 25 additions and 11 deletions

View File

@@ -66,12 +66,12 @@ struct stasis_app_snoop {
struct ast_str *app;
/*! \brief Snoop channel */
struct ast_channel *chan;
/*! \brief The channel that the Snoop channel is snooping on */
struct ast_channel *spyee_chan;
/*! \brief Whether the spy capability is active or not */
unsigned int spy_active:1;
/*! \brief Whether the whisper capability is active or not */
unsigned int whisper_active:1;
/*! \brief Uniqueid of the channel this snoop is snooping on */
char uniqueid[AST_MAX_UNIQUEID];
/*! \brief A frame of silence to use when the audiohook returns null */
struct ast_frame silence;
};
@@ -100,6 +100,7 @@ static void snoop_destroy(void *obj)
ast_free(snoop->app);
ast_channel_cleanup(snoop->spyee_chan);
ast_channel_cleanup(snoop->chan);
}
@@ -134,7 +135,7 @@ static void publish_chanspy_message(struct stasis_app_snoop *snoop, int start)
}
ast_multi_channel_blob_add_channel(payload, "spyer_channel", snoop_snapshot);
spyee_snapshot = ast_channel_snapshot_get_latest(snoop->uniqueid);
spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));
if (spyee_snapshot) {
ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);
}
@@ -354,8 +355,6 @@ struct ast_channel *stasis_app_control_snoop(struct ast_channel *chan,
return NULL;
}
ast_copy_string(snoop->uniqueid, ast_channel_uniqueid(chan), sizeof(snoop->uniqueid));
/* To keep the channel valid on the Snoop structure until it is destroyed we bump the ref up here */
ast_channel_ref(snoop->chan);
@@ -425,6 +424,9 @@ struct ast_channel *stasis_app_control_snoop(struct ast_channel *chan,
return NULL;
}
/* Keep a reference to the channel we are spying on */
snoop->spyee_chan = ast_channel_ref(chan);
publish_chanspy_message(snoop, 1);
/* The caller of this has a reference as well */