]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add uuid_debug_audio <uuid> <read|write|both> <on|off>
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Oct 2009 17:52:52 +0000 (17:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Oct 2009 17:52:52 +0000 (17:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15274 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_rtp.c

index 07b9670be38ea989ded2c653f7af6b0c1e9af7d8..059e50a48ba5e00be26afbfbe39cabfc29dcb595 100644 (file)
@@ -514,7 +514,8 @@ typedef enum {
        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;
 
index a319969d59fade6321e527e44cf0b1af8bd3cbe5..f8caf079b799d69698280385e765f307ffbf3511 100644 (file)
@@ -2106,10 +2106,10 @@ SWITCH_STANDARD_API(uuid_warning_function)
 }
 
 
-#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 @@ SWITCH_STANDARD_API(uuid_debug_audio_function)
                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]))) {
index 95f6c5c8770b05d9d976deb15ff665448c7cf353..891f782193ac087d8ca325e4e8f309c3eb55680f 100644 (file)
@@ -1082,14 +1082,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
        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)) {
index 1338672f243968aaec3e70459c623571574c3360..631aaafab528fed9c906f294ccd78125fed8347e 100644 (file)
@@ -1679,10 +1679,10 @@ static void do_flush(switch_rtp_t *rtp_session)
 
        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 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                }
 
 
-               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 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                                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", 
+                                                                 "%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 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
 #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;