add bridge_answer_timeout variable, a timeout in seconds how long to tolerate a bridge that is in early media without being answered (can be set on either leg)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15057 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-10-02 21:23:52 +00:00
parent 1daf620e34
commit 58f1f28d9e
1 changed files with 18 additions and 1 deletions

View File

@ -108,6 +108,10 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
int16_t silence_data[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = { 0 };
const char *silence_var, *var;
int silence_val = 0, bypass_media_after_bridge = 0;
const char *bridge_answer_timeout = NULL;
int answer_timeout;
time_t answer_limit = 0;
#ifdef SWITCH_VIDEO_IN_THREADS
struct vid_helper vh = { 0 };
uint32_t vid_launch = 0;
@ -133,7 +137,15 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
}
inner_bridge = switch_channel_test_flag(chan_a, CF_INNER_BRIDGE);
if (!switch_channel_test_flag(chan_a, CF_ANSWERED) && (bridge_answer_timeout = switch_channel_get_variable(chan_a, "bridge_answer_timeout"))) {
if ((answer_timeout = atoi(bridge_answer_timeout)) < 0) {
answer_timeout = 0;
} else {
answer_limit = switch_epoch_time_now(NULL) + answer_timeout;
}
}
switch_channel_set_flag(chan_a, CF_BRIDGED);
@ -300,6 +312,11 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
}
}
if (!ans_a && answer_limit && switch_epoch_time_now(NULL) > answer_limit) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Answer timeout hit on %s.\n", switch_channel_get_name(chan_a));
switch_channel_hangup(chan_a, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
}
if (!ans_a && originator) {
if (!ans_b && switch_channel_test_flag(chan_b, CF_ANSWERED)) {