Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
rtp_player_dialog.h
Go to the documentation of this file.
1
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# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
31# include <QAudioDevice>
32# else
33# include <QAudioDeviceInfo>
34# endif
35#endif
36
37namespace Ui {
38class RtpPlayerDialog;
39}
40
41class QCPItemStraightLine;
42class QDialogButtonBox;
43class QMenu;
44class RtpAudioStream;
45class QCPAxisTicker;
46class QCPAxisTickerDateTime;
47
56
64
73
78{
79 Q_OBJECT
80protected:
86 explicit RtpBaseDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf) {}
87
88#ifdef QT_MULTIMEDIA_LIB
89public slots:
93 virtual void rtpAnalysisReplace() = 0;
94
98 virtual void rtpAnalysisAdd() = 0;
99
103 virtual void rtpAnalysisRemove() = 0;
104#endif // QT_MULTIMEDIA_LIB
105};
106
112{
113 Q_OBJECT
114#ifdef QT_MULTIMEDIA_LIB
115 Q_PROPERTY(QString currentOutputDeviceName READ currentOutputDeviceName)
116#endif
117
118public:
127 static RtpPlayerDialog *openRtpPlayerDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list, bool capture_running);
128
133
137 void operator=(const RtpPlayerDialog &) = delete;
138
145 static QToolButton *addPlayerButton(QDialogButtonBox *button_box, QDialog *dialog);
146
147#ifdef QT_MULTIMEDIA_LIB
151 void accept();
152
156 void reject();
157
161 void setMarkers();
162
170 void replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
171
176 void addRtpStreams(QVector<rtpstream_id_t *> stream_ids);
177
182 void removeRtpStreams(QVector<rtpstream_id_t *> stream_ids);
183
184signals:
185 // Tells the packet list to redraw. An alternative might be to add a
186 // cf_packet_marked callback to file.[ch] but that's synchronous and
187 // might incur too much overhead.
191 void packetsMarked();
192
198 void updateFilter(QString filter, bool force = false);
199
204 void goToPacket(int packet_num);
205
210 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_infos);
211
216 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_infos);
217
222 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_infos);
223
224public slots:
228 void rtpAnalysisReplace();
229
233 void rtpAnalysisAdd();
234
238 void rtpAnalysisRemove();
239
240#endif
241protected:
248 explicit RtpPlayerDialog(QWidget &parent, CaptureFile &cf, bool capture_running);
249#ifdef QT_MULTIMEDIA_LIB
254
258 virtual void showEvent(QShowEvent *);
259
264 void contextMenuEvent(QContextMenuEvent *event);
265
272 bool eventFilter(QObject *obj, QEvent *event);
273
274private slots:
278 void retapPackets();
279
285
288 void rescanPackets(bool rescale_axes = false);
289
294 void createPlot(bool rescale_axes = false);
295
299 void updateWidgets();
300
306 void itemEntered(QTreeWidgetItem *item, int column);
307
312 void mouseMovePlot(QMouseEvent *event);
313
317 void mouseMoveUpdate();
318
323 void showGraphContextMenu(const QPoint &pos);
324
329 void graphClicked(QMouseEvent *event);
330
335 void graphDoubleClicked(QMouseEvent *event);
336
343 void plotClicked(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
344
348 void updateHintLabel();
349
353 void resetXAxis();
354
358 void updateGraphs();
359
365 void playFinished(RtpAudioStream *stream, QAudio::Error error);
366
371 void setPlayPosition(double secs);
372
377 void setPlaybackError(const QString playback_error);
378
384 void changeAudioRoutingOnItem(QTreeWidgetItem *ti, AudioRouting new_audio_routing);
385
390 void changeAudioRouting(AudioRouting new_audio_routing);
391
396 void invertAudioMutingOnItem(QTreeWidgetItem *ti);
397
401 void on_playButton_clicked();
402
406 void on_pauseButton_clicked();
407
411 void on_stopButton_clicked();
412
416 void on_actionReset_triggered();
417
421 void on_actionZoomIn_triggered();
422
426 void on_actionZoomOut_triggered();
427
431 void on_actionMoveLeft10_triggered();
432
436 void on_actionMoveRight10_triggered();
437
441 void on_actionMoveLeft1_triggered();
442
446 void on_actionMoveRight1_triggered();
447
451 void on_actionGoToPacket_triggered();
452
456 void on_actionGoToSetupPacketPlot_triggered();
457
461 void on_actionGoToSetupPacketTree_triggered();
462
466 void on_actionRemoveStream_triggered();
467
471 void on_actionAudioRoutingP_triggered();
472
476 void on_actionAudioRoutingL_triggered();
477
481 void on_actionAudioRoutingLR_triggered();
482
486 void on_actionAudioRoutingR_triggered();
487
491 void on_actionAudioRoutingMute_triggered();
492
496 void on_actionAudioRoutingUnmute_triggered();
497
501 void on_actionAudioRoutingMuteInvert_triggered();
502
506 void on_streamTreeWidget_itemSelectionChanged();
507
513 void on_streamTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, const int column);
514
518 void on_outputDeviceComboBox_currentTextChanged(const QString &);
519
524 void on_outputAudioRate_currentTextChanged(const QString &rate_string);
525
529 void on_jitterSpinBox_valueChanged(double);
530
534 void on_timingComboBox_currentIndexChanged(int);
535
540 void on_todCheckBox_toggled(bool checked);
541
545 void on_visualSRSpinBox_editingFinished();
546
550 void on_buttonBox_helpRequested();
551
555 void on_actionSelectAll_triggered();
556
560 void on_actionSelectInvert_triggered();
561
565 void on_actionSelectNone_triggered();
566
570 void outputNotify();
571
575 void on_actionPlay_triggered();
576
580 void on_actionStop_triggered();
581
585 void on_actionSaveAudioFromCursor_triggered();
586
590 void on_actionSaveAudioSyncStream_triggered();
591
595 void on_actionSaveAudioSyncFile_triggered();
596
600 void on_actionSavePayload_triggered();
601
605 void on_actionSelectInaudible_triggered();
606
610 void on_actionDeselectInaudible_triggered();
611
615 void on_actionPrepareFilter_triggered();
616
620 void on_actionReadCapture_triggered();
621
622#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
626 void sinkStateChanged();
627#endif
628
629#endif
630private:
632 static RtpPlayerDialog *pinstance_;
633
635 static std::mutex init_mutex_;
636
638 static std::mutex run_mutex_;
639
640#ifdef QT_MULTIMEDIA_LIB
642 Ui::RtpPlayerDialog *ui;
643
645 QMenu *graph_ctx_menu_;
646
648 QMenu *list_ctx_menu_;
649
651 double first_stream_rel_start_time_;
652
654 double first_stream_abs_start_time_;
655
657 double first_stream_rel_stop_time_;
658
660 double streams_length_;
661
663 double start_marker_time_;
664
666 double start_marker_time_play_;
667
669 QCPItemStraightLine *cur_play_pos_;
670
672 QCPItemStraightLine *start_marker_pos_;
673
675 QString playback_error_;
676
678 QSharedPointer<QCPAxisTicker> number_ticker_;
679
681 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
682
684 bool stereo_available_;
685
687 QList<RtpAudioStream *> playing_streams_;
688
689#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
691 QAudioSink *marker_stream_;
692
694 QTimer notify_timer_;
695
697 qint64 notify_timer_start_diff_;
698#else
700 QAudioOutput *marker_stream_;
701#endif
703 quint32 marker_stream_requested_out_rate_;
704
706 QTreeWidgetItem *last_ti_;
707
709 bool listener_removed_;
710
712 QPushButton *read_btn_;
713
715 QToolButton *inaudible_btn_;
716
718 QToolButton *analyze_btn_;
719
721 QPushButton *prepare_btn_;
722
724 QPushButton *export_btn_;
725
727 QMultiHash<unsigned, RtpAudioStream *> stream_hash_;
728
730 bool block_redraw_;
731
733 int lock_ui_;
734
736 bool read_capture_enabled_;
737
739 double silence_skipped_time_;
740
742 QTimer *mouse_update_timer_;
743
745 QPoint mouse_pos_;
746
747// const QString streamKey(const rtpstream_info_t *rtpstream);
748// const QString streamKey(const packet_info *pinfo, const struct _rtp_info *rtpinfo);
749
750 // Tap callbacks
751// static void tapReset(void *tapinfo_ptr);
752
761 static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr, tap_flags_t flags);
762
767 static void tapDraw(void *tapinfo_ptr);
768
774 void addPacket(packet_info *pinfo, const struct _rtp_info *rtpinfo);
775
780 void zoomXAxis(bool in);
781
786 void panXAxis(int x_pixels);
787
793 const QString getFormatedTime(double f_time);
794
799 const QString getFormatedHoveredTime();
800
805 int getHoveredPacket();
806
811 QString currentOutputDeviceName();
812
817 double getStartPlayMarker();
818
822 void drawStartPlayMarker();
823
828 void setStartPlayMarker(double new_time);
829
835 void updateStartStopTime(rtpstream_info_t *rtpstream, bool is_first);
836
842 void formatAudioRouting(QTreeWidgetItem *ti, AudioRouting audio_routing);
843
848 bool isStereoAvailable();
849
850#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
855 QAudioSink *getSilenceAudioOutput();
856
861 QAudioDevice getCurrentDeviceInfo();
862#else
867 QAudioOutput *getSilenceAudioOutput();
868
873 QAudioDeviceInfo getCurrentDeviceInfo();
874#endif
875
881 QTreeWidgetItem *findItemByCoords(QPoint point);
882
888 QTreeWidgetItem *findItem(QCPAbstractPlottable *plottable);
889
895 void handleItemHighlight(QTreeWidgetItem *ti, bool scroll);
896
902 void highlightItem(QTreeWidgetItem *ti, bool highlight);
903
907 void invertSelection();
908
913 void handleGoToSetupPacket(QTreeWidgetItem *ti);
914
919 void addSingleRtpStream(rtpstream_id_t *id);
920
925 void removeRow(QTreeWidgetItem *ti);
926
930 void fillAudioRateMenu();
931
935 void cleanupMarkerStream();
936
944 qint64 saveAudioHeaderAU(QFile *save_file, quint32 channels, unsigned audio_rate);
945
954 qint64 saveAudioHeaderWAV(QFile *save_file, quint32 channels, unsigned audio_rate, qint64 samples);
955
963 bool writeAudioSilenceSamples(QFile *out_file, qint64 samples, int stream_count);
964
972 bool writeAudioStreamsSamples(QFile *out_file, QVector<RtpAudioStream *> streams, bool big_endian);
973
979 save_audio_t selectFileAudioFormatAndName(QString *file_path);
980
986 save_payload_t selectFilePayloadFormatAndName(QString *file_path);
987
992 QVector<RtpAudioStream *>getSelectedAudibleNonmutedAudioStreams();
993
998 void saveAudio(save_mode_t save_mode);
999
1003 void savePayload();
1004
1008 void lockUI();
1009
1013 void unlockUI();
1014
1019 void selectInaudible(bool select);
1020
1025 QVector<rtpstream_id_t *>getSelectedRtpStreamIDs();
1026
1030 void fillTappedColumns();
1031
1032#else // QT_MULTIMEDIA_LIB
1033private:
1035 Ui::RtpPlayerDialog *ui;
1036#endif // QT_MULTIMEDIA_LIB
1037};
1038
1039#endif // RTP_PLAYER_DIALOG_H
Encapsulates the mute state and channel assignment for one audio stream.
Definition rtp_audio_routing.h:35
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
Base class for RTP related dialogs providing common functionality.
Definition rtp_player_dialog.h:78
RtpBaseDialog(QWidget &parent, CaptureFile &cf)
Constructs an RtpBaseDialog.
Definition rtp_player_dialog.h:86
Singleton dialog for playing and analyzing RTP audio streams. Singleton pattern based on https://refa...
Definition rtp_player_dialog.h:112
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:146
void operator=(const RtpPlayerDialog &)=delete
Should not be assignable.
RtpPlayerDialog(RtpPlayerDialog &other)=delete
Should not be cloneable.
static QToolButton * addPlayerButton(QDialogButtonBox *button_box, QDialog *dialog)
Common routine to add a "Play call" button to a QDialogButtonBox.
Definition rtp_player_dialog.cpp:362
Base class for Wireshark specific dialogs that require interaction with a CaptureFile.
Definition wireshark_dialog.h:38
virtual void updateWidgets()
Updates the state and contents of the dialog's widgets.
Definition wireshark_dialog.cpp:92
virtual void accept()
Accepts the dialog.
Definition wireshark_dialog.cpp:43
virtual void reject()
Rejects the dialog.
Definition wireshark_dialog.cpp:50
void captureEvent(CaptureEvent e)
Handles capture events.
Definition wireshark_dialog.cpp:112
save_mode_t
Defines the modes available for saving audio or payload data.
Definition rtp_player_dialog.h:68
@ save_mode_sync_file
Definition rtp_player_dialog.h:71
@ save_mode_sync_stream
Definition rtp_player_dialog.h:70
@ save_mode_from_cursor
Definition rtp_player_dialog.h:69
save_payload_t
Defines the payload formats available for saving.
Definition rtp_player_dialog.h:60
@ save_payload_data
Definition rtp_player_dialog.h:62
@ save_payload_none
Definition rtp_player_dialog.h:61
save_audio_t
Defines the audio formats available for saving.
Definition rtp_player_dialog.h:51
@ save_audio_au
Definition rtp_player_dialog.h:53
@ save_audio_wav
Definition rtp_player_dialog.h:54
@ save_audio_none
Definition rtp_player_dialog.h:52
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Definition packet-rtp.h:29
Definition rtp_stream_id.h:33
Holds all state and statistics accumulated for a single RTP stream.
Definition rtp_stream.h:42
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Definition stream.c:41
tap_packet_status
Definition tap.h:22