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 graphClicked(QMouseEvent *event);
121  void closeTab(int index);
122  void rowCheckboxChanged(int checked);
123  void singleCheckboxChanged(int checked);
124  void on_actionPrepareFilterOne_triggered();
125  void on_actionPrepareFilterAll_triggered();
126 
127 private:
128  static RtpAnalysisDialog *pinstance_;
129  static std::mutex init_mutex_;
130  static std::mutex run_mutex_;
131 
132  Ui::RtpAnalysisDialog *ui;
133  enum StreamDirection { dir_all_, dir_one_ };
134  int tab_seq;
135 
136  QVector<tab_info_t *> tabs_;
137  QMultiHash<unsigned, tab_info_t *> tab_hash_;
138 
139  QToolButton *player_button_;
140 
141  // Graph data for QCustomPlot
142  QList<QCPGraph *>graphs_;
143 
144  QString err_str_;
145 
146  QMenu stream_ctx_menu_;
147  QMenu graph_ctx_menu_;
148 
149  // Tap callbacks
150  static void tapReset(void *tapinfo_ptr);
151  static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr, tap_flags_t flags);
152  static void tapDraw(void *tapinfo_ptr);
153 
154  void resetStatistics();
155  void addPacket(tab_info_t *tab, packet_info *pinfo, const struct _rtp_info *rtpinfo);
156  void updateStatistics();
157  void updateGraph();
158 
159  void saveCsvHeader(QFile *save_file, QTreeWidget *tree);
160  void saveCsvData(QFile *save_file, QTreeWidget *tree);
161  void saveCsv(StreamDirection direction);
162 
163  bool eventFilter(QObject*, QEvent* event);
164 
165  QVector<rtpstream_id_t *>getSelectedRtpIds();
166  int addTabUI(tab_info_t *new_tab);
167  tab_info_t *getTabInfoForCurrentTab();
168  void deleteTabInfo(tab_info_t *tab_info);
169  void clearLayout(QLayout *layout);
170  void addRtpStreamsPrivate(QVector<rtpstream_id_t *> stream_ids);
171 };
172 
173 #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:1138
RtpAnalysisDialog(RtpAnalysisDialog &other)=delete
void replaceRtpStreams(QVector< rtpstream_id_t * > stream_ids)
Definition: rtp_analysis_dialog.cpp:1032
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