update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / ui / cli / tap-rtp.c
blobab68ed7fc9f27f53359717f8f1eafbbe18495fd3
1 /* tap-rtp.c
2 * RTP TAP for tshark
4 * Copyright 2008, Ericsson AB
5 * By Balint Reczey <balint.reczey@ericsson.com>
7 * based on ui/gtk/rtp_stream_dlg.c
8 * Copyright 2003, Alcatel Business Systems
9 * By Lars Ruoff <lars.ruoff@gmx.net>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
19 * This TAP provides statistics for RTP streams
22 #include "config.h"
24 #include <stdlib.h>
25 #include <string.h>
26 #include <locale.h>
28 #include <glib.h>
30 #include <epan/packet_info.h>
31 #include <epan/value_string.h>
32 #include <epan/tap.h>
33 #include <epan/rtp_pt.h>
34 #include <epan/stat_tap_ui.h>
35 #include <epan/addr_resolv.h>
37 #include "ui/rtp_stream.h"
38 #include "ui/tap-rtp-common.h"
40 void register_tap_listener_rtpstreams(void);
41 static void rtpstreams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo);
43 /* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
45 static rtpstream_tapinfo_t the_tapinfo_struct =
46 { NULL, rtpstreams_stat_draw_cb, NULL,
47 NULL, 0, NULL, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, false, false
50 static void
51 rtpstreams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo _U_)
53 GList *list;
54 rtpstream_info_t *strinfo;
55 rtpstream_info_calc_t calc;
56 char *savelocale;
58 printf("========================= RTP Streams ========================\n");
59 printf("%13s %13s %15s %5s %15s %5s %10s %16s %5s %12s %15s %15s %15s %15s %15s %15s %s\n",
60 "Start time", "End time", "Src IP addr", "Port", "Dest IP addr", "Port", "SSRC", "Payload", "Pkts", "Lost",
61 "Min Delta(ms)", "Mean Delta(ms)", "Max Delta(ms)", "Min Jitter(ms)", "Mean Jitter(ms)", "Max Jitter(ms)", "Problems?");
63 /* save the current locale */
64 savelocale = g_strdup(setlocale(LC_NUMERIC, NULL));
65 /* switch to "C" locale to avoid problems with localized decimal separators
66 in snprintf("%f") functions */
67 setlocale(LC_NUMERIC, "C");
69 list = the_tapinfo_struct.strinfo_list;
71 list = g_list_first(list);
72 while (list)
74 strinfo = (rtpstream_info_t*)(list->data);
75 rtpstream_info_calculate(strinfo, &calc);
77 printf("%13.6f %13.6f %15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.3f %15.3f %15.3f %15.3f %15.3f %15.3f %s\n",
78 nstime_to_sec(&(strinfo->start_rel_time)),
79 nstime_to_sec(&(strinfo->stop_rel_time)),
80 calc.src_addr_str,
81 calc.src_port,
82 calc.dst_addr_str,
83 calc.dst_port,
84 calc.ssrc,
85 calc.all_payload_type_names,
86 calc.packet_count,
87 calc.lost_num,
88 calc.lost_perc,
89 calc.min_delta,
90 calc.mean_delta,
91 calc.max_delta,
92 calc.min_jitter,
93 calc.mean_jitter,
94 calc.max_jitter,
95 (calc.problem)?"X":"");
97 rtpstream_info_calc_free(&calc);
99 list = g_list_next(list);
102 printf("==============================================================\n");
103 /* restore previous locale setting */
104 setlocale(LC_NUMERIC, savelocale);
105 g_free(savelocale);
109 static void
110 rtpstreams_stat_init(const char *opt_arg _U_, void *userdata _U_)
112 register_tap_listener_rtpstream(&the_tapinfo_struct, NULL, NULL);
115 static stat_tap_ui rtpstreams_stat_ui = {
116 REGISTER_STAT_GROUP_GENERIC,
117 NULL,
118 "rtp,streams",
119 rtpstreams_stat_init,
121 NULL
124 void
125 register_tap_listener_rtpstreams(void)
127 register_stat_tap_ui(&rtpstreams_stat_ui, NULL);