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