| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
dis_audio_stream.h
Go to the documentation of this file.
1
10#ifndef DIS_AUDIO_STREAM_H
11#define DIS_AUDIO_STREAM_H
12
13#include "config.h"
14
15#ifdef QT_MULTIMEDIA_LIB
16
17#include <QAudio>
18#include <QByteArray>
19#include <QObject>
20#include <QString>
21#include <QVector>
22
23#include "ui/tap-dis-common.h"
24
25 class QBuffer;
26 class QTimer;
27#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
28 class QAudioSink;
29#else
30 class QAudioOutput;
31#endif
32
33 class DisAudioStream : public QObject
34{
35 Q_OBJECT
36 public:
37 explicit DisAudioStream(QObject *parent = nullptr);
38 ~DisAudioStream();
39
40 bool playDisStream(const disstream_info_t *stream_info, QString &error_message);
41 bool prepareVisualData(const disstream_info_t *stream_info, QString &error_message);
42 void stopPlayback(bool call_stop = true);
43 void pausePlayback();
44 void resumePlayback();
45 void setPlaybackStartTime(double start_time_secs) { playback_start_time_ = start_time_secs; }
46 bool isPlaying() const;
47 bool isPaused() const;
48 QAudio::State playbackState() const;
49 const disstream_info_t *currentStream() const { return current_stream_; }
50 double playbackDurationSeconds() const { return total_playback_secs_; }
51 const QVector<double> &visualTimestamps() const { return visual_timestamps_; }
52 const QVector<double> &visualSamples() const { return visual_samples_; }
53 const QVector<double> &jitterTimestamps() const { return jitter_timestamps_; }
54 const QVector<double> &jitterSamples() const { return jitter_samples_; }
55 const QVector<double> &lossTimestamps() const { return loss_timestamps_; }
56 const QVector<double> &lossSamples() const { return loss_samples_; }
57 const QVector<double> &problemTimestamps() const { return problem_timestamps_; }
58 const QVector<double> &problemSamples() const { return problem_samples_; }
59
60signals:
61 void playbackStateChanged(QAudio::State state);
62 void playbackProgress(double position_secs, double duration_secs);
63
64 private:
65 bool decodeToPcm(const disstream_info_t *stream_info, QString &error_message,
66 unsigned &sample_rate, unsigned &channels);
67 void buildVisualData(const disstream_info_t *stream_info);
68
69 private slots:
70 void onPlaybackStateChanged(QAudio::State state);
71 void updatePlaybackProgress();
72
73 private:
74 QByteArray pcm_buffer_;
75 QBuffer *playback_buffer_;
76#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
77 QAudioSink *audio_sink_;
78#else
79 QAudioOutput *audio_sink_;
80#endif
81 QTimer *progress_timer_;
82 unsigned sample_rate_;
83 unsigned channels_;
84 double total_playback_secs_;
85 double playback_start_time_;
86 const disstream_info_t *current_stream_;
87 bool stopping_playback_;
88 QVector<double> visual_timestamps_;
89 QVector<double> visual_samples_;
90 QVector<double> jitter_timestamps_;
91 QVector<double> jitter_samples_;
92 QVector<double> loss_timestamps_;
93 QVector<double> loss_samples_;
94 QVector<double> problem_timestamps_;
95 QVector<double> problem_samples_;
96};
97
98#endif
99
100#endif /* DIS_AUDIO_STREAM_H */
_disstream_info
Definition tap-dis-common.h:46