ast_audiohook_unlock(&csth.spy_audiohook);
ast_audiohook_destroy(&csth.spy_audiohook);
+ ast_verb(2, "Done Spying on channel %s\n", name);
+ publish_chanspy_message(chan, spyee_autochan->chan, 0);
+
if (spyee_bridge_autochan) {
ast_autochan_destroy(spyee_bridge_autochan);
}
- ast_verb(2, "Done Spying on channel %s\n", name);
- publish_chanspy_message(chan, NULL, 0);
-
return running;
}
struct stasis_message *message)
{
RAII_VAR(struct ast_str *, spyer_channel_string, NULL, ast_free);
+ RAII_VAR(struct ast_str *, spyee_channel_string, NULL, ast_free);
struct ast_channel_snapshot *spyer;
+ struct ast_channel_snapshot *spyee;
+ const char *spyee_info = "";
struct ast_multi_channel_blob *payload = stasis_message_data(message);
spyer = ast_multi_channel_blob_get_channel(payload, "spyer_channel");
if (!spyer) {
- ast_log(AST_LOG_WARNING, "Received ChanSpy Start event with no spyer channel!\n");
+ ast_log(AST_LOG_WARNING, "Received ChanSpy Stop event with no spyer channel!\n");
return;
}
return;
}
+ spyee = ast_multi_channel_blob_get_channel(payload, "spyee_channel");
+ if (spyee) {
+ spyee_channel_string = ast_manager_build_channel_state_string_prefix(spyee, "Spyee");
+ if (spyee_channel_string) {
+ spyee_info = ast_str_buffer(spyee_channel_string);
+ }
+ }
+
manager_event(EVENT_FLAG_CALL, "ChanSpyStop",
- "%s",
- ast_str_buffer(spyer_channel_string));
+ "%s%s",
+ ast_str_buffer(spyer_channel_string),
+ spyee_info);
}
static void channel_chanspy_start_cb(void *data, struct stasis_subscription *sub,
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;
};
ast_free(snoop->app);
+ ast_channel_cleanup(snoop->spyee_chan);
ast_channel_cleanup(snoop->chan);
}
}
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);
}
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);
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 */