Wireshark 5.1.0
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
33namespace Ui {
34class RtpPlayerDialog;
35}
36
37class QCPItemStraightLine;
38class QDialogButtonBox;
39class QMenu;
40class RtpAudioStream;
41class QCPAxisTicker;
42class QCPAxisTickerDateTime;
43
52
60
69
74{
75 Q_OBJECT
76protected:
82 explicit RtpBaseDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf) {}
83
84#ifdef QT_MULTIMEDIA_LIB
85public 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
108{
109 Q_OBJECT
110#ifdef QT_MULTIMEDIA_LIB
111 Q_PROPERTY(QString currentOutputDeviceName READ currentOutputDeviceName)
112#endif
113
114public:
123 static RtpPlayerDialog *openRtpPlayerDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list, bool capture_running);
124
129
133 void operator=(const RtpPlayerDialog &) = delete;
134
141 static QPushButton *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
220public slots:
224 void rtpAnalysisReplace() override;
225
229 void rtpAnalysisAdd() override;
230
234 void rtpAnalysisRemove() override;
235
236#endif // QT_MULTIMEDIA_LIB
237protected:
244 explicit RtpPlayerDialog(QWidget &parent, CaptureFile &cf, bool capture_running);
245#ifdef QT_MULTIMEDIA_LIB
250
254 virtual void showEvent(QShowEvent *) override;
255
260 void contextMenuEvent(QContextMenuEvent *event) override;
261
268 bool eventFilter(QObject *obj, QEvent *event) override;
269
270private slots:
274 void retapPackets();
275
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_actionAudioRoutingSolo_triggered();
503
507 void on_streamTreeWidget_itemSelectionChanged();
508
514 void on_streamTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, const int column);
515
519 void on_outputDeviceComboBox_currentTextChanged(const QString &);
520
525 void on_outputAudioRate_currentTextChanged(const QString &rate_string);
526
530 void on_jitterSpinBox_valueChanged(double);
531
535 void on_timingComboBox_currentIndexChanged(int);
536
541 void on_todCheckBox_toggled(bool checked);
542
546 void on_visualSRSpinBox_editingFinished();
547
551 void on_buttonBox_helpRequested();
552
556 void on_actionSelectAll_triggered();
557
561 void on_actionSelectInvert_triggered();
562
566 void on_actionSelectNone_triggered();
567
571 void outputNotify();
572
576 void on_actionPlay_triggered();
577
581 void on_actionStop_triggered();
582
586 void on_actionSaveAudioFromCursor_triggered();
587
591 void on_actionSaveAudioSyncStream_triggered();
592
596 void on_actionSaveAudioSyncFile_triggered();
597
601 void on_actionSavePayload_triggered();
602
606 void on_actionSelectInaudible_triggered();
607
611 void on_actionDeselectInaudible_triggered();
612
616 void on_actionPrepareFilter_triggered();
617
621 void on_actionReadCapture_triggered();
622
626 void sinkStateChanged();
627
628#endif
629private:
631 static RtpPlayerDialog *pinstance_;
632
634 static std::mutex init_mutex_;
635
637 static std::mutex run_mutex_;
638
639#ifdef QT_MULTIMEDIA_LIB
641 Ui::RtpPlayerDialog *ui;
642
644 QMenu *graph_ctx_menu_;
645
647 QMenu *list_ctx_menu_;
648
650 double first_stream_rel_start_time_;
651
653 double first_stream_abs_start_time_;
654
656 double first_stream_rel_stop_time_;
657
659 double streams_length_;
660
662 double start_marker_time_;
663
665 double start_marker_time_play_;
666
668 QCPItemStraightLine *cur_play_pos_;
669
671 QCPItemStraightLine *start_marker_pos_;
672
674 QString playback_error_;
675
677 QSharedPointer<QCPAxisTicker> number_ticker_;
678
680 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
681
683 bool stereo_available_;
684
686 QList<RtpAudioStream *> playing_streams_;
687
689 QAudioSink *marker_stream_;
690
692 QTimer notify_timer_;
693
695 qint64 notify_timer_start_diff_;
697 quint32 marker_stream_requested_out_rate_;
698
700 QTreeWidgetItem *last_ti_;
701
703 bool listener_removed_;
704
706 QPushButton *read_btn_;
707
709 QPushButton *inaudible_btn_;
710
712 QPushButton *analyze_btn_;
713
715 QPushButton *prepare_btn_;
716
718 QPushButton *export_btn_;
719
721 QMultiHash<unsigned, RtpAudioStream *> stream_hash_;
722
724 bool block_redraw_;
725
727 int lock_ui_;
728
730 bool read_capture_enabled_;
731
733 double silence_skipped_time_;
734
736 QTimer *mouse_update_timer_;
737
739 QPoint mouse_pos_;
740
741// const QString streamKey(const rtpstream_info_t *rtpstream);
742// const QString streamKey(const packet_info *pinfo, const struct _rtp_info *rtpinfo);
743
744 // Tap callbacks
745// static void tapReset(void *tapinfo_ptr);
746
755 static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *rtpinfo_ptr, tap_flags_t flags);
756
761 static void tapDraw(void *tapinfo_ptr);
762
768 void addPacket(packet_info *pinfo, const struct _rtp_info *rtpinfo);
769
774 void zoomXAxis(bool in);
775
780 void panXAxis(int x_pixels);
781
787 const QString getFormatedTime(double f_time);
788
793 const QString getFormatedHoveredTime();
794
799 int getHoveredPacket();
800
805 QString currentOutputDeviceName();
806
811 double getStartPlayMarker();
812
816 void drawStartPlayMarker();
817
822 void setStartPlayMarker(double new_time);
823
829 void updateStartStopTime(rtpstream_info_t *rtpstream, bool is_first);
830
836 void formatAudioRouting(QTreeWidgetItem *ti, AudioRouting audio_routing);
837
842 bool isStereoAvailable();
843
848 QAudioSink *getSilenceAudioOutput();
849
854 QAudioDevice getCurrentDeviceInfo();
855
861 QTreeWidgetItem *findItemByCoords(QPoint point);
862
868 QTreeWidgetItem *findItem(QCPAbstractPlottable *plottable);
869
875 void handleItemHighlight(QTreeWidgetItem *ti, bool scroll);
876
882 void highlightItem(QTreeWidgetItem *ti, bool highlight);
883
887 void invertSelection();
888
893 void handleGoToSetupPacket(QTreeWidgetItem *ti);
894
899 void addSingleRtpStream(rtpstream_id_t *id);
900
905 void removeRow(QTreeWidgetItem *ti);
906
910 void fillAudioRateMenu();
911
915 void cleanupMarkerStream();
916
924 qint64 saveAudioHeaderAU(QFile *save_file, quint32 channels, unsigned audio_rate);
925
934 qint64 saveAudioHeaderWAV(QFile *save_file, quint32 channels, unsigned audio_rate, qint64 samples);
935
943 bool writeAudioSilenceSamples(QFile *out_file, qint64 samples, int stream_count);
944
952 bool writeAudioStreamsSamples(QFile *out_file, QVector<RtpAudioStream *> streams, bool big_endian);
953
959 save_audio_t selectFileAudioFormatAndName(QString *file_path);
960
966 save_payload_t selectFilePayloadFormatAndName(QString *file_path);
967
972 QVector<RtpAudioStream *>getSelectedAudibleNonmutedAudioStreams();
973
978 void saveAudio(save_mode_t save_mode);
979
983 void savePayload();
984
988 void lockUI();
989
993 void unlockUI();
994
999 void selectInaudible(bool select);
1000
1005 QVector<rtpstream_id_t *>getSelectedRtpStreamIDs();
1006
1010 void fillTappedColumns();
1011
1012#else // QT_MULTIMEDIA_LIB
1013private:
1015 Ui::RtpPlayerDialog *ui;
1016#endif // QT_MULTIMEDIA_LIB
1017};
1018
1019#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
RtpBaseDialog(QWidget &parent, CaptureFile &cf)
Constructs an RtpBaseDialog.
Definition rtp_player_dialog.h:82
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:141
void operator=(const RtpPlayerDialog &)=delete
Should not be assignable.
static QPushButton * addPlayerButton(QDialogButtonBox *button_box, QDialog *dialog)
Common routine to add a "Play call" button to a QDialogButtonBox.
Definition rtp_player_dialog.cpp:340
RtpPlayerDialog(RtpPlayerDialog &other)=delete
Should not be cloneable.
virtual void updateWidgets()
Updates the state and contents of the dialog's widgets.
Definition wireshark_dialog.cpp:92
WiresharkDialog(QWidget &parent, CaptureFile &capture_file)
Constructs a new WiresharkDialog object.
Definition wireshark_dialog.cpp:30
void captureEvent(CaptureEvent e)
Handles capture events.
Definition wireshark_dialog.cpp:112
virtual void accept() override
Accepts the dialog.
Definition wireshark_dialog.cpp:43
virtual void reject() override
Rejects the dialog.
Definition wireshark_dialog.cpp:50
struct epan_dissect epan_dissect_t
Opaque type representing a single packet dissection context.
Definition epan.h:62
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
save_mode_t
Defines the modes available for saving audio or payload data.
Definition rtp_player_dialog.h:64
@ save_mode_sync_file
Definition rtp_player_dialog.h:67
@ save_mode_sync_stream
Definition rtp_player_dialog.h:66
@ save_mode_from_cursor
Definition rtp_player_dialog.h:65
save_payload_t
Defines the payload formats available for saving.
Definition rtp_player_dialog.h:56
@ save_payload_data
Definition rtp_player_dialog.h:58
@ save_payload_none
Definition rtp_player_dialog.h:57
save_audio_t
Defines the audio formats available for saving.
Definition rtp_player_dialog.h:47
@ save_audio_au
Definition rtp_player_dialog.h:49
@ save_audio_wav
Definition rtp_player_dialog.h:50
@ save_audio_none
Definition rtp_player_dialog.h:48
struct _rtpstream_info rtpstream_info_t
Holds all state and statistics accumulated for a single RTP stream.
struct _rtpstream_id rtpstream_id_t
Definition packet-rtp.h:29
Definition stream.c:41
tap_packet_status
Definition tap.h:22