replace *a lot* of file related calls by their GLib counterparts. This is necessary...
[obnox/wireshark/wip.git] / gtk / rtp_stream.c
index feb1f1bbf2ebfdf683e5da502d3f83a4fdb5eb1c..75b82fc65f1439542d20022239d7b14ffee505fd 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "alert_box.h"
 #include "simple_dialog.h"
+#include "file_util.h"
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -62,7 +63,7 @@ static rtpstream_tapinfo_t the_tapinfo_struct =
 
 /****************************************************************************/
 /* GCompareFunc style comparison function for _rtp_stream_info */
-gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
+static gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
 {
        const struct _rtp_stream_info* a = aa;
        const struct _rtp_stream_info* b = bb;
@@ -114,7 +115,7 @@ static void rtpstream_reset_cb(void *arg)
 
 /****************************************************************************/
 /* redraw the output */
-void rtpstream_draw(void *arg _U_)
+static void rtpstream_draw(void *arg _U_)
 {
 /* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
        gtk_signal_emit_by_name(top_level, "signal_rtpstream_update");
@@ -229,10 +230,10 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _
                if (!strinfo) {
                        tmp_strinfo.npackets = 0;
                        tmp_strinfo.first_frame_num = pinfo->fd->num;
-                       tmp_strinfo.start_sec = pinfo->fd->abs_secs;
-                       tmp_strinfo.start_usec = pinfo->fd->abs_usecs;
-                       tmp_strinfo.start_rel_sec = pinfo->fd->rel_secs;
-                       tmp_strinfo.start_rel_usec = pinfo->fd->rel_usecs;
+                       tmp_strinfo.start_sec = pinfo->fd->abs_ts.secs;
+                       tmp_strinfo.start_usec = pinfo->fd->abs_ts.nsecs/1000;
+                       tmp_strinfo.start_rel_sec = pinfo->fd->rel_ts.secs;
+                       tmp_strinfo.start_rel_usec = pinfo->fd->rel_ts.nsecs/1000;
                        tmp_strinfo.tag_vlan_error = 0;
                        tmp_strinfo.tag_diffserv_error = 0;
                        tmp_strinfo.vlan_id = 0;
@@ -283,8 +284,8 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _
 
                /* increment the packets counter for this stream */
                ++(strinfo->npackets);
-               strinfo->stop_rel_sec = pinfo->fd->rel_secs;
-               strinfo->stop_rel_usec = pinfo->fd->rel_usecs;
+               strinfo->stop_rel_sec = pinfo->fd->rel_ts.secs;
+               strinfo->stop_rel_usec = pinfo->fd->rel_ts.nsecs/1000;
 
                /* increment the packets counter of all streams */
                ++(tapinfo->npackets);
@@ -296,8 +297,8 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _
                        /* XXX - what if rtpinfo->info_all_data_present is
                           FALSE, so that we don't *have* all the data? */
                        sample.header.rec_time = 
-                               (pinfo->fd->abs_usecs + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000
-                               + (pinfo->fd->abs_secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000;
+                               (pinfo->fd->abs_ts.nsecs/1000 + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000
+                               + (pinfo->fd->abs_ts.secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000;
                        sample.header.frame_length = rtpinfo->info_data_len;
                        sample.frame = rtpinfo->info_data;
                        rtp_write_sample(&sample, tapinfo->save_file);
@@ -324,7 +325,7 @@ void rtpstream_scan(void)
                register_tap_listener_rtp_stream();
 
        the_tapinfo_struct.mode = TAP_ANALYSE;
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
 
        if (!was_registered)
                remove_tap_listener_rtp_stream();
@@ -337,7 +338,7 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
 {
        gboolean was_registered = the_tapinfo_struct.is_registered;
        /* open file for saving */
-       the_tapinfo_struct.save_file = fopen(filename, "wb");
+       the_tapinfo_struct.save_file = eth_fopen(filename, "wb");
        if (the_tapinfo_struct.save_file==NULL) {
                open_failure_alert_box(filename, errno, TRUE);
                return FALSE;
@@ -355,7 +356,7 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
 
        the_tapinfo_struct.mode = TAP_SAVE;
        the_tapinfo_struct.filter_stream_fwd = stream;
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
        the_tapinfo_struct.mode = TAP_ANALYSE;
 
        if (!was_registered)
@@ -386,7 +387,7 @@ void rtpstream_mark(rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev
        the_tapinfo_struct.mode = TAP_MARK;
        the_tapinfo_struct.filter_stream_fwd = stream_fwd;
        the_tapinfo_struct.filter_stream_rev = stream_rev;
-       cf_retap_packets(&cfile);
+       cf_retap_packets(&cfile, FALSE);
        the_tapinfo_struct.mode = TAP_ANALYSE;
 
        if (!was_registered)
@@ -405,14 +406,6 @@ const rtpstream_tapinfo_t* rtpstream_get_info(void)
 /* TAP INTERFACE */
 /****************************************************************************/
 
-/****************************************************************************/
-static void
-rtpstream_init_tap(char *dummy _U_)
-{
-       /* XXX: never called? */
-}
-
-
 /* XXX just copied from gtk/rpc_stat.c */
 void protect_thread_critical_region(void);
 void unprotect_thread_critical_region(void);
@@ -438,8 +431,6 @@ register_tap_listener_rtp_stream(void)
        GString *error_string;
 
        if (!the_tapinfo_struct.is_registered) {
-               register_ethereal_tap("rtp", rtpstream_init_tap);
-
                error_string = register_tap_listener("rtp", &the_tapinfo_struct,
                        NULL, rtpstream_reset_cb, rtpstream_packet,
                        rtpstream_draw);