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_videostream_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
4#ifndef QPIPEWIRE_VIDEOSTREAM_P_H
5#define QPIPEWIRE_VIDEOSTREAM_P_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/qpipewire_cameracontextmanager_p.h>
19#include <QtMultimedia/private/qpipewire_cameranode_p.h>
20#include <QtMultimedia/private/qtmultimediaglobal_p.h>
21#include <QtMultimedia/qvideoframe.h>
22#include <QtMultimedia/qvideoframeformat.h>
23#include <QtCore/qbytearray.h>
24#include <QtCore/qmutex.h>
25#include <QtCore/qobject.h>
26#include <QtCore/qsize.h>
27
28#include <bitset>
29#include <chrono>
30#include <memory>
31#include <optional>
32#include <vector>
33
34#include <spa/buffer/buffer.h>
35#include <spa/param/video/format.h>
36
37#include <pipewire/version.h>
38
39// DMABUF negotiation needs SPA_FORMAT_VIDEO_modifier/SPA_VIDEO_FLAG_MODIFIER(_FIXATION_REQUIRED)
40// and SPA_PARAM_BUFFERS_dataType, none of which older libspa headers declare.
41#if QT_CONFIG(linux_dmabuf) && PW_CHECK_VERSION(0, 3, 76)
42# define QT_PIPEWIRE_HAS_DMABUF_CAMERA 1
43#else
44# define QT_PIPEWIRE_HAS_DMABUF_CAMERA 0
45#endif
46
48# include <QtMultimedia/private/qdmabufallocator_p.h>
49#endif
50
51QT_BEGIN_NAMESPACE
52
53namespace QtPipeWire {
54
56
60
61// A DMA-BUF the camera node allocated, with a duplicate of its fd that outlives the buffer.
62struct NodeDmaBuf
63{
64 pw_buffer *pwBuffer = nullptr;
66};
67#endif
68
69class Q_MULTIMEDIA_EXPORT QPipeWireVideoStream : public QObject
70{
72
73public:
78
80
81 bool start();
82
84
88
89private:
92 void onProcess();
93
95 // Answers a SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED request with the one
96 // modifier we can read, which makes the server send a fixated format.
98
105#endif
106
107 static const pw_stream_events &streamEvents();
108
115
118
119 mutable QMutex m_formatMutex;
121
122 // Only meaningful on the event loop thread. A DMABUF buffer is only read when
123 // its layout is known: a compressed byte stream, or raw with a linear modifier.
124 bool m_dmaBufReadable = false;
126
127 // The first frame's timestamp in microseconds; frame start times are relative to it.
129
131 // Set when the stream allocates its DMA-BUF buffers itself, so they outlive the stream.
134
135 // DMA-BUFs that the camera node allocated, bound by PipeWire while the stream is connected.
138#endif
139};
140
141} // namespace QtPipeWire
142
143QT_END_NAMESPACE
144
145#endif // QPIPEWIRE_VIDEOSTREAM_P_H
Q_STATIC_LOGGING_CATEGORY(lcPipewireAudioSink, "qt.multimedia.pipewire.audiosink")
#define __has_include(x)
#define QT_PIPEWIRE_HAS_DMABUF_CAMERA