| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
dis_audio_stream.h
Go to the documentation of this file.
1
9
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 class QAudioSink;
28
29 class DisAudioStream : public QObject
30{
31 Q_OBJECT
32 public:
33 explicit DisAudioStream(QObject *parent = nullptr);
34 ~DisAudioStream();
35
36 bool playDisStream(const disstream_info_t *stream_info, QString &error_message);
37 bool prepareVisualData(const disstream_info_t *stream_info, QString &error_message);
38 void stopPlayback(bool call_stop = true);
39 void pausePlayback();
40 void resumePlayback();
41 void setPlaybackStartTime(double start_time_secs) { playback_start_time_ = start_time_secs; }
42 bool isPlaying() const;
43 bool isPaused() const;
44 QAudio::State playbackState() const;
45 const disstream_info_t *currentStream() const { return current_stream_; }
46 double playbackDurationSeconds() const { return total_playback_secs_; }
47 const QVector<double> &visualTimestamps() const { return visual_timestamps_; }
48 const QVector<double> &visualSamples() const { return visual_samples_; }
49 const QVector<double> &jitterTimestamps() const { return jitter_timestamps_; }
50 const QVector<double> &jitterSamples() const { return jitter_samples_; }
51 const QVector<double> &lossTimestamps() const { return loss_timestamps_; }
52 const QVector<double> &lossSamples() const { return loss_samples_; }
53 const QVector<double> &problemTimestamps() const { return problem_timestamps_; }
54 const QVector<double> &problemSamples() const { return problem_samples_; }
55
56signals:
57 void playbackStateChanged(QAudio::State state);
58 void playbackProgress(double position_secs, double duration_secs);
59
60 private:
61 bool decodeToPcm(const disstream_info_t *stream_info, QString &error_message,
62 unsigned &sample_rate, unsigned &channels);
63 void buildVisualData(const disstream_info_t *stream_info);
64
65 private slots:
66 void onPlaybackStateChanged(QAudio::State state);
67 void updatePlaybackProgress();
68
69 private:
70 QByteArray pcm_buffer_;
71 QBuffer *playback_buffer_;
72 QAudioSink *audio_sink_;
73 QTimer *progress_timer_;
74 unsigned sample_rate_;
75 unsigned channels_;
76 double total_playback_secs_;
77 double playback_start_time_;
78 const disstream_info_t *current_stream_;
79 bool stopping_playback_;
80 QVector<double> visual_timestamps_;
81 QVector<double> visual_samples_;
82 QVector<double> jitter_timestamps_;
83 QVector<double> jitter_samples_;
84 QVector<double> loss_timestamps_;
85 QVector<double> loss_samples_;
86 QVector<double> problem_timestamps_;
87 QVector<double> problem_samples_;
88};
89
90#endif
91
92#endif /* DIS_AUDIO_STREAM_H */