White space changes.
[obnox/wireshark/wip.git] / tap-rtp-common.c
index ddc553d5df39d215b456dadc86c41d60132ca672..206fd61db04733005520ddf6501f481ff743411b 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright 2008, Ericsson AB
  * By Balint Reczey <balint.reczey@ericsson.com>
  *
  * Copyright 2008, Ericsson AB
  * By Balint Reczey <balint.reczey@ericsson.com>
  *
- * most functions are copied from gtk/rtp_stream.c and gtk/rtp_analisys.c
+ * most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analisys.c
  * Copyright 2003, Alcatel Business Systems
  * By Lars Ruoff <lars.ruoff@gmx.net>
  *
  * Copyright 2003, Alcatel Business Systems
  * By Lars Ruoff <lars.ruoff@gmx.net>
  *
 #include "globals.h"
 
 #include <epan/tap.h>
 #include "globals.h"
 
 #include <epan/tap.h>
-#include "register.h"
 #include <string.h>
 #include <epan/rtp_pt.h>
 #include <epan/addr_resolv.h>
 #include <epan/dissectors/packet-rtp.h>
 #include <string.h>
 #include <epan/rtp_pt.h>
 #include <epan/addr_resolv.h>
 #include <epan/dissectors/packet-rtp.h>
-#include "gtk/rtp_stream.h"
+#include "ui/gtk/rtp_stream.h"
 #include "tap-rtp-common.h"
 
 #include "tap-rtp-common.h"
 
-
+/* XXX: are changes needed to properly handle situations where
+        info_all_data_present == FALSE ?
+        E.G., when captured frames are truncated.
+ */
 
 /****************************************************************************/
 /* GCompareFunc style comparison function for _rtp_stream_info */
 
 /****************************************************************************/
 /* GCompareFunc style comparison function for _rtp_stream_info */
@@ -295,9 +297,7 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con
                        rtp_write_sample(&sample, tapinfo->save_file);
                }
        }
                        rtp_write_sample(&sample, tapinfo->save_file);
                }
        }
-       /* TODO: This doesn't belong here. We really shouldn't refer to cf_mark_frame()
-        * which only make sense if we're using the GTK UI backend. This effectively forces
-        * tshark/rawshark to implement a cf_mark_frame() stub */
+#ifdef __GTK_H__
        else if (tapinfo->mode == TAP_MARK) {
                if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0
                        || rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_rev)==0)
        else if (tapinfo->mode == TAP_MARK) {
                if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0
                        || rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_rev)==0)
@@ -305,7 +305,7 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con
                        cf_mark_frame(&cfile, pinfo->fd);
                }
        }
                        cf_mark_frame(&cfile, pinfo->fd);
                }
        }
-
+#endif
        return 0;
 }
 
        return 0;
 }
 
@@ -459,6 +459,7 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
                statinfo->timestamp = rtpinfo->info_timestamp;
                statinfo->first_timestamp = rtpinfo->info_timestamp;
                statinfo->time = current_time;
                statinfo->timestamp = rtpinfo->info_timestamp;
                statinfo->first_timestamp = rtpinfo->info_timestamp;
                statinfo->time = current_time;
+               statinfo->lastnominaltime = 0;
                statinfo->pt = rtpinfo->info_payload_type;
                statinfo->reg_pt = rtpinfo->info_payload_type;
                statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
                statinfo->pt = rtpinfo->info_payload_type;
                statinfo->reg_pt = rtpinfo->info_payload_type;
                statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
@@ -570,7 +571,11 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
                                clock_rate = 0;
                                statinfo->flags |= STAT_FLAG_PT_T_EVENT;
                        }else{
                                clock_rate = 0;
                                statinfo->flags |= STAT_FLAG_PT_T_EVENT;
                        }else{
-                               clock_rate = get_dyn_pt_clock_rate(rtpinfo-> info_payload_type_str);
+                               if(rtpinfo->info_payload_rate !=0){
+                                       clock_rate = rtpinfo->info_payload_rate;
+                               }else{
+                                       clock_rate = get_dyn_pt_clock_rate(rtpinfo-> info_payload_type_str);
+                               }
                        }
                }else{
                        clock_rate = 0;
                        }
                }else{
                        clock_rate = 0;
@@ -631,8 +636,8 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
                statinfo->sumtTS += 1.0 * current_time * nominaltime;
        }
 
                statinfo->sumtTS += 1.0 * current_time * nominaltime;
        }
 
-       /* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> 20bytes(IP)+8bytes(UDP) = 28bytes */
-       statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
+       /* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> IP header+8bytes(UDP) */
+       statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + pinfo->iphdrlen + 8;
        statinfo->bw_history[statinfo->bw_index].time = current_time;
 
        /* Check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */
        statinfo->bw_history[statinfo->bw_index].time = current_time;
 
        /* Check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */
@@ -641,7 +646,8 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
                statinfo->bw_start_index++;
                if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index=0;
        };
                statinfo->bw_start_index++;
                if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index=0;
        };
-       statinfo->total_bytes += rtpinfo->info_data_len + 28;
+       /* IP hdr + UDP + RTP */
+       statinfo->total_bytes += rtpinfo->info_data_len + pinfo->iphdrlen + 8;
        statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
        statinfo->bw_index++;
        if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0;
        statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
        statinfo->bw_index++;
        if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0;