more
[metze/wireshark/wip.git] / ui / rtp_stream.h
1 /* rtp_stream.h
2  * RTP streams summary addition for Wireshark
3  *
4  * Copyright 2003, Alcatel Business Systems
5  * By Lars Ruoff <lars.ruoff@gmx.net>
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * SPDX-License-Identifier: GPL-2.0-or-later
12  */
13
14 #ifndef __RTP_STREAM_H__
15 #define __RTP_STREAM_H__
16
17 /** @file
18  *  "RTP Streams" dialog box common routines.
19  *  @ingroup main_ui_group
20  */
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25
26 #include "tap-rtp-analysis.h"
27 #include <glib.h>
28 #include <stdio.h>
29
30 #include "cfile.h"
31
32 #include <epan/address.h>
33 #include <epan/tap.h>
34
35 #include "ui/rtp_stream_id.h"
36
37 /** Defines an rtp stream */
38 typedef struct _rtpstream_info {
39     rtpstream_id_t  id;
40
41     guint8          first_payload_type; /**< Numeric payload type */
42     const gchar    *first_payload_type_name; /**< Payload type name */
43     const gchar    *payload_type_names[256]; /**< Seen payload type names. Array index is payload type (byte), filled only during TAP_ANALYSE */
44     gchar          *all_payload_type_names; /**< All seen payload names for a stream in one string */
45
46     gboolean        is_srtp;
47     guint32         packet_count;
48     gboolean        end_stream; /**< Used to track streams across payload types */
49     int             rtp_event;
50
51     int             call_num; /**< Used to match call_num in voip_calls_info_t */
52     guint32         setup_frame_number; /**< frame number of setup message */
53     /* Start and stop packets needed for .num and .abs_ts */
54     frame_data     *start_fd;
55     frame_data     *stop_fd;
56     nstime_t        start_rel_time;     /**< relative start time from pinfo */
57     nstime_t        stop_rel_time;      /**< relative stop time from pinfo */
58     guint16         vlan_id;
59     gboolean        tag_vlan_error;
60     gboolean        tag_diffserv_error;
61
62     tap_rtp_stat_t  rtp_stats;  /**< here goes the RTP statistics info */
63     gboolean        problem;    /**< if the streams had wrong sequence numbers or wrong timestamps */
64     const gchar    *ed137_info; /** pointer to static text, no freeing is required */
65 } rtpstream_info_t;
66
67 /** tapping modes */
68 typedef enum
69 {
70     TAP_ANALYSE,
71     TAP_SAVE,
72     TAP_MARK
73 } tap_mode_t;
74
75 typedef struct _rtpstream_tapinfo rtpstream_tapinfo_t;
76
77 typedef void (*rtpstream_tap_reset_cb)(rtpstream_tapinfo_t *tapinfo);
78 typedef void (*rtpstream_tap_draw_cb)(rtpstream_tapinfo_t *tapinfo);
79 typedef void (*tap_mark_packet_cb)(rtpstream_tapinfo_t *tapinfo, frame_data *fd);
80 typedef void (*rtpstream_tap_error_cb)(GString *error_string);
81
82 /* structure that holds the information about all detected streams */
83 /** struct holding all information of the tap */
84 struct _rtpstream_tapinfo {
85     rtpstream_tap_reset_cb tap_reset;       /**< tap reset callback */
86     rtpstream_tap_draw_cb tap_draw;         /**< tap draw callback */
87     tap_mark_packet_cb tap_mark_packet;     /**< packet marking callback */
88     void              *tap_data;            /**< data for tap callbacks */
89     int                nstreams; /**< number of streams in the list */
90     GList             *strinfo_list; /**< list of rtpstream_info_t* */
91     int                npackets; /**< total number of rtp packets of all streams */
92     /* used while tapping. user shouldn't modify these */
93     tap_mode_t         mode;
94     rtpstream_info_t  *filter_stream_fwd; /**< used as filter in some tap modes */
95     rtpstream_info_t  *filter_stream_rev; /**< used as filter in some tap modes */
96     FILE              *save_file;
97     gboolean           is_registered; /**< if the tap listener is currently registered or not */
98 };
99
100 #if 0
101 #define RTP_STREAM_DEBUG(...) { \
102     char *RTP_STREAM_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
103     g_warning("rtp_stream: %s:%d %s", G_STRFUNC, __LINE__, RTP_STREAM_DEBUG_MSG); \
104     g_free(RTP_STREAM_DEBUG_MSG); \
105 }
106 #else
107 #define RTP_STREAM_DEBUG(...)
108 #endif
109
110 /****************************************************************************/
111 /* INTERFACE */
112
113 void show_tap_registration_error(GString *error_string);
114
115 /**
116 * Scans all packets for RTP streams and updates the RTP streams list.
117 * (redissects all packets)
118 */
119 void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring);
120
121 /**
122 * Saves an RTP stream as raw data stream with timestamp information for later RTP playback.
123 * (redissects all packets)
124 */
125 gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream, const gchar *filename);
126
127 /**
128 * Marks all packets belonging to either of stream_fwd or stream_rev.
129 * (both can be NULL)
130 * (redissects all packets)
131 */
132 void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream_fwd, rtpstream_info_t* stream_rev);
133
134 #define MAX_SILENCE_FRAMES 14400000
135
136 #ifdef __cplusplus
137 }
138 #endif /* __cplusplus */
139
140 #endif /* __RTP_STREAM_H__ */
141
142 /*
143  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
144  *
145  * Local variables:
146  * c-basic-offset: 4
147  * tab-width: 8
148  * indent-tabs-mode: nil
149  * End:
150  *
151  * vi: set shiftwidth=4 tabstop=8 expandtab:
152  * :indentSize=4:tabSize=8:noTabs=true:
153  */