From 3e2c662a882aae0d447f489df7b4a6d9dbe4f71e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 4 Aug 2011 17:20:02 -0500 Subject: [PATCH] clean up originator/ee profile so the right one is prevelant in events --- src/switch_channel.c | 32 +++++++++++++++++--------------- src/switch_ivr_bridge.c | 4 ++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index bd2f84b779..72aa68ea7f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -110,6 +110,12 @@ typedef enum { OCF_HANGUP = (1 << 0) } opaque_channel_flag_t; +typedef enum { + LP_NEITHER, + LP_ORIGINATOR, + LP_ORIGINATEE +} switch_originator_type_t; + struct switch_channel { char *name; switch_call_direction_t direction; @@ -139,6 +145,7 @@ struct switch_channel { int event_count; int profile_index; opaque_channel_flag_t opaque_flags; + switch_originator_type_t last_profile_type; }; @@ -2156,23 +2163,16 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *chann switch_caller_profile_event_set_data(caller_profile, "Caller", event); } - if (originator_caller_profile && originatee_caller_profile) { - /* Index Originator's Profile */ - switch_caller_profile_event_set_data(originator_caller_profile, "Originator", event); - - /* Index Originatee's Profile */ - switch_caller_profile_event_set_data(originatee_caller_profile, "Originatee", event); - } else { - /* Index Originator's Profile */ - if (originator_caller_profile) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Other-Type", "originator"); - switch_caller_profile_event_set_data(originator_caller_profile, "Other-Leg", event); - } else if (originatee_caller_profile) { /* Index Originatee's Profile */ - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Other-Type", "originatee"); - switch_caller_profile_event_set_data(originatee_caller_profile, "Other-Leg", event); - } + /* Index Originator/ee's Profile */ + if (originator_caller_profile && channel->last_profile_type == LP_ORIGINATOR) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Other-Type", "originator"); + switch_caller_profile_event_set_data(originator_caller_profile, "Other-Leg", event); + } else if (originatee_caller_profile && channel->last_profile_type == LP_ORIGINATEE) { /* Index Originatee's Profile */ + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Other-Type", "originatee"); + switch_caller_profile_event_set_data(originatee_caller_profile, "Other-Leg", event); } + switch_mutex_unlock(channel->profile_mutex); } @@ -2342,6 +2342,7 @@ SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel if (channel->caller_profile) { caller_profile->next = channel->caller_profile->originator_caller_profile; channel->caller_profile->originator_caller_profile = caller_profile; + channel->last_profile_type = LP_ORIGINATOR; } switch_assert(channel->caller_profile->originator_caller_profile->next != channel->caller_profile->originator_caller_profile); switch_mutex_unlock(channel->profile_mutex); @@ -2402,6 +2403,7 @@ SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel if (channel->caller_profile) { caller_profile->next = channel->caller_profile->originatee_caller_profile; channel->caller_profile->originatee_caller_profile = caller_profile; + channel->last_profile_type = LP_ORIGINATEE; } switch_assert(channel->caller_profile->originatee_caller_profile->next != channel->caller_profile->originatee_caller_profile); switch_mutex_unlock(channel->profile_mutex); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 9dbd4aecab..b1726e9119 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -997,6 +997,8 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session) if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) { switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid); switch_channel_event_set_data(channel, event); switch_event_fire(&event); } @@ -1310,6 +1312,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(peer_session)); if (br && switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", switch_core_session_get_uuid(peer_session)); switch_channel_event_set_data(caller_channel, event); switch_event_fire(&event); }