| 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(const QAudioFormat &format, | 
| 52 | const QAudioDevice &deviceInfo, QObject *parent); | 
| 53 | QPlatformAudioSink *audioOutputDevice(const QAudioFormat &format, | 
| 54 | const QAudioDevice &deviceInfo, QObject *parent); | 
| 55 | |
| 56 | virtual void prepareAudio(); | 
| 57 | |
| 58 | void initVideoDevicesConnection(); | 
| 59 |     virtual QLatin1String backendName() const { return QLatin1String{ "null"}; }  | 
| 60 | |
| 61 | protected: | 
| 62 | virtual QList<QAudioDevice> findAudioInputs() const { return {}; } | 
| 63 | virtual QList<QAudioDevice> findAudioOutputs() const { return {}; } | 
| 64 | |
| 65 | void onAudioInputsChanged(); | 
| 66 | void onAudioOutputsChanged(); | 
| 67 | |
| 68 | void updateAudioInputsCache(); | 
| 69 | void updateAudioOutputsCache(); | 
| 70 | |
| 71 | Q_SIGNALS: | 
| 72 | void audioInputsChanged(PrivateTag); | 
| 73 | void audioOutputsChanged(PrivateTag); | 
| 74 | |
| 75 | private: | 
| 76 | mutable QCachedValue<QList<QAudioDevice>> m_audioInputs; | 
| 77 | mutable QCachedValue<QList<QAudioDevice>> m_audioOutputs; | 
| 78 | }; | 
| 79 | |
| 80 | QT_END_NAMESPACE | 
| 81 | |
| 82 | |
| 83 | #endif // QPLATFORMAUDIODEVICES_H | 
| 84 | 
