3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef RTP_ANALYSIS_DIALOG_H
11 #define RTP_ANALYSIS_DIALOG_H
17 #include "epan/address.h"
19 #include "ui/rtp_stream.h"
20 #include "ui/tap-rtp-common.h"
21 #include "ui/tap-rtp-analysis.h"
24 #include <QTreeWidget>
28 #include <QHBoxLayout>
29 #include <QToolButton>
31 #include "wireshark_dialog.h"
34 class RtpAnalysisDialog
;
39 class QDialogButtonBox
;
45 rtpstream_info_t stream
;
46 QVector
<double> *time_vals
;
47 QVector
<double> *jitter_vals
;
48 QVector
<double> *diff_vals
;
49 QVector
<double> *delta_vals
;
50 QTreeWidget
*tree_widget
;
51 QLabel
*statistics_label
;
53 QCPGraph
*jitter_graph
;
55 QCPGraph
*delta_graph
;
56 QHBoxLayout
*graphHorizontalLayout
;
57 QCheckBox
*stream_checkbox
;
58 QCheckBox
*jitter_checkbox
;
59 QCheckBox
*diff_checkbox
;
60 QCheckBox
*delta_checkbox
;
63 // Singleton by https://refactoring.guru/design-patterns/singleton/cpp/example#example-1
64 class RtpAnalysisDialog
: public WiresharkDialog
72 static RtpAnalysisDialog
*openRtpAnalysisDialog(QWidget
&parent
, CaptureFile
&cf
, PacketList
*packet_list
);
75 * Should not be clonnable and assignable
77 RtpAnalysisDialog(RtpAnalysisDialog
&other
) = delete;
78 void operator=(const RtpAnalysisDialog
&) = delete;
81 * @brief Common routine to add a "Analyze" button to a QDialogButtonBox.
82 * @param button_box Caller's QDialogButtonBox.
83 * @return The new "Analyze" button.
85 static QToolButton
*addAnalyzeButton(QDialogButtonBox
*button_box
, RtpBaseDialog
*dialog
);
87 /** Replace/Add/Remove an RTP streams to analyse.
88 * Requires array of rtpstream_id_t.
90 * @param stream_ids structs with rtpstream_id
92 void replaceRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
93 void addRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
94 void removeRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
97 void goToPacket(int packet_num
);
98 void rtpPlayerDialogReplaceRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
99 void rtpPlayerDialogAddRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
100 void rtpPlayerDialogRemoveRtpStreams(QVector
<rtpstream_id_t
*> stream_ids
);
101 void updateFilter(QString filter
, bool force
= false);
104 void rtpPlayerReplace();
106 void rtpPlayerRemove();
109 virtual void updateWidgets();
112 explicit RtpAnalysisDialog(QWidget
&parent
, CaptureFile
&cf
);
113 ~RtpAnalysisDialog();
116 void on_actionGoToPacket_triggered();
117 void on_actionNextProblem_triggered();
118 void on_actionSaveOneCsv_triggered();
119 void on_actionSaveAllCsv_triggered();
120 void on_actionSaveGraph_triggered();
121 void on_buttonBox_helpRequested();
122 void showStreamMenu(QPoint pos
);
123 void showGraphMenu(const QPoint
&pos
);
124 void graphClicked(QMouseEvent
*event
);
125 void closeTab(int index
);
126 void rowCheckboxChanged(int checked
);
127 void singleCheckboxChanged(int checked
);
128 void on_actionPrepareFilterOne_triggered();
129 void on_actionPrepareFilterAll_triggered();
132 static RtpAnalysisDialog
*pinstance_
;
133 static std::mutex init_mutex_
;
134 static std::mutex run_mutex_
;
136 Ui::RtpAnalysisDialog
*ui
;
137 enum StreamDirection
{ dir_all_
, dir_one_
};
140 QVector
<tab_info_t
*> tabs_
;
141 QMultiHash
<unsigned, tab_info_t
*> tab_hash_
;
143 QToolButton
*player_button_
;
145 // Graph data for QCustomPlot
146 QList
<QCPGraph
*>graphs_
;
150 QMenu stream_ctx_menu_
;
151 QMenu graph_ctx_menu_
;
154 static void tapReset(void *tapinfo_ptr
);
155 static tap_packet_status
tapPacket(void *tapinfo_ptr
, packet_info
*pinfo
, epan_dissect_t
*, const void *rtpinfo_ptr
, tap_flags_t flags
);
156 static void tapDraw(void *tapinfo_ptr
);
158 void resetStatistics();
159 void addPacket(tab_info_t
*tab
, packet_info
*pinfo
, const struct _rtp_info
*rtpinfo
);
160 void updateStatistics();
163 void saveCsvHeader(QFile
*save_file
, QTreeWidget
*tree
);
164 void saveCsvData(QFile
*save_file
, QTreeWidget
*tree
);
165 void saveCsv(StreamDirection direction
);
167 bool eventFilter(QObject
*, QEvent
* event
);
169 QVector
<rtpstream_id_t
*>getSelectedRtpIds();
170 int addTabUI(tab_info_t
*new_tab
);
171 tab_info_t
*getTabInfoForCurrentTab();
172 void deleteTabInfo(tab_info_t
*tab_info
);
173 void clearLayout(QLayout
*layout
);
174 void addRtpStreamsPrivate(QVector
<rtpstream_id_t
*> stream_ids
);
177 #endif // RTP_ANALYSIS_DIALOG_H