Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qlibcamera_stream_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_STREAM_P_H
4
#
define
QLIBCAMERA_STREAM_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
<
QtMultimedia
/
qvideoframe
.
h
>
18
#
include
<
QtMultimedia
/
qvideoframeformat
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qtmultimediaglobal_p
.
h
>
20
#
include
<
QtCore
/
private
/
qexpected_p
.
h
>
21
#
include
<
QtCore
/
qmutex
.
h
>
22
#
include
<
QtCore
/
qobject
.
h
>
23
24
#
include
<
libcamera
/
controls
.
h
>
25
26
#
include
<
chrono
>
27
#
include
<
memory
>
28
#
include
<
mutex
>
29
#
include
<
optional
>
30
31
namespace
libcamera
{
32
class
Camera;
33
class
FrameBuffer;
34
class
Request;
35
class
Stream;
36
}
// namespace libcamera
37
38
QT_BEGIN_NAMESPACE
39
40
namespace
QLibCamera
{
41
42
#
if
QT_CONFIG
(
linux_dmabuf
)
43
class
QLibCameraDmaBufRegistry
;
44
#
endif
45
46
// Number of buffers requested from libcamera for a stream.
47
inline
constexpr
unsigned
kCaptureBufferCount
= 8;
48
49
// Controls set by the application. They are merged into the next request queued on the camera.
50
class
QLibCameraPendingControls
51
{
52
public
:
53
template
<
typename
Fn>
54
void
with
(Fn &&fn)
55
{
56
std
::lock_guard lock(m_mutex);
57
fn(m_controls);
58
}
59
60
void
mergeInto
(libcamera::ControlList &controls)
61
{
62
std
::lock_guard lock(m_mutex);
63
controls.merge(m_controls, libcamera::ControlList::MergePolicy::OverwriteExisting);
64
}
65
66
private
:
67
QMutex m_mutex;
68
libcamera::ControlList m_controls;
69
};
70
71
// Re-arms a completed request, applies the pending controls and queues it on the camera again.
72
void
requeueRequest
(
libcamera
::Camera &camera,
libcamera
::Request *request,
73
QLibCameraPendingControls
&pendingControls);
74
75
class
QLibCameraCameraStream
final
:
public
QObject
76
{
77
Q_OBJECT
78
public
:
79
QLibCameraCameraStream
(
std
::
shared_ptr
<
libcamera
::
Camera
>,
libcamera
::
Stream
*,
80
int
bytesPerLine
,
QVideoFrameFormat
,
double
maxFrameRate
,
81
std
::
shared_ptr
<
QLibCameraPendingControls
>
82
#
if
QT_CONFIG
(
linux_dmabuf
)
83
,
84
std
::
shared_ptr
<
QLibCameraDmaBufRegistry
>
85
#
endif
86
);
87
88
// Runs on libcamera's CameraManager thread -- see the class comment above.
89
void
handleRequestCompleted
(
libcamera
::Request *);
90
91
libcamera
::Stream *
stream
()
const
{
return
m_stream; }
92
93
Q_SIGNALS
:
94
void
newVideoFrame
(
const
QVideoFrame
&);
95
96
private
:
97
q23::expected<QVideoFrame, QString> createFrame(
libcamera
::Request *,
98
const
libcamera
::FrameBuffer &);
99
100
const
std
::shared_ptr<
libcamera
::Camera> m_libcameraCamera;
101
libcamera
::Stream *
const
m_stream;
102
const
int
m_bytesPerLine;
103
const
QVideoFrameFormat m_frameFormat;
104
const
double
m_maxFrameRate;
105
const
std
::shared_ptr<
QLibCameraPendingControls
> m_pendingControls;
106
#
if
QT_CONFIG
(
linux_dmabuf
)
107
const
std
::
shared_ptr
<
QLibCameraDmaBufRegistry
>
m_dmaBufRegistry
;
108
#
endif
109
110
std
::optional<
std
::chrono::nanoseconds> m_firstFrameTimestamp;
111
};
112
113
}
// namespace QLibCamera
114
115
QT_END_NAMESPACE
116
117
#
endif
// QLIBCAMERA_STREAM_P_H
QLibCamera::QLibCameraCameraStream::QLibCameraCameraStream
QLibCameraCameraStream(std::shared_ptr< libcamera::Camera >, libcamera::Stream *, int bytesPerLine, QVideoFrameFormat, double maxFrameRate, std::shared_ptr< QLibCameraPendingControls >)
Definition
qlibcamera_stream.cpp:162
QLibCamera::QLibCameraCameraStream::handleRequestCompleted
void handleRequestCompleted(libcamera::Request *)
Definition
qlibcamera_stream.cpp:203
QLibCamera::QLibCameraCameraStream::stream
libcamera::Stream * stream() const
Definition
qlibcamera_stream_p.h:91
QLibCamera::QLibCameraCamera::setExposureCompensation
void setExposureCompensation(float compensation) override
Definition
qlibcamera_camera.cpp:460
QLibCamera::QLibCameraCamera::setManualIsoSensitivity
void setManualIsoSensitivity(int iso) override
Definition
qlibcamera_camera.cpp:468
QLibCamera::QLibCameraCamera::setActive
void setActive(bool active) override
Definition
qlibcamera_camera.cpp:82
QLibCamera::QLibCameraCamera::setCamera
void setCamera(const QCameraDevice &) override
Definition
qlibcamera_camera.cpp:115
QLibCamera::QLibCameraCamera::setManualExposureTime
void setManualExposureTime(float seconds) override
Definition
qlibcamera_camera.cpp:476
QLibCamera::QLibCameraCamera::setCameraFormat
bool setCameraFormat(const QCameraFormat &) override
Definition
qlibcamera_camera.cpp:159
QLibCamera::QLibCameraCamera::zoomTo
void zoomTo(float newZoomFactor, float rate=-1.) override
Definition
qlibcamera_camera.cpp:502
QLibCamera::QLibCameraCamera::~QLibCameraCamera
~QLibCameraCamera() override
Definition
qlibcamera_camera.cpp:60
QLibCamera::QLibCameraCamera::setExposureMode
void setExposureMode(QCamera::ExposureMode) override
Definition
qlibcamera_camera.cpp:445
QLibCamera::QLibCameraCamera::frameFormat
QVideoFrameFormat frameFormat() const override
Definition
qlibcamera_camera.cpp:513
QLibCamera::QLibCameraCamera::cameraPixelFormatScore
int cameraPixelFormatScore(QVideoFrameFormat::PixelFormat, QVideoFrameFormat::ColorRange) const override
Definition
qlibcamera_camera.cpp:65
QLibCamera::QLibCameraCamera::setColorTemperature
void setColorTemperature(int temperature) override
Definition
qlibcamera_camera.cpp:494
QLibCamera::QLibCameraCamera::isActive
bool isActive() const override
Definition
qlibcamera_camera_p.h:49
QLibCamera::QLibCameraCamera::setWhiteBalanceMode
void setWhiteBalanceMode(QCamera::WhiteBalanceMode) override
Definition
qlibcamera_camera.cpp:484
QLibCamera::QLibCameraCamera::isExposureModeSupported
bool isExposureModeSupported(QCamera::ExposureMode mode) const override
Definition
qlibcamera_camera.cpp:455
QLibCamera::QLibCameraInstance
Definition
qlibcamera_instance_p.h:32
QLibCamera::QLibCameraPendingControls
Definition
qlibcamera_stream_p.h:51
QLibCamera::QLibCameraPendingControls::mergeInto
void mergeInto(libcamera::ControlList &controls)
Definition
qlibcamera_stream_p.h:60
QLibCamera::QLibCameraPendingControls::with
void with(Fn &&fn)
Definition
qlibcamera_stream_p.h:54
QLibCamera::QLibCameraControls
Definition
qlibcamera_controls.cpp:16
QLibCamera::QLibCameraControls::setExposureCompensation
void setExposureCompensation(ControlList &pending, float stops)
Definition
qlibcamera_controls.cpp:48
QLibCamera::QLibCameraControls::setAnalogueGainForIso
void setAnalogueGainForIso(ControlList &pending, int iso)
Definition
qlibcamera_controls.cpp:53
QLibCamera::QLibCameraControls::setAwbEnable
void setAwbEnable(ControlList &pending, bool enable)
Definition
qlibcamera_controls.cpp:60
QLibCamera::QLibCameraControls::setZoomFactor
void setZoomFactor(ControlList &pending, const ControlInfoMap &controls, float zoomFactor)
Definition
qlibcamera_controls.cpp:71
QLibCamera::QLibCameraControls::setColorTemperature
void setColorTemperature(ControlList &pending, int kelvin)
Definition
qlibcamera_controls.cpp:65
QLibCamera::QLibCameraControls::setManualExposureTime
void setManualExposureTime(ControlList &pending, float seconds)
Definition
qlibcamera_controls.cpp:41
QLibCamera::QLibCameraControls::setAeEnable
void setAeEnable(ControlList &pending, bool enable)
Definition
qlibcamera_controls.cpp:36
QLibCamera::QLibCameraFormatSupport
Definition
qlibcamera_format_support.cpp:26
QLibCamera
Definition
qplatformlibcameraintegration.cpp:13
QLibCamera::kCaptureBufferCount
constexpr unsigned kCaptureBufferCount
Definition
qlibcamera_stream_p.h:47
QLibCamera::requeueRequest
void requeueRequest(libcamera::Camera &camera, libcamera::Request *request, QLibCameraPendingControls &pendingControls)
libcamera
Definition
qlibcamera_camera_p.h:29
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtmultimedia
src
plugins
libcamera
qlibcamera_stream_p.h
Generated on
for Qt by
1.18.0