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 QAUDIOINPUTDEVICE_H |
5 | #define QAUDIOINPUTDEVICE_H |
6 | |
7 | #include <QtCore/qobject.h> |
8 | #include <QtMultimedia/qtmultimediaglobal.h> |
9 | #include <QtMultimedia/qaudio.h> |
10 | |
11 | #include <functional> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QAudioDevice; |
16 | class QPlatformAudioInput; |
17 | |
18 | class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject |
19 | { |
20 | Q_OBJECT |
21 | Q_PROPERTY(QAudioDevice device READ device WRITE setDevice NOTIFY deviceChanged) |
22 | Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) |
23 | Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) |
24 | |
25 | public: |
26 | explicit QAudioInput(QObject *parent = nullptr); |
27 | explicit QAudioInput(const QAudioDevice &deviceInfo, QObject *parent = nullptr); |
28 | ~QAudioInput(); |
29 | |
30 | QAudioDevice device() const; |
31 | float volume() const; |
32 | bool isMuted() const; |
33 | |
34 | public Q_SLOTS: |
35 | void setDevice(const QAudioDevice &device); |
36 | void setVolume(float volume); |
37 | void setMuted(bool muted); |
38 | |
39 | Q_SIGNALS: |
40 | void deviceChanged(); |
41 | void volumeChanged(float volume); |
42 | void mutedChanged(bool muted); |
43 | |
44 | private: |
45 | QPlatformAudioInput *handle() const { return d; } |
46 | void setDisconnectFunction(std::function<void()> disconnectFunction); |
47 | friend class QMediaCaptureSession; |
48 | Q_DISABLE_COPY(QAudioInput) |
49 | QPlatformAudioInput *d = nullptr; |
50 | }; |
51 | |
52 | QT_END_NAMESPACE |
53 | |
54 | #endif // QAUDIOINPUTDEVICE_H |
55 | |