Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qavfvideodevices_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QAVFVIDEODEVICES_H
5#define QAVFVIDEODEVICES_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 <QtMultimedia/qtmultimediaexports.h>
19#include <QtMultimedia/private/qplatformvideodevices_p.h>
20#include <QtCore/private/qcore_mac_p.h>
21
22#include <functional>
23
25
26QT_BEGIN_NAMESPACE
27
28class QPlatformMediaIntegration;
29class Q_MULTIMEDIA_EXPORT QAVFVideoDevices : public QPlatformVideoDevices
30{
31public:
32 // Takes a delegate to check whether a given CvPixelFormat is supported for a capture session.
33 // If given a nullptr, it assumes all formats are supported.
34 QAVFVideoDevices(
35 QPlatformMediaIntegration *integration,
36 std::function<bool(uint32_t)> &&isCvPixelFormatSupportedDelegate = nullptr);
37 ~QAVFVideoDevices();
38
39 // Returns true if the given CvPixelFormat is supported for camera capture session.
40 [[nodiscard]] bool isCvPixelFormatSupported(uint32_t cvPixelFormat) const;
41
42protected:
43 QList<QCameraDevice> findVideoInputs() const override;
44
45private:
46 QMacNotificationObserver m_deviceConnectedObserver;
47 QMacNotificationObserver m_deviceDisconnectedObserver;
48 std::function<bool(uint32_t)> m_isCvPixelFormatSupportedDelegate;
49
50 // We need to key-value observe the "suspended" value of all connected
51 // AVCaptureDevices in order to determine whether they should be exposed as
52 // QCameraDevice to the user.
53 struct ObservedAVCaptureDevice {
54 QMacKeyValueObserver observer;
55 AVCaptureDevice* avCaptureDevice;
56 };
57
58 void clearObservedAvCaptureDevices();
59 void rebuildObserveredAvCaptureDevices();
60 // All modifications and read of m_observedAvCaptureDevices happen by
61 // posting jobs the QAVFVideoDevices' thread, and so this doesn't need a
62 // lock.
63 QList<ObservedAVCaptureDevice> m_observedAvCaptureDevices;
64};
65
66QT_END_NAMESPACE
67
68#endif
Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureDevice)