| 1 | // Copyright (C) 2022 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 QPLATFORMVIDEODEVICES_H |
| 4 | #define QPLATFORMVIDEODEVICES_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 <private/qtmultimediaglobal_p.h> |
| 18 | #include <qmediarecorder.h> |
| 19 | #include <qcameradevice.h> |
| 20 | #include <qobject.h> |
| 21 | |
| 22 | #include <private/qcachedvalue_p.h> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class QCameraDevice; |
| 27 | class QPlatformMediaIntegration; |
| 28 | |
| 29 | // Implementations should use constructor to setup device-changed notification |
| 30 | // listeners. Actual device enumeration should happen in findVideoInputs(). |
| 31 | // This allows device enumeration be deferred until user starts using QMediaDevices |
| 32 | // functionality. |
| 33 | class Q_MULTIMEDIA_EXPORT QPlatformVideoDevices : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | QT_DEFINE_TAG_STRUCT(PrivateTag); |
| 38 | public: |
| 39 | QPlatformVideoDevices(QPlatformMediaIntegration *integration); |
| 40 | |
| 41 | ~QPlatformVideoDevices() override; |
| 42 | |
| 43 | QList<QCameraDevice> videoInputs() const; |
| 44 | |
| 45 | protected: |
| 46 | // Implementation must be thread safe. Can be called from any thread as a result of |
| 47 | // QMediaDevices::videoInputs(). |
| 48 | virtual QList<QCameraDevice> findVideoInputs() const = 0; |
| 49 | |
| 50 | // Thread-safe. |
| 51 | // Called by the platform-implementation to signal that findVideoInputs() will return a new list |
| 52 | // of devices. |
| 53 | void onVideoInputsChanged(); |
| 54 | |
| 55 | // Thread-safe. Called by platform-implementation. |
| 56 | void updateVideoInputsCache(); |
| 57 | |
| 58 | Q_SIGNALS: |
| 59 | void videoInputsChanged(PrivateTag); |
| 60 | |
| 61 | protected: |
| 62 | QPlatformMediaIntegration *m_integration = nullptr; |
| 63 | mutable QCachedValue<QList<QCameraDevice>> m_videoInputs; |
| 64 | }; |
| 65 | |
| 66 | QT_END_NAMESPACE |
| 67 | |
| 68 | #endif |
| 69 | |