fix issue with global bypass_media_after_bridge messing up callflow

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15404 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-11-09 23:49:35 +00:00
parent 92896c6c36
commit 275e919f3c
6 changed files with 20 additions and 19 deletions

View File

@ -929,6 +929,7 @@ typedef enum {
CF_NOT_READY,
CF_SIGNAL_BRIDGE_TTL,
CF_MEDIA_BRIDGE_TTL,
CF_BYPASS_MEDIA_AFTER_BRIDGE,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
CF_FLAG_MAX
} switch_channel_flag_t;

View File

@ -2144,7 +2144,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
{
switch_channel_t *caller_channel = switch_core_session_get_channel(session);
switch_core_session_t *peer_session = NULL;
const char *continue_on_fail = NULL, *failure_causes = NULL,
const char *continue_on_fail = NULL, *failure_causes = NULL,
*v_campon = NULL, *v_campon_retries, *v_campon_sleep, *v_campon_timeout, *v_campon_fallback_exten = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
int campon_retries = 100, campon_timeout = 10, campon_sleep = 10, tmp, camping = 0, fail = 0, thread_started = 0;
@ -2383,6 +2383,10 @@ SWITCH_STANDARD_APP(audio_bridge_function)
b_key = NULL;
}
if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) {
switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
}
switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, a_key);
}

View File

@ -727,7 +727,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
}
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session) && !switch_channel_test_flag(channel, CF_REQ_MEDIA))) {
if (--sanity && switch_channel_ready(channel)) {
if (--sanity && switch_channel_up(channel)) {
switch_yield(10000);
} else {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);

View File

@ -3922,7 +3922,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
launch_media_on_hold(session);
switch_core_session_rwunlock(other_session);
goto done;
}
@ -4391,14 +4391,6 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
if (refer_to->r_url->url_headers && (rep = (char *)switch_stristr("Replaces=", refer_to->r_url->url_headers))) {
sip_replaces_t *replaces;
nua_handle_t *bnh;
if (switch_channel_test_flag(channel_a, CF_PROXY_MODE)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Attended Transfer BYPASS MEDIA CALLS!\n");
switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
goto done;
}
if (rep) {
const char *br_a = NULL, *br_b = NULL;
@ -4515,7 +4507,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
if ((profile->media_options & MEDIA_OPT_BYPASS_AFTER_ATT_XFER) && (tmp = switch_core_session_locate(br_b))) {
switch_channel_t *tchannel = switch_core_session_get_channel(tmp);
switch_channel_set_variable(tchannel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE, "true");
switch_channel_set_flag(tchannel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
switch_core_session_rwunlock(tmp);
}

View File

@ -884,6 +884,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_
(*event)->bind_user_data = todup->bind_user_data;
for (hp = todup->headers; hp; hp = hp->next) {
if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) {
continue;
}
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, hp->name, hp->value);
}

View File

@ -165,13 +165,12 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
switch_codec_t silence_codec = { 0 };
switch_frame_t silence_frame = { 0 };
int16_t silence_data[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = { 0 };
const char *silence_var, *var;
const char *silence_var;
int silence_val = 0, bypass_media_after_bridge = 0;
const char *bridge_answer_timeout = NULL;
int answer_timeout, sent_update = 0;
time_t answer_limit = 0;
#ifdef SWITCH_VIDEO_IN_THREADS
struct vid_helper vh = { 0 };
uint32_t vid_launch = 0;
@ -190,6 +189,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
chan_a = switch_core_session_get_channel(session_a);
chan_b = switch_core_session_get_channel(session_b);
bypass_media_after_bridge = switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE);
switch_channel_clear_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE);
ans_a = switch_channel_test_flag(chan_a, CF_ANSWERED);
if ((originator = switch_channel_test_flag(chan_a, CF_BRIDGE_ORIGINATOR))) {
@ -220,13 +222,11 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
goto end_of_bridge_loop;
}
if ((var = switch_channel_get_variable(chan_a, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)) && switch_true(var)) {
if (bypass_media_after_bridge) {
if (switch_stristr("loopback", switch_channel_get_name(chan_a)) || switch_stristr("loopback", switch_channel_get_name(chan_b))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot bypass media while bridged to a loopback address.\n");
} else {
switch_channel_set_variable(chan_a, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE, NULL);
bypass_media_after_bridge = 0;
}
bypass_media_after_bridge = 1;
}
if ((silence_var = switch_channel_get_variable(chan_a, "bridge_generate_comfort_noise"))) {
@ -330,10 +330,11 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
#endif
if (loop_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a) &&
bypass_media_after_bridge && switch_channel_test_flag(chan_a, CF_ANSWERED) &&
(bypass_media_after_bridge || switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED) &&
switch_channel_test_flag(chan_b, CF_ANSWERED)) {
switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);
bypass_media_after_bridge = 0;
switch_channel_clear_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE);
}
/* if 1 channel has DTMF pass it to the other */