From Xiao Xiangquan:
[obnox/wireshark/wip.git] / tap-rtp.c
index a911ace7bdf3bf30866b2c5670c2e148b71bf07a..2741ea84b7584a13dd0cdf6488254f7d920443a6 100644 (file)
--- a/tap-rtp.c
+++ b/tap-rtp.c
@@ -1,10 +1,12 @@
 /* tap-rtp.c
  * RTP TAP for tshark
- * 
+ *
+ * $Id$
+ *
  * Copyright 2008, Ericsson AB
  * By Balint Reczey <balint.reczey@ericsson.com>
  *
- * based on gtk/rtp_stream_dlg.c
+ * based on ui/gtk/rtp_stream_dlg.c
  * Copyright 2003, Alcatel Business Systems
  * By Lars Ruoff <lars.ruoff@gmx.net>
  *
 #include <epan/rtp_pt.h>
 #include <epan/stat_cmd_args.h>
 #include <epan/addr_resolv.h>
-#include "register.h"
 #include "tap-rtp-common.h"
 
-
+/* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
+ */
+static rtpstream_tapinfo_t the_tapinfo_struct =
+        {0, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, 0, FALSE};
 
 static void
 rtp_streams_stat_draw(void *arg _U_)
 {
-    
-    
+
+
     GList *list;
     rtp_stream_info_t* strinfo;
     gchar *payload_type;
@@ -66,24 +70,24 @@ rtp_streams_stat_draw(void *arg _U_)
     gint32 lost;
     double perc;
     char *savelocale;
-    
+
     printf("========================= RTP Streams ========================\n");
     printf("%15s %5s %15s %5s %10s %16s %5s %12s %15s %15s %15s %s\n","Src IP addr", "Port",  "Dest IP addr", "Port", "SSRC", "Payload", "Pkts", "Lost", "Max Delta(ms)", "Max Jitter(ms)", "Mean Jitter(ms)", "Problems?");
-    
+
     /* save the current locale */
     savelocale = setlocale(LC_NUMERIC, NULL);
     /* switch to "C" locale to avoid problems with localized decimal separators
        in g_snprintf("%f") functions */
     setlocale(LC_NUMERIC, "C");
-    
+
     list = the_tapinfo_struct.strinfo_list;
-    
+
     list = g_list_first(list);
     while (list)
     {
         strinfo = (rtp_stream_info_t*)(list->data);
 
-        // payload type
+        /* payload type */
         if(strinfo->pt>95){
        if(strinfo->info_payload_type_str != NULL){
             payload_type = g_strdup(strinfo->info_payload_type_str);
@@ -92,11 +96,11 @@ rtp_streams_stat_draw(void *arg _U_)
        }
 
         }else{
-           payload_type = g_strdup(val_to_str(strinfo->pt, rtp_payload_type_vals,
+           payload_type = g_strdup(val_to_str_ext(strinfo->pt, &rtp_payload_type_vals_ext,
                "Unknown (%u)"));
         }
-    
-        // packet count, lost packets
+
+        /* packet count, lost packets */
        expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536)
             - strinfo->rtp_stats.start_seq_nr + 1;
         lost = expected - strinfo->rtp_stats.total_nr;
@@ -105,7 +109,7 @@ rtp_streams_stat_draw(void *arg _U_)
         } else {
             perc = 0;
         }
-        
+
         printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n",
             get_addr_name(&(strinfo->src_addr)),
            strinfo->src_port,
@@ -115,11 +119,11 @@ rtp_streams_stat_draw(void *arg _U_)
            payload_type,
            strinfo->npackets,
            lost, perc,
-           strinfo->rtp_stats.max_delta*1000,
-           strinfo->rtp_stats.max_jitter*1000,
-           strinfo->rtp_stats.mean_jitter*1000,
+           strinfo->rtp_stats.max_delta,
+           strinfo->rtp_stats.max_jitter,
+           strinfo->rtp_stats.mean_jitter,
            (strinfo->problem)?"X":"");
-        
+
        list = g_list_next(list);
 
 
@@ -137,7 +141,7 @@ rtp_streams_stat_init(const char *optarg _U_, void* userdata _U_)
     GString            *err_p;
 
     err_p =
-       register_tap_listener("rtp", &the_tapinfo_struct, NULL,
+       register_tap_listener("rtp", &the_tapinfo_struct, NULL, 0,
            rtpstream_reset_cb,
            rtpstream_packet,
            rtp_streams_stat_draw);