[Freeswitch-svn] [commit] r6801 - in freeswitch/trunk: libs/libteletone/src src/mod/applications/mod_commands

Freeswitch SVN anthm at freeswitch.org
Fri Dec 14 18:11:14 EST 2007


Author: anthm
Date: Fri Dec 14 18:11:14 2007
New Revision: 6801

Modified:
   freeswitch/trunk/libs/libteletone/src/libteletone_detect.c
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c

Log:
add uuid_dump

Modified: freeswitch/trunk/libs/libteletone/src/libteletone_detect.c
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone_detect.c	(original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone_detect.c	Fri Dec 14 18:11:14 2007
@@ -216,7 +216,7 @@
 	float eng_sum = 0, eng_all[TELETONE_MAX_TONES];
 	int gtest = 0, see_hit = 0;
 
-	for (sample = 0;  sample < samples;	 sample = limit) {
+	for (sample = 0;  sample >= 0 && sample < samples; sample = limit) {
 		mt->total_samples++;
 
 		if ((samples - sample) >= (mt->min_samples - mt->current_sample)) {

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Fri Dec 14 18:11:14 2007
@@ -1985,6 +1985,71 @@
 
 
 
+#define DUMP_SYNTAX "<uuid> [format]"
+SWITCH_STANDARD_API(uuid_dump_function)
+{
+	switch_core_session_t *psession = NULL;
+	char *mycmd = NULL, *argv[4] = { 0 };
+	int argc = 0;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
+		argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+		if (argc >= 0) {
+			char *uuid = argv[0];
+			char *format = argv[1];
+			
+			if ((psession = switch_core_session_locate(uuid))) {
+				switch_channel_t *channel;
+				switch_event_t *event;
+				char *buf;
+
+				channel = switch_core_session_get_channel(psession);
+				switch_assert(channel != NULL);
+
+				if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+					switch_channel_event_set_data(channel, event);
+					if (format && !strcasecmp(format, "xml")) {
+						switch_xml_t xml;
+						if ((xml = switch_event_xmlize(event, "%s", ""))) {
+                            buf = switch_xml_toxml(xml, SWITCH_FALSE);
+                            switch_xml_free(xml);
+						}
+					} else {
+						switch_event_serialize(event, &buf, SWITCH_TRUE);
+					}
+					
+					switch_assert(buf);
+					stream->write_function(stream, buf);
+					switch_event_destroy(&event);
+					free(buf);
+				} else {
+					abort();
+				}
+
+				switch_core_session_rwunlock(psession);
+
+			} else {
+				stream->write_function(stream, "-ERR No Such Channel!\n");
+			}
+			goto done;
+		}
+	}
+
+	stream->write_function(stream, "-USAGE: %s\n", DUMP_SYNTAX);
+
+ done:
+	switch_safe_free(mycmd);
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+
+
 #define GLOBAL_SETVAR_SYNTAX "<var> <value>"
 SWITCH_STANDARD_API(global_setvar_function)
 {
@@ -2049,6 +2114,7 @@
 	SWITCH_ADD_API(commands_api_interface, "uuid_bridge", "uuid_bridge", uuid_bridge_function, "");
 	SWITCH_ADD_API(commands_api_interface, "uuid_setvar", "uuid_setvar", uuid_setvar_function, SETVAR_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX);
+	SWITCH_ADD_API(commands_api_interface, "uuid_dump", "uuid_dump", uuid_dump_function, DUMP_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "global_setvar", "global_setvar", global_setvar_function, GLOBAL_SETVAR_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "global_getvar", "global_getvar", global_getvar_function, GLOBAL_GETVAR_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace (depricated)", 



More information about the Freeswitch-svn mailing list