[Freeswitch-svn] [commit] r8098 - in freeswitch/trunk/src: . include mod/applications/mod_dptools

Freeswitch SVN anthm at freeswitch.org
Sat Apr 12 12:17:10 EDT 2008


Author: anthm
Date: Sat Apr 12 12:17:09 2008
New Revision: 8098

Modified:
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/switch_ivr_async.c

Log:
update

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Sat Apr 12 12:17:09 2008
@@ -211,7 +211,10 @@
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
-SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, 
+															 const char *uuid, 
+															 const char *require_group, 
+															 switch_eavesdrop_flag_t flags);
 SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
 SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file);
 

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Sat Apr 12 12:17:09 2008
@@ -146,18 +146,20 @@
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", eavesdrop_SYNTAX);
 	} else {
+		switch_channel_t *channel = switch_core_session_get_channel(session);
+		const char *require_group = switch_channel_get_variable(channel, "eavesdrop_require_group");
 		if (!strcasecmp((char *)data, "all")) {
 			switch_core_db_t *db = switch_core_db_handle();
 			char *errmsg = NULL;
 			struct e_data e_data = {{ 0 }};
 			char *sql = switch_mprintf("select uuid from channels where uuid != '%q'", switch_core_session_get_uuid(session));
-			switch_channel_t *channel = switch_core_session_get_channel(session);
 			const char *file = NULL;
 			int x = 0;
 			char buf[2] = "";
 			switch_size_t buflen = sizeof(buf);
 			char terminator;
-
+			switch_status_t status;
+			
 			while(switch_channel_ready(channel)) {
 				for(x = 0; x < MAX_SPY; x++) {
 					switch_safe_free(e_data.uuid_list[x]);
@@ -179,12 +181,14 @@
 						if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_new"))) {
 							switch_ivr_play_file(session, NULL, file, NULL);
 						}
-						if (switch_ivr_eavesdrop_session(session, e_data.uuid_list[x], ED_DTMF) != SWITCH_STATUS_SUCCESS) {
-							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Spy: %s Failed\n", e_data.uuid_list[x]);
-							if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed"))) {
-								switch_ivr_play_file(session, NULL, file, NULL);
+						if ((status = switch_ivr_eavesdrop_session(session, e_data.uuid_list[x], require_group, ED_DTMF)) != SWITCH_STATUS_SUCCESS) {
+							if (status != SWITCH_STATUS_BREAK) {
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Spy: %s Failed\n", e_data.uuid_list[x]);
+								if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed"))) {
+									switch_ivr_play_file(session, NULL, file, NULL);
+								}
+								switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0);
 							}
-							switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0);
 						}
 					}
 				} else {
@@ -202,7 +206,7 @@
 			switch_core_db_close(db);
 			
 		} else {
-			switch_ivr_eavesdrop_session(session, data, ED_DTMF);
+			switch_ivr_eavesdrop_session(session, data, require_group, ED_DTMF);
 		}
 	}
 }
@@ -214,7 +218,7 @@
 	if (switch_strlen_zero(data)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", threeway_SYNTAX);
 	} else {
-		switch_ivr_eavesdrop_session(session, data, ED_MUX_READ | ED_MUX_WRITE);
+		switch_ivr_eavesdrop_session(session, data, NULL, ED_MUX_READ | ED_MUX_WRITE);
 	}
 }
 

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Sat Apr 12 12:17:09 2008
@@ -489,7 +489,10 @@
 	return SWITCH_TRUE;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags)
+SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, 
+															 const char *uuid, 
+															 const char *require_group, 
+															 switch_eavesdrop_flag_t flags)
 {
 	switch_core_session_t *tsession;
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -505,11 +508,36 @@
 		int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE/2];
 		switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession);
 		uint32_t tlen;
+		const char *macro_name = "eavesdrop_announce";
+		const char *id_name = NULL;
 
 		if (!switch_channel_media_ready(channel)) {
 			goto end;
 		}
 
+		if (!switch_channel_media_ready(tchannel)) {
+			goto end;
+		}
+
+		if ((id_name = switch_channel_get_variable(tchannel, "eavesdrop_announce_id"))) {
+			const char *tmp = switch_channel_get_variable(tchannel, "eavesdrop_annnounce_macro");
+			if (tmp) {
+				macro_name = tmp;
+			}
+
+			switch_ivr_phrase_macro(session, macro_name, id_name, NULL, NULL);
+		}
+
+
+		if (!switch_strlen_zero(require_group)) {
+			const char *group_name = switch_channel_get_variable(tchannel, "eavesdrop_group");			
+			if (!group_name || strcmp(group_name, require_group)) {
+				status = SWITCH_STATUS_BREAK;
+				goto end;
+			}
+		}
+
+		
 		ep = switch_core_session_alloc(session, sizeof(*ep));
 
 		tlen = tread_codec->implementation->bytes_per_frame;



More information about the Freeswitch-svn mailing list