Revision
16530
Author
anthm
Date
2010-01-28 11:10:23 -0600 (Thu, 28 Jan 2010)

Log Message

make bridge_terminate_key work in bypass media when using info dtmf

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (16529 => 16530)


--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2010-01-28 03:13:57 UTC (rev 16529)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2010-01-28 17:10:23 UTC (rev 16530)
@@ -2439,8 +2439,8 @@
 			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);
+			
+			switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
 		}
 		
 		if (peer_session) {

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (16529 => 16530)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2010-01-28 03:13:57 UTC (rev 16529)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2010-01-28 17:10:23 UTC (rev 16530)
@@ -803,13 +803,50 @@
 	return SWITCH_STATUS_FALSE;
 }
 
+static switch_status_t sb_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
+{
+	switch_channel_t *channel = NULL;
+	char *key;
+
+	channel = switch_core_session_get_channel(session);
+	switch_assert(channel != NULL);
+	
+	if ((key = (char *) switch_channel_get_private(channel, "__bridge_term_key")) && dtmf->digit == *key) {
+		const char *uuid;
+		switch_core_session_t *other_session;
+
+		if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+			switch_channel_set_state(channel, CS_EXECUTE);
+		} else {
+			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+				switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+				switch_channel_set_state(other_channel, CS_EXECUTE);
+				switch_core_session_rwunlock(other_session);
+			} else {
+				return SWITCH_STATUS_SUCCESS;
+			}
+		}
+		
+		return SWITCH_STATUS_FALSE;
+	}
+	
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
 static switch_status_t signal_bridge_on_hibernate(switch_core_session_t *session)
 {
 	switch_channel_t *channel = NULL;
+	const char *key;
 
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
 
+	if ((key = switch_channel_get_variable(channel, "bridge_terminate_key"))) {
+		switch_channel_set_private(channel, "__bridge_term_key", switch_core_session_strdup(session, key));
+		switch_core_event_hook_add_recv_dtmf(session, sb_on_dtmf);
+	}
+
 	switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
 
 	return SWITCH_STATUS_SUCCESS;
@@ -826,6 +863,11 @@
 		switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
 	}
 
+	if (switch_channel_get_private(channel, "__bridge_term_key")) {
+		switch_core_event_hook_remove_recv_dtmf(session, sb_on_dtmf);
+		switch_channel_set_private(channel, "__bridge_term_key", NULL);
+	}
+
 	switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
 
 	if (uuid && (other_session = switch_core_session_locate(uuid))) {