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
qpipewire_camera.cpp
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
5
6#include <QtMultimedia/private/qpipewire_cameracontextmanager_p.h>
7#include <QtMultimedia/private/qpipewire_videostream_p.h>
8#include <QtCore/qloggingcategory.h>
9
11
12namespace QtPipeWire {
13
14using namespace Qt::StringLiterals;
15
16Q_STATIC_LOGGING_CATEGORY(lcPipewireCamera, "qt.multimedia.pipewire.camera")
17
22
27
29{
30 return m_active;
31}
32
34{
35 if (m_active == active)
36 return;
37
39 return;
40
43
45
46 if (m_active)
48 else {
49 stopStream();
50 // Tells any attached sink to drop what it is showing
52 }
53
55}
56
58{
60 return;
61
62 const bool wasActive = m_active;
63 stopStream();
64
67
68 if (wasActive)
70}
71
73{
75 return false;
76
78 return true;
79
80 if (m_active) {
81 stopStream();
83 }
84
85 return true;
86}
87
89{
91 if (resolved.isNull())
93
95 return false;
96
98 return true;
99}
100
102{
103 // Until the stream has negotiated a format, report what was requested, so
104 // that a sink has something to work with.
105 if (m_stream) {
107 if (negotiated.isValid())
108 return negotiated;
109 }
110
112}
113
115{
117
119
120 const std::optional<QByteArray> target =
122 if (!target) {
123 const QByteArray id = m_cameraDevice.id();
124 if (!id.startsWith("pw:")) {
126 u"The camera id \"%1\" does not name a PipeWire camera. Camera ids are "
127 "not interchangeable between backends."_s.arg(QString::fromUtf8(id)));
128 } else {
130 u"No PipeWire camera with the id \"%1\" is present."_s.arg(
131 QString::fromUtf8(id)));
132 }
133 return;
134 }
135
139
143 [this](const QString &errorString) {
145 }, Qt::QueuedConnection);
146
147 if (!m_stream->start()) {
148 m_stream.reset();
149 updateError(QCamera::CameraError, u"Could not start the PipeWire camera stream."_s);
150 return;
151 }
152
153 qCDebug(lcPipewireCamera) << "streaming from" << *target << "as" << m_cameraFormat.pixelFormat()
155}
156
158{
159 m_stream.reset();
160}
161
162} // namespace QtPipeWire
163
164QT_END_NAMESPACE
Combined button and popup list for selecting options.
Q_STATIC_LOGGING_CATEGORY(lcPipewireAudioSink, "qt.multimedia.pipewire.audiosink")