TODO netlogon_user_flags_ntlmv2_enabled
[wireshark-sm.git] / ui / qt / rtp_analysis_dialog.h
bloba84278747ad92524790dde1cccc5a9ff1a2d75ad
1 /** @file
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
8 */
10 #ifndef RTP_ANALYSIS_DIALOG_H
11 #define RTP_ANALYSIS_DIALOG_H
13 #include <config.h>
15 #include <mutex>
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"
23 #include <QMenu>
24 #include <QTreeWidget>
25 #include <QLabel>
26 #include <QFile>
27 #include <QCheckBox>
28 #include <QHBoxLayout>
29 #include <QToolButton>
31 #include "wireshark_dialog.h"
33 namespace Ui {
34 class RtpAnalysisDialog;
37 class QCPGraph;
38 class QTemporaryFile;
39 class QDialogButtonBox;
41 class PacketList;
42 class RtpBaseDialog;
44 typedef struct {
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;
52 QString *tab_name;
53 QCPGraph *jitter_graph;
54 QCPGraph *diff_graph;
55 QCPGraph *delta_graph;
56 QHBoxLayout *graphHorizontalLayout;
57 QCheckBox *stream_checkbox;
58 QCheckBox *jitter_checkbox;
59 QCheckBox *diff_checkbox;
60 QCheckBox *delta_checkbox;
61 } tab_info_t;
63 // Singleton by https://refactoring.guru/design-patterns/singleton/cpp/example#example-1
64 class RtpAnalysisDialog : public WiresharkDialog
66 Q_OBJECT
68 public:
69 /**
70 * Returns singleton
72 static RtpAnalysisDialog *openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, PacketList *packet_list);
74 /**
75 * Should not be clonnable and assignable
77 RtpAnalysisDialog(RtpAnalysisDialog &other) = delete;
78 void operator=(const RtpAnalysisDialog &) = delete;
80 /**
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);
96 signals:
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);
103 public slots:
104 void rtpPlayerReplace();
105 void rtpPlayerAdd();
106 void rtpPlayerRemove();
108 protected slots:
109 virtual void updateWidgets();
111 protected:
112 explicit RtpAnalysisDialog(QWidget &parent, CaptureFile &cf);
113 ~RtpAnalysisDialog();
115 private slots:
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();
131 private:
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_ };
138 int tab_seq;
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_;
148 QString err_str_;
150 QMenu stream_ctx_menu_;
151 QMenu graph_ctx_menu_;
153 // Tap callbacks
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();
161 void updateGraph();
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