]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5670 --resolve allow debug rtp if rtp is not attached to a session
authorSeven Du <dujinfang@gmail.com>
Thu, 8 Aug 2013 00:19:05 +0000 (08:19 +0800)
committerSeven Du <dujinfang@gmail.com>
Thu, 8 Aug 2013 00:22:00 +0000 (08:22 +0800)
src/switch_core_session.c
src/switch_rtp.c

index 9bcb6488bea652cd476b0ee7990edb8a4339edc6..0768feed15dc9af1eba66398dfa8dfa4287b1557 100644 (file)
@@ -2379,6 +2379,7 @@ SWITCH_DECLARE(uint8_t) switch_core_session_check_interface(switch_core_session_
 
 SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session_t *session)
 {
+       if (!session) return NULL;
        return session->uuid_str;
 }
 
index d961d7df5862955747f0d7d85152c8f22884f030..cfca9f20ae13f99d1200abeab262fbea751c1ebc 100644 (file)
@@ -25,7 +25,7 @@
  * 
  * Anthony Minessale II <anthm@freeswitch.org>
  * Marcel Barbulescu <marcelbarbulescu@gmail.com>
- *
+ * Seven Du <dujinfang@gmail.com>
  *
  * switch_rtp.c -- RTP
  *
@@ -3889,15 +3889,10 @@ static void do_flush(switch_rtp_t *rtp_session, int force)
        if (switch_rtp_ready(rtp_session)) {
                
                if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
-                       
-                       if (!rtp_session->session) {
-                               rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ] = 0;
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
-                       } else {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),
-                                                                 SWITCH_LOG_CONSOLE, "%s FLUSH\n", switch_channel_get_name(switch_core_session_get_channel(rtp_session->session))
-                                                                 );
-                       }
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),
+                                 SWITCH_LOG_CONSOLE, "%s FLUSH\n",
+                                 rtp_session->session ? switch_channel_get_name(switch_core_session_get_channel(rtp_session->session)) : "NoName"
+                                 );
                }
 
                if (!rtp_session->flags[SWITCH_RTP_FLAG_NOBLOCK]) {
@@ -4041,31 +4036,26 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
 
 
        if (*bytes && rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
-               if (!rtp_session->session) {
-                       rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ] = 0;
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
-               } else {
-                       const char *tx_host;
-                       const char *old_host;
-                       const char *my_host;
+               const char *tx_host;
+               const char *old_host;
+               const char *my_host;
 
-                       char bufa[30], bufb[30], bufc[30];
+               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);
+               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(rtp_session->session), SWITCH_LOG_CONSOLE,
-                                                         "R %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
-                                                         switch_channel_get_name(switch_core_session_get_channel(rtp_session->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);
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(rtp_session->session), SWITCH_LOG_CONSOLE,
+                                                 "R %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
+                                                 rtp_session->session ? switch_channel_get_name(switch_core_session_get_channel(rtp_session->session)) : "No-Name",
+                                                 (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);
 
-               }
        }
        
 
@@ -5750,31 +5740,26 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
                rtp_session->send_time = now;
 
                if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]) {
-                       if (!rtp_session->session) {
-                               rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE] = 0;
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
-                       } else {
-                               const char *tx_host;
-                               const char *old_host;
-                               const char *my_host;
+                       const char *tx_host;
+                       const char *old_host;
+                       const char *my_host;
 
-                               char bufa[30], bufb[30], bufc[30];
+                       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);
+                       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(rtp_session->session), SWITCH_LOG_CONSOLE,
-                                                                 "W %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
-                                                                 switch_channel_get_name(switch_core_session_get_channel(rtp_session->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);
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(rtp_session->session), SWITCH_LOG_CONSOLE,
+                                                         "W %s b=%4ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
+                                                         rtp_session->session ? switch_channel_get_name(switch_core_session_get_channel(rtp_session->session)) : "NoName",
+                                                         (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) {