Revision
15274
Author
anthm
Date
2009-10-29 12:52:52 -0500 (Thu, 29 Oct 2009)

Log Message

add uuid_debug_audio <uuid> <read|write|both> <on|off>

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_types.h (15273 => 15274)


--- freeswitch/trunk/src/include/switch_types.h	2009-10-29 17:29:05 UTC (rev 15273)
+++ freeswitch/trunk/src/include/switch_types.h	2009-10-29 17:52:52 UTC (rev 15274)
@@ -514,7 +514,8 @@
 	SWITCH_ZRTP_FLAG_SECURE_RECV = (1 << 24),
 	SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 << 25),
 	SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26),
-	SWITCH_RTP_FLAG_DEBUG_RTP = (1 << 27)
+	SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 << 27),
+	SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 << 28)
 } switch_rtp_flag_enum_t;
 typedef uint32_t switch_rtp_flag_t;
 

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (15273 => 15274)


--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-10-29 17:29:05 UTC (rev 15273)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-10-29 17:52:52 UTC (rev 15274)
@@ -2106,10 +2106,10 @@
 }
 
 
-#define DEBUG_AUDIO_SYNTAX "<uuid> <on|off>"
+#define DEBUG_AUDIO_SYNTAX "<uuid> <read|write|both> <on|off>"
 SWITCH_STANDARD_API(uuid_debug_audio_function)
 {
-	char *mycmd = NULL, *argv[2] = { 0 };
+	char *mycmd = NULL, *argv[3] = { 0 };
 	int argc = 0;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
@@ -2117,14 +2117,15 @@
 		argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 	}
 
-	if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) {
+	if (zstr(cmd) || argc < 3 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2])) {
 		stream->write_function(stream, "-USAGE: %s\n", DEBUG_AUDIO_SYNTAX);
 	} else {
 		switch_core_session_message_t msg = { 0 };
 		switch_core_session_t *lsession = NULL;
-
+		
 		msg.message_id = SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO;
-		msg.string_arg = argv[1];
+		msg.string_array_arg[0] = argv[1];
+		msg.string_array_arg[1] = argv[2];
 		msg.from = __FILE__;
 
 		if ((lsession = switch_core_session_locate(argv[0]))) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15273 => 15274)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-29 17:29:05 UTC (rev 15273)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-29 17:52:52 UTC (rev 15274)
@@ -1082,14 +1082,28 @@
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO:
 		{
-			if (switch_rtp_ready(tech_pvt->rtp_session)) {
-				if (switch_true(msg->string_arg)) {
-					switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
+			if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
+				int32_t flags = 0;
+				if (!strcasecmp(msg->string_array_arg[0], "read")) {
+					flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ;
+				} else if (!strcasecmp(msg->string_array_arg[0], "write")) {
+					flags |= SWITCH_RTP_FLAG_DEBUG_RTP_WRITE;
+				} else if (!strcasecmp(msg->string_array_arg[0], "both")) {
+					flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ | SWITCH_RTP_FLAG_DEBUG_RTP_WRITE;
+				}
+
+				if (flags) {
+					if (switch_true(msg->string_array_arg[1])) {
+						switch_rtp_set_flag(tech_pvt->rtp_session, flags);
+					} else {
+						switch_rtp_clear_flag(tech_pvt->rtp_session, flags);
+					}
 				} else {
-					switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
+					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options\n");
 				}
 			}
 		}
+		status = SWITCH_STATUS_FALSE;
 		goto end;
 	case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY:
 		if (tech_pvt->rtp_session && switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {

Modified: freeswitch/trunk/src/switch_rtp.c (15273 => 15274)


--- freeswitch/trunk/src/switch_rtp.c	2009-10-29 17:29:05 UTC (rev 15273)
+++ freeswitch/trunk/src/switch_rtp.c	2009-10-29 17:52:52 UTC (rev 15274)
@@ -1679,10 +1679,10 @@
 
 	if (switch_rtp_ready(rtp_session)) {
 
-		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
+		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ)) {
 			switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
 			if (!session) {
-				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
+				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ);
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
@@ -1904,11 +1904,11 @@
 		}
 
 
-		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
+		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ)) {
 			switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
 
 			if (!session) {
-				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
+				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ);
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
 			} else {
 				const char *tx_host;
@@ -1923,7 +1923,7 @@
 				my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
 
 				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
-								  "%s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n", 
+								  "R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n", 
 								  switch_channel_get_name(switch_core_session_get_channel(session)),
 								  (long)bytes,
 								  my_host, switch_sockaddr_get_port(rtp_session->local_addr),
@@ -2748,6 +2748,37 @@
 #endif
 
 
+		if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_WRITE)) {
+			switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
+
+			if (!session) {
+				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_WRITE);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
+			} else {
+				const char *tx_host;
+				const char *old_host;
+				const char *my_host;
+
+				char bufa[30], bufb[30], bufc[30];
+				
+				
+				tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
+				old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
+				my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
+
+				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
+								  "W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n", 
+								  switch_channel_get_name(switch_core_session_get_channel(session)),
+								  (long)bytes,
+								  my_host, switch_sockaddr_get_port(rtp_session->local_addr),
+								  old_host, rtp_session->remote_port, 
+								  tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
+								  send_msg->header.pt, ntohl(send_msg->header.ts), send_msg->header.m);
+			
+			}
+		}
+
+
 		if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
 			rtp_session->seq--;
 			ret = -1;