some more : try to make read/write not break the build if the return value is not...
[obnox/wireshark/wip.git] / gtk / rtp_stream.h
1 /* rtp_stream.h
2  * RTP streams summary addition for Wireshark
3  *
4  * $Id$
5  *
6  * Copyright 2003, Alcatel Business Systems
7  * By Lars Ruoff <lars.ruoff@gmx.net>
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation,  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifndef RTP_STREAM_H_INCLUDED
29 #define RTP_STREAM_H_INCLUDED
30
31 #include "rtp_analysis.h"
32 #include <glib.h>
33 #include <stdio.h>
34 #include <epan/address.h>
35
36 /** @file
37  *  ??? 
38  *  @ingroup dialog_group
39  *  @todo what's this?
40  */
41
42 /****************************************************************************/
43 /* type for storing rtp frame information */
44 typedef struct st_rtp_sample_header {
45         guint32 rec_time;       /* miliseconds since start of recording */
46         guint16 frame_length;   /* number of bytes in *frame */
47 } rtp_sample_header_t;
48
49 /* type for storing rtp frame information */
50 typedef struct st_rtp_sample {
51         rtp_sample_header_t header;  /* date and size */
52         const guint8 *frame;                 /* data bytes */
53 } rtp_sample_t;
54
55 typedef rtp_sample_t* rtp_sample_p;
56
57
58 /* defines an rtp stream */
59 typedef struct _rtp_stream_info {
60         address src_addr;
61         guint16 src_port;
62         address dest_addr;
63         guint16 dest_port;
64         guint32 ssrc;
65         guint8  pt;
66         gchar   *info_payload_type_str;
67         guint32 npackets;
68
69         guint32 first_frame_num; /* frame number of first frame */
70         guint32 setup_frame_number; /* frame number of setup message */
71         /* start of recording (GMT) of this stream */
72     guint32 start_sec;         /* seconds */
73     guint32 start_usec;        /* microseconds */
74         gboolean tag_vlan_error;
75         guint32 start_rel_sec;         /* start stream rel seconds */
76         guint32 start_rel_usec;        /* start stream rel microseconds */
77         guint32 stop_rel_sec;         /* stop stream rel seconds */
78         guint32 stop_rel_usec;        /* stop stream rel microseconds */
79         gboolean tag_diffserv_error;
80         guint16 vlan_id;
81
82         tap_rtp_stat_t rtp_stats;  /* here goes the RTP statistics info */
83         gboolean problem; /* if the streams had wrong sequence numbers or wrong timerstamps */
84 } rtp_stream_info_t;
85
86
87 /* tapping modes */
88 typedef enum
89 {
90   TAP_ANALYSE,
91   TAP_SAVE,
92   TAP_MARK
93 } tap_mode_t;
94
95
96 /* structure that holds the information about all detected streams */
97 /* struct holding all information of the tap */
98 typedef struct _rtpstream_tapinfo {
99         int     nstreams;       /* number of streams in the list */
100         GList*  strinfo_list;   /* list with all streams */
101         int     npackets;       /* total number of rtp packets of all streams */
102         /* used while tapping. user shouldnt modify these */
103         tap_mode_t mode;
104         rtp_stream_info_t* filter_stream_fwd;  /* used as filter in some tap modes */
105         rtp_stream_info_t* filter_stream_rev;  /* used as filter in some tap modes */
106         FILE*   save_file;
107         guint32 launch_count;   /* number of times the tap has been run */
108         gboolean is_registered; /* if the tap listener is currently registered or not */
109 } rtpstream_tapinfo_t;
110
111 /****************************************************************************/
112 /* INTERFACE */
113
114 /*
115 * Registers the rtp_streams tap listener (if not already done).
116 * From that point on, the RTP streams list will be updated with every redissection.
117 * This function is also the entry point for the initialization routine of the tap system.
118 * So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
119 * If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
120 */
121 void register_tap_listener_rtp_stream(void);
122
123 /*
124 * Removes the rtp_streams tap listener (if not already done)
125 * From that point on, the RTP streams list won't be updated any more.
126 */
127 void remove_tap_listener_rtp_stream(void);
128
129 /*
130 * Retrieves a constant reference to the unique info structure of the rtp_streams tap listener.
131 * The user should not modify the data pointed to.
132 */
133 const rtpstream_tapinfo_t* rtpstream_get_info(void);
134
135 /*
136 * Cleans up memory of rtp streams tap.
137 */
138 void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
139
140 /*
141 * Scans all packets for RTP streams and updates the RTP streams list.
142 * (redissects all packets)
143 */
144 void rtpstream_scan(void);
145
146 /*
147 * Saves an RTP stream as raw data stream with timestamp information for later RTP playback.
148 * (redissects all packets)
149 */
150 gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename);
151
152 /*
153 * Marks all packets belonging to either of stream_fwd or stream_rev.
154 * (both can be NULL)
155 * (redissects all packets)
156 */
157 void rtpstream_mark(rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev);
158
159
160 #endif /*RTP_STREAM_H_INCLUDED*/