git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1274 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-04-27 00:09:56 +00:00
parent 2a5d68dfea
commit 3c4d46c1cf
2 changed files with 43 additions and 24 deletions

View File

@ -578,8 +578,9 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
size_t bytes = 0, samples = 0, frames = 0, ms = 0;
switch_channel *channel = NULL;
int payload = 0;
switch_time_t now, started = switch_time_now();
switch_time_t now, started = switch_time_now(), last_act = switch_time_now();
unsigned int elapsed;
uint32_t hard_timeout = 60000 * 3;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@ -626,14 +627,20 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
}
payload = tech_pvt->read_frame.payload;
elapsed = (unsigned int)((switch_time_now() - started) / 1000);
if (timeout > -1) {
elapsed = (unsigned int)((switch_time_now() - started) / 1000);
if (elapsed >= (unsigned int)timeout) {
return SWITCH_STATUS_SUCCESS;
return SWITCH_STATUS_BREAK;
}
}
elapsed = (unsigned int)((switch_time_now() - last_act) / 1000);
if (elapsed >= hard_timeout) {
return SWITCH_STATUS_BREAK;
}
/* RFC2833 ... TBD try harder to honor the duration etc.*/
if (payload == 101) {

View File

@ -813,9 +813,11 @@ static switch_status audio_bridge_on_loopback(switch_core_session *session)
if ((arg = switch_channel_get_private(channel))) {
switch_channel_set_private(channel, NULL);
audio_bridge_thread(NULL, (void *) arg);
switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
return SWITCH_STATUS_FALSE;
}
@ -867,7 +869,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
{
struct switch_core_thread_session this_audio_thread, other_audio_thread;
struct switch_core_thread_session *this_audio_thread, *other_audio_thread;
switch_channel *caller_channel, *peer_channel;
time_t start;
int stream_id = 0;
@ -883,23 +885,24 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
peer_channel = switch_core_session_get_channel(peer_session);
assert(peer_channel != NULL);
memset(&other_audio_thread, 0, sizeof(other_audio_thread));
memset(&this_audio_thread, 0, sizeof(this_audio_thread));
other_audio_thread.objs[0] = session;
other_audio_thread.objs[1] = peer_session;
other_audio_thread.objs[2] = &stream_id;
other_audio_thread.objs[3] = (void *) dtmf_callback;
other_audio_thread.objs[4] = session_data;
other_audio_thread.objs[5] = &this_audio_thread;
other_audio_thread.running = 5;
other_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session));
this_audio_thread = switch_core_session_alloc(peer_session, sizeof(switch_core_thread_session));
this_audio_thread.objs[0] = peer_session;
this_audio_thread.objs[1] = session;
this_audio_thread.objs[2] = &stream_id;
this_audio_thread.objs[3] = (void *) dtmf_callback;
this_audio_thread.objs[4] = peer_session_data;
this_audio_thread.objs[5] = &other_audio_thread;
this_audio_thread.running = 2;
other_audio_thread->objs[0] = session;
other_audio_thread->objs[1] = peer_session;
other_audio_thread->objs[2] = &stream_id;
other_audio_thread->objs[3] = (void *) dtmf_callback;
other_audio_thread->objs[4] = session_data;
other_audio_thread->objs[5] = this_audio_thread;
other_audio_thread->running = 5;
this_audio_thread->objs[0] = peer_session;
this_audio_thread->objs[1] = session;
this_audio_thread->objs[2] = &stream_id;
this_audio_thread->objs[3] = (void *) dtmf_callback;
this_audio_thread->objs[4] = peer_session_data;
this_audio_thread->objs[5] = other_audio_thread;
this_audio_thread->running = 2;
switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
@ -978,14 +981,23 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
switch_core_session_receive_message(session, &msg);
switch_channel_set_flag(peer_channel, CF_LOCK_THREAD);
switch_channel_set_private(peer_channel, &other_audio_thread);
switch_channel_set_private(peer_channel, other_audio_thread);
switch_channel_set_state(peer_channel, CS_LOOPBACK);
audio_bridge_thread(NULL, (void *) &this_audio_thread);
audio_bridge_thread(NULL, (void *) this_audio_thread);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(caller_channel, event);
switch_event_fire(&event);
}
this_audio_thread->objs[0] = NULL;
this_audio_thread->objs[1] = NULL;
this_audio_thread->objs[2] = NULL;
this_audio_thread->objs[3] = NULL;
this_audio_thread->objs[4] = NULL;
this_audio_thread->objs[5] = NULL;
this_audio_thread->running = 2;
switch_channel_clear_flag(peer_channel, CF_LOCK_THREAD);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bridge Failed %s->%s\n",