Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
rtp_analysis_dialog.h
1 /* rtp_analysis_dialog.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef RTP_ANALYSIS_DIALOG_H
11 #define RTP_ANALYSIS_DIALOG_H
12 
13 #include <config.h>
14 
15 #include <glib.h>
16 
17 #include "epan/address.h"
18 
19 #include "ui/rtp_stream.h"
20 #include "ui/tap-rtp-analysis.h"
21 
22 #include <QAbstractButton>
23 #include <QMenu>
24 #include <QFile>
25 
26 #include "wireshark_dialog.h"
27 
28 namespace Ui {
29 class RtpAnalysisDialog;
30 }
31 
32 class QCPGraph;
33 class QTemporaryFile;
34 
35 typedef enum {
36  TAP_RTP_NO_ERROR,
37  TAP_RTP_WRONG_LENGTH,
38  TAP_RTP_PADDING_ERROR,
39  TAP_RTP_FILE_IO_ERROR
40 } rtp_error_type_t;
41 
43 {
44  Q_OBJECT
45 
46 public:
47  explicit RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _rtp_stream_info *stream_fwd = 0, struct _rtp_stream_info *stream_rev = 0);
49 
50 signals:
51  void goToPacket(int packet_num);
52 
53 protected:
54  virtual void captureFileClosing();
55 
56 protected slots:
57  virtual void updateWidgets();
58 
59 private slots:
60  void on_actionGoToPacket_triggered();
61  void on_actionNextProblem_triggered();
62  void on_fJitterCheckBox_toggled(bool checked);
63  void on_fDiffCheckBox_toggled(bool checked);
64  void on_fDeltaCheckBox_toggled(bool checked);
65  void on_rJitterCheckBox_toggled(bool checked);
66  void on_rDiffCheckBox_toggled(bool checked);
67  void on_rDeltaCheckBox_toggled(bool checked);
68  void on_actionSaveAudioUnsync_triggered();
69  void on_actionSaveForwardAudioUnsync_triggered();
70  void on_actionSaveReverseAudioUnsync_triggered();
71  void on_actionSaveAudioSyncStream_triggered();
72  void on_actionSaveForwardAudioSyncStream_triggered();
73  void on_actionSaveReverseAudioSyncStream_triggered();
74  void on_actionSaveAudioSyncFile_triggered();
75  void on_actionSaveForwardAudioSyncFile_triggered();
76  void on_actionSaveReverseAudioSyncFile_triggered();
77  void on_actionSaveCsv_triggered();
78  void on_actionSaveForwardCsv_triggered();
79  void on_actionSaveReverseCsv_triggered();
80  void on_actionSaveGraph_triggered();
81  void on_buttonBox_clicked(QAbstractButton *button);
82  void on_buttonBox_helpRequested();
83  void showStreamMenu(QPoint pos);
84  void graphClicked(QMouseEvent *event);
85 
86 private:
88  enum StreamDirection { dir_both_, dir_forward_, dir_reverse_ };
89  enum SyncType { sync_unsync_, sync_sync_stream_, sync_sync_file_ };
90 
91  // XXX These are copied to and from rtp_stream_info_t structs. Should
92  // we just have a pair of those instead?
93  address src_fwd_;
94  guint32 port_src_fwd_;
95  address dst_fwd_;
96  guint32 port_dst_fwd_;
97  guint32 ssrc_fwd_;
98  guint32 packet_count_fwd_;
99  guint32 setup_frame_number_fwd_;
100  nstime_t start_rel_time_fwd_;
101 
102  address src_rev_;
103  guint32 port_src_rev_;
104  address dst_rev_;
105  guint32 port_dst_rev_;
106  guint32 ssrc_rev_;
107  guint32 packet_count_rev_;
108  guint32 setup_frame_number_rev_;
109  nstime_t start_rel_time_rev_;
110 
111  int num_streams_;
112 
113  tap_rtp_stat_t fwd_statinfo_;
114  tap_rtp_stat_t rev_statinfo_;
115 
116  QPushButton *player_button_;
117 
118  QTemporaryFile *fwd_tempfile_;
119  QTemporaryFile *rev_tempfile_;
120 
121  // Graph data for QCustomPlot
122  QList<QCPGraph *>graphs_;
123  QVector<double> fwd_time_vals_;
124  QVector<double> fwd_jitter_vals_;
125  QVector<double> fwd_diff_vals_;
126  QVector<double> fwd_delta_vals_;
127 
128  QVector<double> rev_time_vals_;
129  QVector<double> rev_jitter_vals_;
130  QVector<double> rev_diff_vals_;
131  QVector<double> rev_delta_vals_;
132 
133  rtpstream_tapinfo_t tapinfo_;
134  QString err_str_;
135  rtp_error_type_t save_payload_error_;
136 
137  QMenu stream_ctx_menu_;
138  QMenu graph_ctx_menu_;
139 
140  void findStreams();
141 
142  // Tap callbacks
143  static void tapReset(void *tapinfo_ptr);
144  static gboolean tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr);
145  static void tapDraw(void *tapinfo_ptr);
146 
147  void resetStatistics();
148  void addPacket(bool forward, packet_info *pinfo, const struct _rtp_info *rtpinfo);
149  void savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *statinfo, packet_info *pinfo, const struct _rtp_info *rtpinfo);
150  void updateStatistics();
151  void updateGraph();
152 
153  void showPlayer();
154 
155  size_t convert_payload_to_samples(unsigned int payload_type, QTemporaryFile *tempfile, gchar *pd_out, size_t expected_nchars);
156  gboolean saveAudioAUSilence(size_t total_len, QFile *save_file, gboolean *stop_flag);
157  gboolean saveAudioAUUnidir(tap_rtp_stat_t &statinfo, QTemporaryFile *tempfile, QFile *save_file, size_t header_end, gboolean *stop_flag, gboolean interleave, size_t prefix_silence);
158  gboolean saveAudioAUBidir(tap_rtp_stat_t &fwd_statinfo, tap_rtp_stat_t &rev_statinfo, QTemporaryFile *fwd_tempfile, QTemporaryFile *rev_tempfile, QFile *save_file, size_t header_end, gboolean *stop_flag, size_t prefix_silence_fwd, size_t prefix_silence_rev);
159  gboolean saveAudioAU(StreamDirection direction, QFile *save_file, gboolean *stop_flag, RtpAnalysisDialog::SyncType sync);
160  gboolean saveAudioRAW(StreamDirection direction, QFile *save_file, gboolean *stop_flag);
161  void saveAudio(StreamDirection direction, RtpAnalysisDialog::SyncType sync);
162  void saveCsv(StreamDirection direction);
163 
164  guint32 processNode(proto_node *ptree_node, header_field_info *hfinformation, const gchar* proto_field, bool *ok);
165  guint32 getIntFromProtoTree(proto_tree *protocol_tree, const gchar *proto_name, const gchar *proto_field, bool *ok);
166 
167  bool eventFilter(QObject*, QEvent* event);
168 };
169 
170 #endif // RTP_ANALYSIS_DIALOG_H
171 
172 /*
173  * Editor modelines
174  *
175  * Local Variables:
176  * c-basic-offset: 4
177  * tab-width: 8
178  * indent-tabs-mode: nil
179  * End:
180  *
181  * ex: set shiftwidth=4 tabstop=8 expandtab:
182  * :indentSize=4:tabSize=8:noTabs=true:
183  */
Definition: ui_rtp_analysis_dialog.h:383
Definition: proto.h:622
Definition: packet_info.h:44
Definition: ui_about_dialog.h:291
A plottable representing a graph in a plot.
Definition: qcustomplot.h:2492
Definition: nstime.h:27
Definition: tap-rtp-analysis.h:55
Definition: rtp_stream.h:83
Definition: epan_dissect.h:28
Definition: wireshark_dialog.h:32
Definition: rtp_analysis_dialog.h:42
Definition: packet-rtp.h:26
Definition: proto.h:759
Definition: capture_file.h:22
Definition: rtp_stream.h:36
Definition: address.h:47