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 <glib.h>
16 #include <mutex>
17 
18 #include "epan/address.h"
19 
20 #include "ui/rtp_stream.h"
21 #include "ui/tap-rtp-common.h"
22 #include "ui/tap-rtp-analysis.h"
23 
24 #include <QMenu>
25 #include <QTreeWidget>
26 #include <QLabel>
27 #include <QFile>
28 #include <QCheckBox>
29 #include <QHBoxLayout>
30 #include <QToolButton>
31 
32 #include "wireshark_dialog.h"
33 
34 namespace Ui {
35 class RtpAnalysisDialog;
36 }
37 
38 class QCPGraph;
39 class QTemporaryFile;
40 class QDialogButtonBox;
41 
42 typedef struct {
44  QVector<double> *time_vals;
45  QVector<double> *jitter_vals;
46  QVector<double> *diff_vals;
47  QVector<double> *delta_vals;
48  QTreeWidget *tree_widget;
49  QLabel *statistics_label;
50  QString *tab_name;
51  QCPGraph *jitter_graph;
52  QCPGraph *diff_graph;
53  QCPGraph *delta_graph;
54  QHBoxLayout *graphHorizontalLayout;
55  QCheckBox *stream_checkbox;
56  QCheckBox *jitter_checkbox;
57  QCheckBox *diff_checkbox;
58  QCheckBox *delta_checkbox;
59 } tab_info_t;
60 
61 // Singleton by https://refactoring.guru/design-patterns/singleton/cpp/example#example-1
63 {
64  Q_OBJECT
65 
66 public:
70  static RtpAnalysisDialog *openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list);
71 
76  void operator=(const RtpAnalysisDialog &) = delete;
77 
83  static QToolButton *addAnalyzeButton(QDialogButtonBox *button_box, QDialog *dialog);
84 
90  void replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
91  void addRtpStreams(QVector<rtpstream_id_t *> stream_ids);
92  void removeRtpStreams(QVector<rtpstream_id_t *> stream_ids);
93 
94 signals:
95  void goToPacket(int packet_num);
96  void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
97  void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
98  void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
99  void updateFilter(QString filter, bool force = false);
100 
101 public slots:
102  void rtpPlayerReplace();
103  void rtpPlayerAdd();
104  void rtpPlayerRemove();
105 
106 protected slots:
107  virtual void updateWidgets();
108 
109 protected:
110  explicit RtpAnalysisDialog(QWidget &parent, CaptureFile &cf);
112 
113 private slots:
114  void on_actionGoToPacket_triggered();
115  void on_actionNextProblem_triggered();
116  void on_actionSaveOneCsv_triggered();
117  void on_actionSaveAllCsv_triggered();
118  void on_actionSaveGraph_triggered();
119  void on_buttonBox_helpRequested();
120  void showStreamMenu(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<guint, 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:23
Definition: rtp_analysis_dialog.h:63
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:42
tap_packet_status
Definition: tap.h:25