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#ifndef QFFMPEGAUDIOINPUT_H
4#define QFFMPEGAUDIOINPUT_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <QtMultimedia/qaudioinput.h>
18#include <QtMultimedia/private/qplatformaudioinput_p.h>
19#include <QtMultimedia/private/qplatformaudiobufferinput_p.h>
20#include <QtFFmpegMediaPluginImpl/private/qffmpegthread_p.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QFFmpeg {
25class AudioSourceIO;
26} // namespace QFFmpeg
27
28constexpr int DefaultAudioInputBufferSize = 4096;
29
30class QFFmpegAudioInput : public QAudioBufferSource, public QPlatformAudioInput
31{
32 // for qobject_cast
33 Q_OBJECT
34public:
35 explicit QFFmpegAudioInput(QAudioInput *qq);
36 ~QFFmpegAudioInput() override;
37
38 void setAudioDevice(const QAudioDevice &/*device*/) override;
39 void setMuted(bool /*muted*/) override;
40 void setVolume(float /*volume*/) override;
41
42 void setBufferSize(int bufferSize);
43
44 int bufferSize() const;
45
46protected:
47 // ensures the underlying audio source is run if
48 // the signal newAudioBuffer is connected
49 void connectNotify(const QMetaMethod &signal) override;
50
51 // postponly ensures that the underlying audio source is not run
52 // if the signal newAudioBuffer is not connacted to any slot.
53 void disconnectNotify(const QMetaMethod &signal) override;
54
55private:
56 QFFmpeg::AudioSourceIO *m_audioIO = nullptr;
57 std::unique_ptr<QThread> m_inputThread;
58};
59
60QT_END_NAMESPACE
61
62
63#endif // QPLATFORMAUDIOINPUT_H
64

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