clean up originator/ee profile so the right one is prevelant in events

This commit is contained in:
Anthony Minessale 2011-08-04 17:20:02 -05:00
parent 77c5000dad
commit 3e2c662a88
2 changed files with 21 additions and 15 deletions

View File

@ -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);

View File

@ -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);
}