| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
rtp_player_dialog.h
Go to the documentation of this file.
1
9
10#ifndef RTP_PLAYER_DIALOG_H
11#define RTP_PLAYER_DIALOG_H
12
13#include "config.h"
14
15#include <mutex>
16
17#include "ui/rtp_stream.h"
18
19#include "wireshark_dialog.h"
20#include "rtp_audio_stream.h"
21
22#include <QWidget>
23#include <QMap>
24#include <QMultiHash>
25#include <QTreeWidgetItem>
26#include <QMetaType>
27#include <ui/qt/widgets/qcustomplot.h>
28
29#ifdef QT_MULTIMEDIA_LIB
30# include <QAudioDevice>
31#endif
32
33 namespace Ui {
34 class RtpPlayerDialog;
35}
36
37 class QCPItemStraightLine;
38 class QDialogButtonBox;
39 class QMenu;
40 class RtpAudioStream;
41 class QCPAxisTicker;
42 class QCPAxisTickerDateTime;
43
47 typedef enum {
48 save_audio_none,
49 save_audio_au,
50 save_audio_wav
51} save_audio_t;
52
56 typedef enum {
57 save_payload_none,
58 save_payload_data
59} save_payload_t;
60
64 typedef enum {
65 save_mode_from_cursor,
66 save_mode_sync_stream,
67 save_mode_sync_file
68} save_mode_t;
69
73 class RtpBaseDialog : public WiresharkDialog
74{
75 Q_OBJECT
76 protected:
82 explicit RtpBaseDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf) {}
83
84#ifdef QT_MULTIMEDIA_LIB
85 public slots:
89 virtual void rtpAnalysisReplace() = 0;
90
94 virtual void rtpAnalysisAdd() = 0;
95
99 virtual void rtpAnalysisRemove() = 0;
100#endif // QT_MULTIMEDIA_LIB
101};
102
107 class RtpPlayerDialog : public RtpBaseDialog
108{
109 Q_OBJECT
110#ifdef QT_MULTIMEDIA_LIB
111 Q_PROPERTY(QString currentOutputDeviceName READ currentOutputDeviceName)
112#endif
113
114 public:
123 static RtpPlayerDialog *openRtpPlayerDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list, bool capture_running);
124
128 RtpPlayerDialog(RtpPlayerDialog &other) = delete;
129
133 void operator=(const RtpPlayerDialog &) = delete;
134
141 static QToolButton *addPlayerButton(QDialogButtonBox *button_box, QDialog *dialog);
142
143#ifdef QT_MULTIMEDIA_LIB
147 void accept() override;
148
152 void reject() override;
153
157 void setMarkers();
158
166 void replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
167
172 void addRtpStreams(QVector<rtpstream_id_t *> stream_ids);
173
178 void removeRtpStreams(QVector<rtpstream_id_t *> stream_ids);
179
180signals:
181 // Tells the packet list to redraw. An alternative might be to add a
182 // cf_packet_marked callback to file.[ch] but that's synchronous and
183 // might incur too much overhead.
187 void packetsMarked();
188
194 void updateFilter(QString filter, bool force = false);
195
200 void goToPacket(int packet_num);
201
206 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_infos);
207
212 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_infos);
213
218 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_infos);
219
220 public slots:
224 void rtpAnalysisReplace() override;
225
229 void rtpAnalysisAdd() override;
230
234 void rtpAnalysisRemove() override;
235
236#endif // QT_MULTIMEDIA_LIB
237 protected:
244 explicit RtpPlayerDialog(QWidget &parent, CaptureFile &cf, bool capture_running);
245#ifdef QT_MULTIMEDIA_LIB
249 ~RtpPlayerDialog();
250
254 virtual void showEvent(QShowEvent *) override;
255
260 void contextMenuEvent(QContextMenuEvent *event) override;
261
268 bool eventFilter(QObject *obj, QEvent *event) override;
269
270 private slots:
274 void retapPackets();
275
280 void captureEvent(CaptureEvent e);
281
284 void rescanPackets(bool rescale_axes = false);
285
290 void createPlot(bool rescale_axes = false);
291
295 void updateWidgets() override;
296
302 void itemEntered(QTreeWidgetItem *item, int column);
303
308 void mouseMovePlot(QMouseEvent *event);
309
313 void mouseMoveUpdate();
314
319 void showGraphContextMenu(const QPoint &pos);
320
325 void graphClicked(QMouseEvent *event);
326
331 void graphDoubleClicked(QMouseEvent *event);
332
339 void plotClicked(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
340
344 void updateHintLabel();
345
349 void resetXAxis();
350
354 void updateGraphs();
355
361 void playFinished(RtpAudioStream *stream, QAudio::Error error);
362
367 void setPlayPosition(double secs);
368
373 void setPlaybackError(const QString playback_error);
374
380 void changeAudioRoutingOnItem(QTreeWidgetItem *ti, AudioRouting new_audio_routing);
381
386 void changeAudioRouting(AudioRouting new_audio_routing);
387
392 void invertAudioMutingOnItem(QTreeWidgetItem *ti);
393
397 void on_playButton_clicked();
398
402 void on_pauseButton_clicked();
403
407 void on_stopButton_clicked();
408
412 void on_actionReset_triggered();
413
417 void on_actionZoomIn_triggered();
418
422 void on_actionZoomOut_triggered();
423
427 void on_actionMoveLeft10_triggered();
428
432 void on_actionMoveRight10_triggered();
433
437 void on_actionMoveLeft1_triggered();
438
442 void on_actionMoveRight1_triggered();
443
447 void on_actionGoToPacket_triggered();
448
452 void on_actionGoToSetupPacketPlot_triggered();
453
457 void on_actionGoToSetupPacketTree_triggered();
458
462 void on_actionRemoveStream_triggered();
463
467 void on_actionAudioRoutingP_triggered();
468
472 void on_actionAudioRoutingL_triggered();
473
477 void on_actionAudioRoutingLR_triggered();
478
482 void on_actionAudioRoutingR_triggered();
483
487 void on_actionAudioRoutingMute_triggered();
488
492 void on_actionAudioRoutingUnmute_triggered();
493
497 void on_actionAudioRoutingMuteInvert_triggered();
498
502 void on_streamTreeWidget_itemSelectionChanged();
503
509 void on_streamTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, const int column);
510
514 void on_outputDeviceComboBox_currentTextChanged(const QString &);
515
520 void on_outputAudioRate_currentTextChanged(const QString &rate_string);
521
525 void on_jitterSpinBox_valueChanged(double);
526
530 void on_timingComboBox_currentIndexChanged(int);
531
536 void on_todCheckBox_toggled(bool checked);
537
541 void on_visualSRSpinBox_editingFinished();
542
546 void on_buttonBox_helpRequested();
547
551 void on_actionSelectAll_triggered();
552
556 void on_actionSelectInvert_triggered();
557
561 void on_actionSelectNone_triggered();
562
566 void outputNotify();
567
571 void on_actionPlay_triggered();
572
576 void on_actionStop_triggered();
577
581 void on_actionSaveAudioFromCursor_triggered();
582
586 void on_actionSaveAudioSyncStream_triggered();
587
591 void on_actionSaveAudioSyncFile_triggered();
592
596 void on_actionSavePayload_triggered();
597
601 void on_actionSelectInaudible_triggered();
602
606 void on_actionDeselectInaudible_triggered();
607
611 void on_actionPrepareFilter_triggered();
612
616 void on_actionReadCapture_triggered();
617
621 void sinkStateChanged();
622
623#endif
624 private:
626 static RtpPlayerDialog *pinstance_;
627
629 static std::mutex init_mutex_;
630
632 static std::mutex run_mutex_;
633
634#ifdef QT_MULTIMEDIA_LIB
636 Ui::RtpPlayerDialog *ui;
637
639 QMenu *graph_ctx_menu_;
640
642 QMenu *list_ctx_menu_;
643
645 double first_stream_rel_start_time_;
646
648 double first_stream_abs_start_time_;
649
651 double first_stream_rel_stop_time_;
652
654 double streams_length_;
655
657 double start_marker_time_;
658
660 double start_marker_time_play_;
661
663 QCPItemStraightLine *cur_play_pos_;
664
666 QCPItemStraightLine *start_marker_pos_;
667
669 QString playback_error_;
670
672 QSharedPointer<QCPAxisTicker> number_ticker_;
673
675 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
676
678 bool stereo_available_;
679
681 QList<RtpAudioStream *> playing_streams_;
682
684 QAudioSink *marker_stream_;
685
687 QTimer notify_timer_;
688
690 qint64 notify_timer_start_diff_;
692 quint32 marker_stream_requested_out_rate_;
693
695 QTreeWidgetItem *last_ti_;
696
698 bool listener_removed_;
699
701 QPushButton *read_btn_;
702
704 QToolButton *inaudible_btn_;
705
707 QToolButton *analyze_btn_;
708
710 QPushButton *prepare_btn_;
711
713 QPushButton *export_btn_;
714
716 QMultiHash<unsigned, RtpAudioStream *> stream_hash_;
717
719 bool block_redraw_;
720
722 int lock_ui_;
723
725 bool read_capture_enabled_;
726
728 double silence_skipped_time_;
729
731 QTimer *mouse_update_timer_;
732
734 QPoint mouse_pos_;
735
736// const QString streamKey(const rtpstream_info_t *rtpstream);
737// const QString streamKey(const packet_info *pinfo, const struct _rtp_info *rtpinfo);
738
739 // Tap callbacks
740// static void tapReset(void *tapinfo_ptr);
741
750 static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr, tap_flags_t flags);
751
756 static void tapDraw(void *tapinfo_ptr);
757
763 void addPacket(packet_info *pinfo, const struct _rtp_info *rtpinfo);
764
769 void zoomXAxis(bool in);
770
775 void panXAxis(int x_pixels);
776
782 const QString getFormatedTime(double f_time);
783
788 const QString getFormatedHoveredTime();
789
794 int getHoveredPacket();
795
800 QString currentOutputDeviceName();
801
806 double getStartPlayMarker();
807
811 void drawStartPlayMarker();
812
817 void setStartPlayMarker(double new_time);
818
824 void updateStartStopTime(rtpstream_info_t *rtpstream, bool is_first);
825
831 void formatAudioRouting(QTreeWidgetItem *ti, AudioRouting audio_routing);
832
837 bool isStereoAvailable();
838
843 QAudioSink *getSilenceAudioOutput();
844
849 QAudioDevice getCurrentDeviceInfo();
850
856 QTreeWidgetItem *findItemByCoords(QPoint point);
857
863 QTreeWidgetItem *findItem(QCPAbstractPlottable *plottable);
864
870 void handleItemHighlight(QTreeWidgetItem *ti, bool scroll);
871
877 void highlightItem(QTreeWidgetItem *ti, bool highlight);
878
882 void invertSelection();
883
888 void handleGoToSetupPacket(QTreeWidgetItem *ti);
889
894 void addSingleRtpStream(rtpstream_id_t *id);
895
900 void removeRow(QTreeWidgetItem *ti);
901
905 void fillAudioRateMenu();
906
910 void cleanupMarkerStream();
911
919 qint64 saveAudioHeaderAU(QFile *save_file, quint32 channels, unsigned audio_rate);
920
929 qint64 saveAudioHeaderWAV(QFile *save_file, quint32 channels, unsigned audio_rate, qint64 samples);
930
938 bool writeAudioSilenceSamples(QFile *out_file, qint64 samples, int stream_count);
939
947 bool writeAudioStreamsSamples(QFile *out_file, QVector<RtpAudioStream *> streams, bool big_endian);
948
954 save_audio_t selectFileAudioFormatAndName(QString *file_path);
955
961 save_payload_t selectFilePayloadFormatAndName(QString *file_path);
962
967 QVector<RtpAudioStream *>getSelectedAudibleNonmutedAudioStreams();
968
973 void saveAudio(save_mode_t save_mode);
974
978 void savePayload();
979
983 void lockUI();
984
988 void unlockUI();
989
994 void selectInaudible(bool select);
995
1000 QVector<rtpstream_id_t *>getSelectedRtpStreamIDs();
1001
1005 void fillTappedColumns();
1006
1007#else // QT_MULTIMEDIA_LIB
1008 private:
1010 Ui::RtpPlayerDialog *ui;
1011#endif // QT_MULTIMEDIA_LIB
1012};
1013
1014#endif // RTP_PLAYER_DIALOG_H
AudioRouting
Encapsulates the mute state and channel assignment for one audio stream.
Definition rtp_audio_routing.h:35
CaptureEvent
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
CaptureFile
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
RtpBaseDialog::RtpBaseDialog
RtpBaseDialog(QWidget &parent, CaptureFile &cf)
Constructs an RtpBaseDialog.
Definition rtp_player_dialog.h:82
RtpPlayerDialog::openRtpPlayerDialog
static RtpPlayerDialog * openRtpPlayerDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list, bool capture_running)
Opens or retrieves the singleton instance of the RTP Player Dialog.
Definition rtp_player_dialog.cpp:142
RtpPlayerDialog::operator=
void operator=(const RtpPlayerDialog &)=delete
Should not be assignable.
RtpPlayerDialog::RtpPlayerDialog
RtpPlayerDialog(RtpPlayerDialog &other)=delete
Should not be cloneable.
RtpPlayerDialog::addPlayerButton
static QToolButton * addPlayerButton(QDialogButtonBox *button_box, QDialog *dialog)
Common routine to add a "Play call" button to a QDialogButtonBox.
Definition rtp_player_dialog.cpp:345
WiresharkDialog::updateWidgets
virtual void updateWidgets()
Updates the state and contents of the dialog's widgets.
Definition wireshark_dialog.cpp:92
WiresharkDialog::WiresharkDialog
WiresharkDialog(QWidget &parent, CaptureFile &capture_file)
Constructs a new WiresharkDialog object.
Definition wireshark_dialog.cpp:30
WiresharkDialog::captureEvent
void captureEvent(CaptureEvent e)
Handles capture events.
Definition wireshark_dialog.cpp:112
WiresharkDialog::accept
virtual void accept() override
Accepts the dialog.
Definition wireshark_dialog.cpp:43
WiresharkDialog::reject
virtual void reject() override
Rejects the dialog.
Definition wireshark_dialog.cpp:50
epan_dissect_t
struct epan_dissect epan_dissect_t
Opaque type representing a single packet dissection context.
Definition epan.h:62
packet_info
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
rtp_audio_stream.h
save_mode_t
save_mode_t
Defines the modes available for saving audio or payload data.
Definition rtp_player_dialog.h:64
save_mode_sync_file
@ save_mode_sync_file
Definition rtp_player_dialog.h:67
save_mode_sync_stream
@ save_mode_sync_stream
Definition rtp_player_dialog.h:66
save_mode_from_cursor
@ save_mode_from_cursor
Definition rtp_player_dialog.h:65
save_payload_t
save_payload_t
Defines the payload formats available for saving.
Definition rtp_player_dialog.h:56
save_payload_data
@ save_payload_data
Definition rtp_player_dialog.h:58
save_payload_none
@ save_payload_none
Definition rtp_player_dialog.h:57
save_audio_t
save_audio_t
Defines the audio formats available for saving.
Definition rtp_player_dialog.h:47
save_audio_au
@ save_audio_au
Definition rtp_player_dialog.h:49
save_audio_wav
@ save_audio_wav
Definition rtp_player_dialog.h:50
save_audio_none
@ save_audio_none
Definition rtp_player_dialog.h:48
rtp_stream.h
rtpstream_info_t
struct _rtpstream_info rtpstream_info_t
Holds all state and statistics accumulated for a single RTP stream.
rtpstream_id_t
struct _rtpstream_id rtpstream_id_t
_rtp_info
Definition packet-rtp.h:29
stream
Definition stream.c:41
tap_packet_status
tap_packet_status
Definition tap.h:22
wireshark_dialog.h