Wireshark  4.3.0
The Wireshark network protocol analyzer
rtp_analysis_dialog.h
Go to the documentation of this file.
1 
10 #ifndef RTP_ANALYSIS_DIALOG_H
11 #define RTP_ANALYSIS_DIALOG_H
12 
13 #include <config.h>
14 
15 #include <mutex>
16 
17 #include "epan/address.h"
18 
19 #include "ui/rtp_stream.h"
20 #include "ui/tap-rtp-common.h"
21 #include "ui/tap-rtp-analysis.h"
22 
23 #include <QMenu>
24 #include <QTreeWidget>
25 #include <QLabel>
26 #include <QFile>
27 #include <QCheckBox>
28 #include <QHBoxLayout>
29 #include <QToolButton>
30 
31 #include "wireshark_dialog.h"
32 
33 namespace Ui {
34 class RtpAnalysisDialog;
35 }
36 
37 class QCPGraph;
38 class QTemporaryFile;
39 class QDialogButtonBox;
40 
41 typedef struct {
43  QVector<double> *time_vals;
44  QVector<double> *jitter_vals;
45  QVector<double> *diff_vals;
46  QVector<double> *delta_vals;
47  QTreeWidget *tree_widget;
48  QLabel *statistics_label;
49  QString *tab_name;
50  QCPGraph *jitter_graph;
51  QCPGraph *diff_graph;
52  QCPGraph *delta_graph;
53  QHBoxLayout *graphHorizontalLayout;
54  QCheckBox *stream_checkbox;
55  QCheckBox *jitter_checkbox;
56  QCheckBox *diff_checkbox;
57  QCheckBox *delta_checkbox;
58 } tab_info_t;
59 
60 // Singleton by https://refactoring.guru/design-patterns/singleton/cpp/example#example-1
62 {
63  Q_OBJECT
64 
65 public:
69  static RtpAnalysisDialog *openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list);
70 
75  void operator=(const RtpAnalysisDialog &) = delete;
76 
82  static QToolButton *addAnalyzeButton(QDialogButtonBox *button_box, QDialog *dialog);
83 
89  void replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
90  void addRtpStreams(QVector<rtpstream_id_t *> stream_ids);
91  void removeRtpStreams(QVector<rtpstream_id_t *> stream_ids);
92 
93 signals:
94  void goToPacket(int packet_num);
95  void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
96  void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
97  void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
98  void updateFilter(QString filter, bool force = false);
99 
100 public slots:
101  void rtpPlayerReplace();
102  void rtpPlayerAdd();
103  void rtpPlayerRemove();
104 
105 protected slots:
106  virtual void updateWidgets();
107 
108 protected:
109  explicit RtpAnalysisDialog(QWidget &parent, CaptureFile &cf);
111 
112 private slots:
113  void on_actionGoToPacket_triggered();
114  void on_actionNextProblem_triggered();
115  void on_actionSaveOneCsv_triggered();
116  void on_actionSaveAllCsv_triggered();
117  void on_actionSaveGraph_triggered();
118  void on_buttonBox_helpRequested();
119  void showStreamMenu(QPoint pos);
120  void showGraphMenu(const QPoint &pos);
121  void graphClicked(QMouseEvent *event);
122  void closeTab(int index);
123  void rowCheckboxChanged(int checked);
124  void singleCheckboxChanged(int checked);
125  void on_actionPrepareFilterOne_triggered();
126  void on_actionPrepareFilterAll_triggered();
127 
128 private:
129  static RtpAnalysisDialog *pinstance_;
130  static std::mutex init_mutex_;
131  static std::mutex run_mutex_;
132 
133  Ui::RtpAnalysisDialog *ui;
134  enum StreamDirection { dir_all_, dir_one_ };
135  int tab_seq;
136 
137  QVector<tab_info_t *> tabs_;
138  QMultiHash<unsigned, tab_info_t *> tab_hash_;
139 
140  QToolButton *player_button_;
141 
142  // Graph data for QCustomPlot
143  QList<QCPGraph *>graphs_;
144 
145  QString err_str_;
146 
147  QMenu stream_ctx_menu_;
148  QMenu graph_ctx_menu_;
149 
150  // Tap callbacks
151  static void tapReset(void *tapinfo_ptr);
152  static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr, tap_flags_t flags);
153  static void tapDraw(void *tapinfo_ptr);
154 
155  void resetStatistics();
156  void addPacket(tab_info_t *tab, packet_info *pinfo, const struct _rtp_info *rtpinfo);
157  void updateStatistics();
158  void updateGraph();
159 
160  void saveCsvHeader(QFile *save_file, QTreeWidget *tree);
161  void saveCsvData(QFile *save_file, QTreeWidget *tree);
162  void saveCsv(StreamDirection direction);
163 
164  bool eventFilter(QObject*, QEvent* event);
165 
166  QVector<rtpstream_id_t *>getSelectedRtpIds();
167  int addTabUI(tab_info_t *new_tab);
168  tab_info_t *getTabInfoForCurrentTab();
169  void deleteTabInfo(tab_info_t *tab_info);
170  void clearLayout(QLayout *layout);
171  void addRtpStreamsPrivate(QVector<rtpstream_id_t *> stream_ids);
172 };
173 
174 #endif // RTP_ANALYSIS_DIALOG_H
Definition: capture_file.h:21
Definition: rtp_analysis_dialog.h:62
static RtpAnalysisDialog * openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list)
Definition: rtp_analysis_dialog.cpp:246
static QToolButton * addAnalyzeButton(QDialogButtonBox *button_box, QDialog *dialog)
Common routine to add a "Analyze" button to a QDialogButtonBox.
Definition: rtp_analysis_dialog.cpp:1140
RtpAnalysisDialog(RtpAnalysisDialog &other)=delete
void replaceRtpStreams(QVector< rtpstream_id_t * > stream_ids)
Definition: rtp_analysis_dialog.cpp:1034
Definition: wireshark_dialog.h:35
Definition: packet_info.h:44
Definition: packet-rtp.h:29
Definition: rtp_stream.h:40
Definition: epan_dissect.h:28
Definition: stream.c:41
Definition: rtp_analysis_dialog.h:41
tap_packet_status
Definition: tap.h:25