]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add uuid_debug_audio <uuid> <on|off>
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Oct 2009 17:29:05 +0000 (17:29 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Oct 2009 17:29:05 +0000 (17:29 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15273 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_core_session.c
src/switch_rtp.c

index abaff85b3e50ae3df9dfbe1e255d05153b654159..07b9670be38ea989ded2c653f7af6b0c1e9af7d8 100644 (file)
@@ -513,7 +513,8 @@ typedef enum {
        SWITCH_ZRTP_FLAG_SECURE_SEND = (1 << 23),
        SWITCH_ZRTP_FLAG_SECURE_RECV = (1 << 24),
        SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 << 25),
-       SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26)
+       SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26),
+       SWITCH_RTP_FLAG_DEBUG_RTP = (1 << 27)
 } switch_rtp_flag_enum_t;
 typedef uint32_t switch_rtp_flag_t;
 
@@ -666,6 +667,7 @@ typedef enum {
        SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
        SWITCH_MESSAGE_INDICATE_UUID_CHANGE,
        SWITCH_MESSAGE_INDICATE_WARNING,
+       SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO,
        SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 
index 6d7b23b662b9b47bc43aafc75c97e87ce2b97a5d..a319969d59fade6321e527e44cf0b1af8bd3cbe5 100644 (file)
@@ -2105,6 +2105,44 @@ SWITCH_STANDARD_API(uuid_warning_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
+
+#define DEBUG_AUDIO_SYNTAX "<uuid> <on|off>"
+SWITCH_STANDARD_API(uuid_debug_audio_function)
+{
+       char *mycmd = NULL, *argv[2] = { 0 };
+       int argc = 0;
+       switch_status_t status = SWITCH_STATUS_FALSE;
+
+       if (!zstr(cmd) && (mycmd = strdup(cmd))) {
+               argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+       }
+
+       if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) {
+               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.from = __FILE__;
+
+               if ((lsession = switch_core_session_locate(argv[0]))) {
+                       status = switch_core_session_receive_message(lsession, &msg);
+                       switch_core_session_rwunlock(lsession);
+               }
+       }
+
+       if (status == SWITCH_STATUS_SUCCESS) {
+               stream->write_function(stream, "+OK Success\n");
+       } else {
+               stream->write_function(stream, "-ERR Operation Failed\n");
+       }
+
+       switch_safe_free(mycmd);
+       return SWITCH_STATUS_SUCCESS;
+}
+
 #define UUID_SYNTAX "<uuid> <other_uuid>"
 SWITCH_STANDARD_API(uuid_bridge_function)
 {
@@ -3711,6 +3749,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_warning", "send popup", uuid_warning_function, WARNING_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_debug_audio", "debug audio", uuid_debug_audio_function, DEBUG_AUDIO_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
        switch_console_set_complete("add fsctl hupall");
index f476149e13bdc2fb66dfbe926a1e31b88bd42659..95f6c5c8770b05d9d976deb15ff665448c7cf353 100644 (file)
@@ -1080,6 +1080,17 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 
        /* ones that do not need to lock sofia mutex */
        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);
+                               } else {
+                                       switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP);
+                               }
+                       }
+               }
+               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)) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Pass 2833 mode may not work on a transcoded call.\n");
index 994a09baf295d6b5416de21bc072ba5a0be522fa..a3022dde2707b2d29641152d2631e6a44f506c94 100644 (file)
@@ -578,6 +578,7 @@ static const char *message_names[] = {
        "REQUEST_IMAGE_MEDIA",
        "UUID_CHANGE",
        "WARNING",
+       "DEBUG_AUDIO",
        "INVALID"
 };
 
index 329158a84771c6b0c095295c16cf035a09f7d61c..1338672f243968aaec3e70459c623571574c3360 100644 (file)
@@ -1678,6 +1678,20 @@ static void do_flush(switch_rtp_t *rtp_session)
        READ_INC(rtp_session);
 
        if (switch_rtp_ready(rtp_session)) {
+
+               if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
+                       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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
+                                                                 SWITCH_LOG_CONSOLE, "%s FLUSH\n",
+                                                                 switch_channel_get_name(switch_core_session_get_channel(session))
+                                                                 );
+                       }
+               }
+
                if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
                        was_blocking = 1;
                        switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);           
@@ -1889,6 +1903,38 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                        rtp_flush_read_buffer(rtp_session, SWITCH_RTP_FLUSH_ONCE);
                }
 
+
+               if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP)) {
+                       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_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,
+                                                                 "%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),
+                                                                 rtp_session->recv_msg.header.pt, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.header.m);
+                       
+                       }
+               }
+
+
                if (bytes && ((rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) || rtp_session->recv_msg.header.pt == 13)) {
                        bytes = 0;
                        goto recvfrom;