1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QFFMPEGAUDIODECODER_H |
5 | #define QFFMPEGAUDIODECODER_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "private/qplatformaudiodecoder_p.h" |
19 | #include <qffmpeg_p.h> |
20 | #include <qurl.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | namespace QFFmpeg { |
25 | class AudioDecoder; |
26 | } |
27 | |
28 | class QFFmpegAudioDecoder : public QPlatformAudioDecoder |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | QFFmpegAudioDecoder(QAudioDecoder *parent); |
34 | virtual ~QFFmpegAudioDecoder(); |
35 | |
36 | QUrl source() const override; |
37 | void setSource(const QUrl &fileName) override; |
38 | |
39 | QIODevice *sourceDevice() const override; |
40 | void setSourceDevice(QIODevice *device) override; |
41 | |
42 | void start() override; |
43 | void stop() override; |
44 | |
45 | QAudioFormat audioFormat() const override; |
46 | void setAudioFormat(const QAudioFormat &format) override; |
47 | |
48 | QAudioBuffer read() override; |
49 | |
50 | public Q_SLOTS: |
51 | void newAudioBuffer(const QAudioBuffer &b); |
52 | void done(); |
53 | void errorSignal(int err, const QString &errorString); |
54 | |
55 | private: |
56 | using AudioDecoder = QFFmpeg::AudioDecoder; |
57 | |
58 | QUrl m_url; |
59 | QIODevice *m_sourceDevice = nullptr; |
60 | std::unique_ptr<AudioDecoder> m_decoder; |
61 | QAudioFormat m_audioFormat; |
62 | |
63 | QAudioBuffer m_audioBuffer; |
64 | }; |
65 | |
66 | QT_END_NAMESPACE |
67 | |
68 | #endif // QFFMPEGAUDIODECODER_H |
69 | |