Revision
15057
Author
anthm
Date
2009-10-02 16:23:52 -0500 (Fri, 02 Oct 2009)

Log Message

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)

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (15056 => 15057)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-02 21:10:27 UTC (rev 15056)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-02 21:23:52 UTC (rev 15057)
@@ -108,6 +108,10 @@
 	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,8 +137,16 @@
 	}
 
 	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);
 
 	switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
@@ -300,6 +312,11 @@
 			}
 		}
 
+		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)) {