]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clean up originator/ee profile so the right one is prevelant in events
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 4 Aug 2011 22:20:02 +0000 (17:20 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 4 Aug 2011 22:20:02 +0000 (17:20 -0500)
src/switch_channel.c
src/switch_ivr_bridge.c

index bd2f84b77956a927ebd05c56337f0be68d8d448b..72aa68ea7fbfe18c322b843513d34b43719faf12 100644 (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);
index 9dbd4aecab9ec1c44d52602ac8dd6c3befe84c15..b1726e91190680cd44469a02c773d82a99ae0b20 100644 (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);
        }