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
30 #include <epan/packet_info.h>
31 #include <epan/value_string.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
51 rtpstreams_stat_draw_cb(rtpstream_tapinfo_t
*tapinfo _U_
)
54 rtpstream_info_t
*strinfo
;
55 rtpstream_info_calc_t calc
;
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
);
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
)),
85 calc
.all_payload_type_names
,
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
);
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
,
119 rtpstreams_stat_init
,
125 register_tap_listener_rtpstreams(void)
127 register_stat_tap_ui(&rtpstreams_stat_ui
, NULL
);