From e7470e882c6c99ef2ef989d2871d9f38e41d8daf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 27 Apr 2009 17:45:04 +0000 Subject: [PATCH] FSCORE-357 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13167 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 2 ++ src/switch_channel.c | 2 +- src/switch_core_session.c | 13 +++++++++++++ src/switch_ivr_bridge.c | 19 ++++++++++++++----- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 78f566b739..e1ba1ac312 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -677,6 +677,8 @@ SWITCH_DECLARE(void) switch_core_session_hupall(_In_ switch_call_cause_t cause); SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause); SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner); + /*! \brief Send a message to another session using it's uuid \param uuid_str the unique id of the session you want to send a message to diff --git a/src/switch_channel.c b/src/switch_channel.c index b1beb3a55e..f1a2472eb5 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -764,7 +764,7 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw state = switch_channel_get_running_state(other_channel); mystate = switch_channel_get_running_state(channel); - if (mystate != ostate || state >= CS_HANGUP || state == want_state) { + if (mystate != ostate || state >= CS_HANGUP || state >= want_state) { break; } switch_cond_next(); diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 3c6dd890dc..114a2e0fd9 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -75,6 +75,19 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(const char *u return session; } +SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner) +{ + const char *uuid; + + if ((uuid = switch_channel_get_variable(session->channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + *partner = switch_core_session_locate(uuid); + return SWITCH_STATUS_SUCCESS; + } + + *partner = NULL; + return SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_name, const char *var_val, switch_call_cause_t cause) { diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 2b10b26a80..96ea48e09f 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -508,15 +508,24 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses if (switch_true(switch_channel_get_variable(channel, SWITCH_COPY_XML_CDR_VARIABLE))) { + switch_core_session_t *other_session; + switch_channel_t *other_channel; switch_xml_t cdr; char *xml_text; - if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) { - switch_channel_set_variable_partner(channel, "b_leg_cdr", xml_text); - switch_safe_free(xml_text); + if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { + other_channel = switch_core_session_get_channel(other_session); + + switch_channel_wait_for_state(channel, other_channel, CS_REPORTING); + + if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { + if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) { + switch_channel_set_variable(other_channel, "b_leg_cdr", xml_text); + switch_safe_free(xml_text); + } + switch_xml_free(cdr); } - switch_xml_free(cdr); + switch_core_session_rwunlock(other_session); } }