mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
res_stasis: Expose event for call forwarding and follow forwarded channel.
This change adds an event for when an originated call is redirected to another target. This event contains the original channel and the newly created channel. If a stasis subscription exists on the original originated channel for a stasis application then a new subscription will also be created on the stasis application to the redirected channel. This allows the application to follow the call path completely. (closes issue ASTERISK-22719) Reported by: Joshua Colp Review: https://reviewboard.asterisk.org/r/3054/ ........ Merged revisions 403808 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403810 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -265,6 +265,25 @@ static void app_dtor(void *obj)
|
||||
app->data = NULL;
|
||||
}
|
||||
|
||||
static void call_forwarded_handler(struct stasis_app *app, struct stasis_message *message)
|
||||
{
|
||||
struct ast_multi_channel_blob *payload = stasis_message_data(message);
|
||||
struct ast_channel_snapshot *snapshot = ast_multi_channel_blob_get_channel(payload, "forwarded");
|
||||
struct ast_channel *chan;
|
||||
|
||||
if (!snapshot) {
|
||||
return;
|
||||
}
|
||||
|
||||
chan = ast_channel_get_by_name(snapshot->uniqueid);
|
||||
if (!chan) {
|
||||
return;
|
||||
}
|
||||
|
||||
app_subscribe_channel(app, chan);
|
||||
ast_channel_unref(chan);
|
||||
}
|
||||
|
||||
static void sub_default_handler(void *data, struct stasis_subscription *sub,
|
||||
struct stasis_message *message)
|
||||
{
|
||||
@@ -275,6 +294,10 @@ static void sub_default_handler(void *data, struct stasis_subscription *sub,
|
||||
ao2_cleanup(app);
|
||||
}
|
||||
|
||||
if (stasis_message_type(message) == ast_channel_dial_type()) {
|
||||
call_forwarded_handler(app, message);
|
||||
}
|
||||
|
||||
/* By default, send any message that has a JSON representation */
|
||||
json = stasis_message_to_json(message, stasis_app_get_sanitizer());
|
||||
if (!json) {
|
||||
|
Reference in New Issue
Block a user