RTP: If multiple codecs are used in RTP stream flow, all are shown in codecs column
[metze/wireshark/wip.git] / ui / tap-rtp-common.h
1 /* tap-rtp-common.h
2  * RTP streams handler functions used by tshark and wireshark
3  *
4  * Copyright 2008, Ericsson AB
5  * By Balint Reczey <balint.reczey@ericsson.com>
6  *
7  * most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analisys.c
8  * Copyright 2003, Alcatel Business Systems
9  * By Lars Ruoff <lars.ruoff@gmx.net>
10  *
11  * Wireshark - Network traffic analyzer
12  * By Gerald Combs <gerald@wireshark.org>
13  * Copyright 1998 Gerald Combs
14  *
15  * SPDX-License-Identifier: GPL-2.0-or-later
16  */
17
18 #ifndef __TAP_RTP_COMMON_H__
19 #define __TAP_RTP_COMMON_H__
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24
25 #include "ui/rtp_stream.h"
26
27 /* type of error when saving voice in a file didn't succeed */
28 typedef enum {
29     TAP_RTP_NO_ERROR,
30     TAP_RTP_WRONG_CODEC,
31     TAP_RTP_WRONG_LENGTH,
32     TAP_RTP_PADDING_ERROR,
33     TAP_RTP_SHORT_FRAME,
34     TAP_RTP_FILE_OPEN_ERROR,
35     TAP_RTP_FILE_WRITE_ERROR,
36     TAP_RTP_NO_DATA,
37 } tap_rtp_error_type_t;
38
39 typedef struct _tap_rtp_save_info_t {
40     FILE *fp;
41     guint32 count;
42     tap_rtp_error_type_t error_type;
43     gboolean saved;
44 } tap_rtp_save_info_t;
45
46 typedef struct _rtpstream_info_calc {
47     gchar *src_addr_str;
48     guint16 src_port;
49     gchar *dst_addr_str;
50     guint16 dst_port;
51     guint32 ssrc;
52     gchar *all_payload_type_names; /* Name of codec derived from fixed or dynamic codec names */
53     guint32 packet_count;
54     guint32 total_nr;
55     guint32 packet_expected; /* Count of expected packets, derived from lenght of RTP stream */
56     gint32 lost_num;
57     double lost_perc;
58     double max_delta;
59     double max_jitter;
60     double max_skew;
61     double mean_jitter;
62     gboolean problem; /* Indication that RTP stream contains something unusual -GUI should indicate it somehow */
63     double clock_drift_ms;
64     double freq_drift_hz;
65     double freq_drift_perc;
66     double duration_ms;
67     guint32 sequence_err;
68     double start_time_ms; /**< Unit is ms */
69     guint32 first_packet_num;
70     guint32 last_packet_num;
71 } rtpstream_info_calc_t;
72
73 /**
74  * Funcions for init and destroy of rtpstream_info_t and attached structures
75  */
76 void rtpstream_info_init(rtpstream_info_t* info);
77 rtpstream_info_t *rtpstream_info_malloc_and_init(void);
78 void rtpstream_info_copy_deep(rtpstream_info_t *dest, const rtpstream_info_t *src);
79 rtpstream_info_t *rtpstream_info_malloc_and_copy_deep(const rtpstream_info_t *src);
80 void rtpstream_info_free_data(rtpstream_info_t* info);
81 void rtpstream_info_free_all(rtpstream_info_t* info);
82
83 /**
84  * Compares two RTP stream infos (GCompareFunc style comparison function)
85  *
86  * @return -1,0,1
87  */
88 gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb);
89
90 /**
91 * Compares the endpoints of two RTP streams.
92 *
93 * @return TRUE if the
94 */
95 gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b);
96
97 /****************************************************************************/
98 /* INTERFACE */
99
100 /**
101 * Registers the rtp_streams tap listener (if not already done).
102 * From that point on, the RTP streams list will be updated with every redissection.
103 * This function is also the entry point for the initialization routine of the tap system.
104 * So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
105 * If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
106 */
107 void register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring, rtpstream_tap_error_cb tap_error);
108
109 /**
110 * Removes the rtp_streams tap listener (if not already done)
111 * From that point on, the RTP streams list won't be updated any more.
112 */
113 void remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo);
114
115 /**
116 * Cleans up memory of rtp streams tap.
117 */
118 void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
119
120 void rtpstream_reset_cb(void*);
121 void rtp_write_header(rtpstream_info_t*, FILE*);
122 int rtpstream_packet_cb(void*, packet_info*, epan_dissect_t *, const void *);
123
124 /**
125  * Evaluate rtpstream_info_t calculations
126  */
127 void rtpstream_info_calculate(const rtpstream_info_t *strinfo, rtpstream_info_calc_t *calc);
128
129 /**
130  * Free rtpstream_info_calc_t structure (internal items)
131  */
132 void rtpstream_info_calc_free(rtpstream_info_calc_t *calc);
133
134 #ifdef __cplusplus
135 }
136 #endif /* __cplusplus */
137
138 #endif /* __TAP_RTP_COMMON_H__ */
139
140 /*
141  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
142  *
143  * Local Variables:
144  * c-basic-offset: 4
145  * tab-width: 8
146  * indent-tabs-mode: nil
147  * End:
148  *
149  * ex: set shiftwidth=4 tabstop=8 expandtab:
150  * :indentSize=4:tabSize=8:noTabs=true:
151  */