summaryrefslogtreecommitdiff
path: root/main/stasis_bridges.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2014-08-20 13:06:33 +0000
committerKinsey Moore <kmoore@digium.com>2014-08-20 13:06:33 +0000
commit36f4bff943c0ea83b3d1a3ab5243658d64b16ba3 (patch)
tree7bc49bbdb265bfae3c007c1b23f9964c202ae5f9 /main/stasis_bridges.c
parent01f1ff1f77101b2612ddb885dc6e22125e46a9fb (diff)
Stasis: Add information to blind transfer event
When a blind transfer occurs that is forced to create a local channel pair to satisfy the transfer request, information about the local channel pair is not published. This adds a field to describe that channel to the blind transfer message struct so that this information is conveyed properly to consumers of the blind transfer message. This also fixes a bug in which Stasis() was unable to properly identify the channel that was replacing an existing Stasis-controlled channel due to a blind transfer. Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/3921/ ........ Merged revisions 421537 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 421538 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@421539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis_bridges.c')
-rw-r--r--main/stasis_bridges.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/main/stasis_bridges.c b/main/stasis_bridges.c
index 7b61ce31d..16fda2d49 100644
--- a/main/stasis_bridges.c
+++ b/main/stasis_bridges.c
@@ -636,7 +636,10 @@ static struct ast_json *blind_transfer_to_json(struct stasis_message *msg,
const struct stasis_message_sanitizer *sanitize)
{
struct ast_blind_transfer_message *transfer_msg = stasis_message_data(msg);
- struct ast_json *json_transferer, *json_transferee = NULL, *out;
+ struct ast_json *json_transferer;
+ struct ast_json *json_transferee = NULL;
+ struct ast_json *out;
+ struct ast_json *json_replace = NULL;
const struct timeval *tv = stasis_message_timestamp(msg);
json_transferer = ast_channel_snapshot_to_json(transfer_msg->to_transferee.channel_snapshot, sanitize);
@@ -647,6 +650,16 @@ static struct ast_json *blind_transfer_to_json(struct stasis_message *msg,
if (transfer_msg->transferee) {
json_transferee = ast_channel_snapshot_to_json(transfer_msg->transferee, sanitize);
if (!json_transferee) {
+ ast_json_unref(json_transferer);
+ return NULL;
+ }
+ }
+
+ if (transfer_msg->replace_channel) {
+ json_replace = ast_channel_snapshot_to_json(transfer_msg->replace_channel, sanitize);
+ if (!json_replace) {
+ ast_json_unref(json_transferee);
+ ast_json_unref(json_transferer);
return NULL;
}
}
@@ -661,11 +674,19 @@ static struct ast_json *blind_transfer_to_json(struct stasis_message *msg,
"is_external", ast_json_boolean(transfer_msg->is_external));
if (!out) {
+ ast_json_unref(json_transferee);
+ ast_json_unref(json_replace);
return NULL;
}
if (json_transferee && ast_json_object_set(out, "transferee", json_transferee)) {
ast_json_unref(out);
+ ast_json_unref(json_replace);
+ return NULL;
+ }
+
+ if (json_replace && ast_json_object_set(out, "replace_channel", json_replace)) {
+ ast_json_unref(out);
return NULL;
}
@@ -741,7 +762,7 @@ static void blind_transfer_dtor(void *obj)
void ast_bridge_publish_blind_transfer(int is_external, enum ast_transfer_result result,
struct ast_bridge_channel_pair *transferer, const char *context, const char *exten,
- struct ast_channel *transferee_channel)
+ struct ast_channel *transferee_channel, struct ast_channel *replace_channel)
{
struct ast_blind_transfer_message *msg;
struct stasis_message *stasis;
@@ -759,6 +780,9 @@ void ast_bridge_publish_blind_transfer(int is_external, enum ast_transfer_result
if (transferee_channel) {
msg->transferee = ast_channel_snapshot_get_latest(ast_channel_uniqueid(transferee_channel));
}
+ if (replace_channel) {
+ msg->replace_channel = ast_channel_snapshot_get_latest(ast_channel_uniqueid(replace_channel));
+ }
msg->is_external = is_external;
msg->result = result;
ast_copy_string(msg->context, context, sizeof(msg->context));