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
22QT_BEGIN_NAMESPACE
23
24namespace QFFmpeg {
25class AudioDecoder;
26}
27
28class QFFmpegAudioDecoder : public QPlatformAudioDecoder
29{
30 Q_OBJECT
31
32public:
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
50public Q_SLOTS:
51 void newAudioBuffer(const QAudioBuffer &b);
52 void done();
53 void errorSignal(int err, const QString &errorString);
54
55private:
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
66QT_END_NAMESPACE
67
68#endif // QFFMPEGAUDIODECODER_H
69

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder_p.h