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
qlibcamera_camera_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QLIBCAMERA_CAMERA_P_H
4#define QLIBCAMERA_CAMERA_P_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 "qlibcamera_stream_p.h" // for the full QLibCameraCameraStream definition
18
19#include <QtMultimedia/private/qplatformcamera_p.h>
20#include <QtCore/private/qexpected_p.h>
21
22#include <memory>
23#include <tuple>
24#include <utility>
25#include <vector>
26
27namespace libcamera {
28class Camera;
29class CameraConfiguration;
30class FrameBufferAllocator;
31class Request;
32} // namespace libcamera
33
34QT_BEGIN_NAMESPACE
35
36namespace QLibCamera {
37
39
40class QLibCameraCamera final : public QPlatformCamera
41{
42 Q_OBJECT
43public:
44 explicit QLibCameraCamera(QCamera *parent, std::shared_ptr<QLibCameraInstance>);
46
47 bool isActive() const override { return m_active; }
48 void setActive(bool active) override;
49
50 void setCamera(const QCameraDevice &) override;
51 bool setCameraFormat(const QCameraFormat &) override;
52
53 void setExposureMode(QCamera::ExposureMode) override;
54 bool isExposureModeSupported(QCamera::ExposureMode mode) const override;
55 void setExposureCompensation(float compensation) override;
57 void setManualExposureTime(float seconds) override;
58
60 void setColorTemperature(int temperature) override;
61
62 void zoomTo(float newZoomFactor, float rate = -1.) override;
63
64 QVideoFrameFormat frameFormat() const override;
65
66private:
68 QVideoFrameFormat::ColorRange) const override;
69
70 using StartCapturingResult = q23::expected<void, std::tuple<QCamera::Error, QString>>;
71
72 StartCapturingResult startCapturing();
73 void startCapturingReportingErrors();
74 void stopCapturing();
75
76 template <typename Fn>
77 void withPendingControls(Fn &&fn)
78 {
79 if (m_stream)
80 m_stream->withPendingControls(std::forward<Fn>(fn));
81 }
82
83 // Lifecycle of the libcamera stream
84 enum class StreamState : uint8_t {
85 Idle,
86 Acquired,
87 Running,
88 };
89
90 std::shared_ptr<QLibCameraInstance> m_instance;
91 std::shared_ptr<libcamera::Camera> m_camera;
92 std::unique_ptr<QLibCameraCameraStream> m_stream;
93
94 QCameraDevice m_cameraDevice;
95 bool m_active = false;
96 StreamState m_streamState = StreamState::Idle;
97
98 std::unique_ptr<libcamera::CameraConfiguration> m_config;
99 std::unique_ptr<libcamera::FrameBufferAllocator> m_allocator;
100 std::vector<std::unique_ptr<libcamera::Request>> m_requests;
101
102 int m_stride = 0;
103 QVideoFrameFormat::ColorSpace m_colorSpace = QVideoFrameFormat::ColorSpace_Undefined;
104 QVideoFrameFormat::ColorRange m_colorRange = QVideoFrameFormat::ColorRange_Unknown;
105};
106
107} // namespace QLibCamera
108
109QT_END_NAMESPACE
110
111#endif // QLIBCAMERA_CAMERA_P_H
void setExposureCompensation(float compensation) override
void setManualIsoSensitivity(int iso) override
void setActive(bool active) override
void setCamera(const QCameraDevice &) override
void setManualExposureTime(float seconds) override
bool setCameraFormat(const QCameraFormat &) override
void zoomTo(float newZoomFactor, float rate=-1.) override
void setExposureMode(QCamera::ExposureMode) override
QVideoFrameFormat frameFormat() const override
int cameraPixelFormatScore(QVideoFrameFormat::PixelFormat, QVideoFrameFormat::ColorRange) const override
void setColorTemperature(int temperature) override
void setWhiteBalanceMode(QCamera::WhiteBalanceMode) override
bool isExposureModeSupported(QCamera::ExposureMode mode) const override
void setExposureCompensation(ControlList &pending, float stops)
void setAnalogueGainForIso(ControlList &pending, int iso)
void setAwbEnable(ControlList &pending, bool enable)
void setZoomFactor(ControlList &pending, const ControlInfoMap &controls, float zoomFactor)
void setColorTemperature(ControlList &pending, int kelvin)
void setManualExposureTime(ControlList &pending, float seconds)
void setAeEnable(ControlList &pending, bool enable)