| 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 QPLATFORMAUDIODEVICES_H |
| 5 | #define QPLATFORMAUDIODEVICES_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 <QtCore/qlist.h> |
| 19 | #include <QtCore/qobject.h> |
| 20 | #include <QtMultimedia/private/qaudiodevice_p.h> |
| 21 | #include <QtMultimedia/private/qcachedvalue_p.h> |
| 22 | #include <QtMultimedia/private/qtmultimediaglobal_p.h> |
| 23 | #include <memory> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QPlatformAudioSource; |
| 28 | class QPlatformAudioSink; |
| 29 | class QAudioFormat; |
| 30 | |
| 31 | class Q_MULTIMEDIA_EXPORT QPlatformAudioDevices : public QObject |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | |
| 35 | QT_DEFINE_TAG_STRUCT(PrivateTag); |
| 36 | |
| 37 | public: |
| 38 | QPlatformAudioDevices(); |
| 39 | ~QPlatformAudioDevices() override; |
| 40 | |
| 41 | static std::unique_ptr<QPlatformAudioDevices> create(); |
| 42 | |
| 43 | QList<QAudioDevice> audioInputs() const; |
| 44 | QList<QAudioDevice> audioOutputs() const; |
| 45 | |
| 46 | virtual QPlatformAudioSource *createAudioSource(const QAudioDevice &, const QAudioFormat &, |
| 47 | QObject *parent); |
| 48 | virtual QPlatformAudioSink *createAudioSink(const QAudioDevice &, const QAudioFormat &, |
| 49 | QObject *parent); |
| 50 | |
| 51 | QPlatformAudioSource *audioInputDevice(QAudioFormat, const QAudioDevice &, QObject *parent); |
| 52 | QPlatformAudioSink *audioOutputDevice(QAudioFormat, const QAudioDevice &, QObject *parent); |
| 53 | |
| 54 | void initVideoDevicesConnection(); |
| 55 | virtual QLatin1String backendName() const { return QLatin1String{ "null" }; } |
| 56 | |
| 57 | protected: |
| 58 | virtual QList<QAudioDevice> findAudioInputs() const { return {}; } |
| 59 | virtual QList<QAudioDevice> findAudioOutputs() const { return {}; } |
| 60 | |
| 61 | void onAudioInputsChanged(); |
| 62 | void onAudioOutputsChanged(); |
| 63 | |
| 64 | void updateAudioInputsCache(); |
| 65 | void updateAudioOutputsCache(); |
| 66 | |
| 67 | Q_SIGNALS: |
| 68 | void audioInputsChanged(PrivateTag); |
| 69 | void audioOutputsChanged(PrivateTag); |
| 70 | |
| 71 | private: |
| 72 | mutable QCachedValue<QList<QAudioDevice>> m_audioInputs; |
| 73 | mutable QCachedValue<QList<QAudioDevice>> m_audioOutputs; |
| 74 | }; |
| 75 | |
| 76 | QT_END_NAMESPACE |
| 77 | |
| 78 | |
| 79 | #endif // QPLATFORMAUDIODEVICES_H |
| 80 | |