/* rtp_analysis_dialog.h * * Wireshark - Network traffic analyzer * By Gerald Combs * Copyright 1998 Gerald Combs * * SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef RTP_ANALYSIS_DIALOG_H #define RTP_ANALYSIS_DIALOG_H #include #include #include #include "epan/address.h" #include "ui/rtp_stream.h" #include "ui/tap-rtp-common.h" #include "ui/tap-rtp-analysis.h" #include #include #include #include #include #include #include #include "wireshark_dialog.h" namespace Ui { class RtpAnalysisDialog; } class QCPGraph; class QTemporaryFile; class QDialogButtonBox; typedef struct { rtpstream_info_t stream; QVector *time_vals; QVector *jitter_vals; QVector *diff_vals; QVector *delta_vals; QTreeWidget *tree_widget; QLabel *statistics_label; QString *tab_name; QCPGraph *jitter_graph; QCPGraph *diff_graph; QCPGraph *delta_graph; QHBoxLayout *graphHorizontalLayout; QCheckBox *stream_checkbox; QCheckBox *jitter_checkbox; QCheckBox *diff_checkbox; QCheckBox *delta_checkbox; } tab_info_t; // Singleton by https://refactoring.guru/design-patterns/singleton/cpp/example#example-1 class RtpAnalysisDialog : public WiresharkDialog { Q_OBJECT public: /** * Returns singleton */ static RtpAnalysisDialog *openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list); /** * Should not be clonnable and assignable */ RtpAnalysisDialog(RtpAnalysisDialog &other) = delete; void operator=(const RtpAnalysisDialog &) = delete; /** * @brief Common routine to add a "Analyze" button to a QDialogButtonBox. * @param button_box Caller's QDialogButtonBox. * @return The new "Analyze" button. */ static QToolButton *addAnalyzeButton(QDialogButtonBox *button_box, QDialog *dialog); /** Replace/Add/Remove an RTP streams to analyse. * Requires array of rtpstream_id_t. * * @param stream_ids structs with rtpstream_id */ void replaceRtpStreams(QVector stream_ids); void addRtpStreams(QVector stream_ids); void removeRtpStreams(QVector stream_ids); signals: void goToPacket(int packet_num); void rtpPlayerDialogReplaceRtpStreams(QVector stream_ids); void rtpPlayerDialogAddRtpStreams(QVector stream_ids); void rtpPlayerDialogRemoveRtpStreams(QVector stream_ids); void updateFilter(QString filter, bool force = false); public slots: void rtpPlayerReplace(); void rtpPlayerAdd(); void rtpPlayerRemove(); protected slots: virtual void updateWidgets(); protected: explicit RtpAnalysisDialog(QWidget &parent, CaptureFile &cf); ~RtpAnalysisDialog(); private slots: void on_actionGoToPacket_triggered(); void on_actionNextProblem_triggered(); void on_actionSaveOneCsv_triggered(); void on_actionSaveAllCsv_triggered(); void on_actionSaveGraph_triggered(); void on_buttonBox_helpRequested(); void showStreamMenu(QPoint pos); void graphClicked(QMouseEvent *event); void closeTab(int index); void rowCheckboxChanged(int checked); void singleCheckboxChanged(int checked); void on_actionPrepareFilterOne_triggered(); void on_actionPrepareFilterAll_triggered(); private: static RtpAnalysisDialog *pinstance_; static std::mutex mutex_; Ui::RtpAnalysisDialog *ui; enum StreamDirection { dir_all_, dir_one_ }; int tab_seq; QVector tabs_; QMultiHash tab_hash_; QToolButton *player_button_; // Graph data for QCustomPlot QListgraphs_; QString err_str_; QMenu stream_ctx_menu_; QMenu graph_ctx_menu_; // Tap callbacks static void tapReset(void *tapinfo_ptr); static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr); static void tapDraw(void *tapinfo_ptr); void resetStatistics(); void addPacket(tab_info_t *tab, packet_info *pinfo, const struct _rtp_info *rtpinfo); void updateStatistics(); void updateGraph(); void saveCsvHeader(QFile *save_file, QTreeWidget *tree); void saveCsvData(QFile *save_file, QTreeWidget *tree); void saveCsv(StreamDirection direction); bool eventFilter(QObject*, QEvent* event); QVectorgetSelectedRtpIds(); int addTabUI(tab_info_t *new_tab); tab_info_t *getTabInfoForCurrentTab(); void deleteTabInfo(tab_info_t *tab_info); void clearLayout(QLayout *layout); void addRtpStreamsPrivate(QVector stream_ids); }; #endif // RTP_ANALYSIS_DIALOG_H