6#include <QtMultimedia/private/qcapturablewindow_p.h>
7#include <QtMultimedia/private/qmemoryvideobuffer_p.h>
8#include <QtMultimedia/private/qpipewire_instance_p.h>
9#include <QtMultimedia/private/qvideoframe_p.h>
10#include <QtMultimedia/private/qvideoframeconversionhelper_p.h>
11#include <QtMultimedia/qabstractvideobuffer.h>
12#include <QtGui/private/qdesktopunixservices_p.h>
13#include <QtGui/private/qguiapplication_p.h>
14#include <QtGui/qguiapplication.h>
15#include <QtGui/qpa/qplatformintegration.h>
16#include <QtGui/qscreen.h>
17#include <QtGui/qwindow.h>
18#include <QtCore/private/qcore_unix_p.h>
19#include <QtCore/qdebug.h>
20#include <QtCore/qfileinfo.h>
21#include <QtCore/qloggingcategory.h>
22#include <QtCore/qmutex.h>
23#include <QtCore/qrandom.h>
24#include <QtCore/qurlquery.h>
25#include <QtCore/quuid.h>
26#include <QtCore/qvariantmap.h>
27#include <QtDBus/qdbusconnection.h>
28#include <QtDBus/qdbusinterface.h>
29#include <QtDBus/qdbusmessage.h>
30#include <QtDBus/qdbuspendingcall.h>
31#include <QtDBus/qdbuspendingreply.h>
32#include <QtDBus/qdbusreply.h>
33#include <QtDBus/qdbusunixfiledescriptor.h>
39QT_WARNING_DISABLE_CLANG(
"-Wunused-value")
43using namespace Qt::StringLiterals;
53 QDBusConnection bus = QDBusConnection::sessionBus();
54 auto *interface =
new QDBusInterface(u"org.freedesktop.portal.Desktop"_s,
55 u"/org/freedesktop/portal/desktop"_s,
56 u"org.freedesktop.DBus.Properties"_s, bus, qGuiApp);
59 args << u"org.freedesktop.portal.ScreenCast"_s << u"version"_s;
61 QDBusMessage reply = interface->callWithArgumentList(QDBus::Block, u"Get"_s, args);
62 qCDebug(qLcPipeWireCapture) <<
"v1=" << reply.type()
63 <<
"v2=" << reply.arguments().size()
64 <<
"v3=" << reply.arguments().at(0).toUInt();
65 if (reply.type() == QDBusMessage::ReplyMessage
66 && reply.arguments().size() == 1
71 qCDebug(qLcPipeWireCapture) << Q_FUNC_INFO <<
"hasScreenCastPortal=" << hasScreenCastPortal;
81 : QSurfaceCaptureGrabber(CreateGrabbingThread),
95 return std::move(m_currentFrame);
100 QSurfaceCaptureGrabber::initializeGrabbingContext();
101 if (m_state == NoState)
107 if (m_state != NoState)
109 QSurfaceCaptureGrabber::finalizeGrabbingContext();
114 return m_videoFrameFormat;
122 return globalState->hasScreenCastPortal;
128 qCDebug(qLcPipeWireCapture) << Q_FUNC_INFO <<
"result=" << result <<
"map=" << map;
130 m_operationState = NoOperation;
131 qWarning() <<
"Failed to capture screen via pipewire, perhaps because user cancelled the operation.";
136 switch (m_operationState) {
138 selectSources(map[u"session_handle"_s].toString());
144 updateStreams(map[u"streams"_s].value<QDBusArgument>());
145 openPipeWireRemote();
146 m_operationState = NoOperation;
149 case OpenPipeWireRemote:
150 m_operationState = NoOperation;
159 return QRandomGenerator::global()->bounded(1, 25600);
164 if (m_requestToken <= 0)
166 return u"u%1%2"_s.arg(m_requestTokenPrefix).arg(m_requestToken);
173 if (!globalState->hasScreenCastPortal)
176 m_operationState = NoOperation;
178 if (!m_screenCastInterface) {
179 m_screenCastInterface = std::make_unique<QDBusInterface>(
180 u"org.freedesktop.portal.Desktop"_s, u"/org/freedesktop/portal/desktop"_s,
181 u"org.freedesktop.portal.ScreenCast"_s, QDBusConnection::sessionBus());
182 bool ok = m_screenCastInterface->connection().connect(
183 u"org.freedesktop.portal.Desktop"_s, u""_s, u"org.freedesktop.portal.Request"_s,
184 u"Response"_s,
this, SLOT(gotRequestResponse(uint,QVariantMap)));
188 QPlatformSurfaceCapture::Error::InternalError,
189 u"Failed to connect to org.freedesktop.portal.ScreenCast dbus interface."_s);
198 if (!m_screenCastInterface)
203 { u"session_handle_token"_s, getRequestToken() },
205 QDBusMessage reply = m_screenCastInterface->call(u"CreateSession"_s, options);
206 if (!reply.errorMessage().isEmpty()) {
207 updateError(QPlatformSurfaceCapture::Error::InternalError,
208 u"Failed to create session for org.freedesktop.portal.ScreenCast. Error: "_s
209 + reply.errorName() + u": "_s + reply.errorMessage());
213 m_operationState = CreateSession;
218 if (!m_screenCastInterface)
221 m_sessionHandle = sessionHandle;
223 { u"handle_token"_s, getRequestToken() },
224 { u"types"_s, (uint)1 },
225 { u"multiple"_s,
false },
226 { u"cursor_mode"_s, (uint)1 },
227 { u"persist_mode"_s, (uint)0 },
229 QDBusMessage reply = m_screenCastInterface->call(u"SelectSources"_s,
230 QDBusObjectPath(sessionHandle), options);
231 if (!reply.errorMessage().isEmpty()) {
232 updateError(QPlatformSurfaceCapture::Error::InternalError,
233 u"Failed to select sources for org.freedesktop.portal.ScreenCast. Error: "_s
234 + reply.errorName() + u": "_s + reply.errorMessage());
238 m_operationState = SelectSources;
243 if (!m_screenCastInterface)
247 { u"handle_token"_s, getRequestToken() },
250 auto *unixServices =
dynamic_cast<QDesktopUnixServices *>(QGuiApplicationPrivate::platformIntegration()->services());
251 const QString parentWindow = QGuiApplication::focusWindow() && unixServices
252 ? unixServices->portalWindowIdentifier(QGuiApplication::focusWindow())
254 QDBusMessage reply = m_screenCastInterface->call(
"Start"_L1, QDBusObjectPath(m_sessionHandle),
255 parentWindow, options);
256 if (!reply.errorMessage().isEmpty()) {
257 updateError(QPlatformSurfaceCapture::Error::InternalError,
258 u"Failed to start stream for org.freedesktop.portal.ScreenCast. Error: "_s
259 + reply.errorName() + u": "_s + reply.errorMessage());
263 m_operationState = StartStream;
270 streamsInfo.beginStructure();
271 streamsInfo.beginArray();
273 while (!streamsInfo.atEnd()) {
275 streamsInfo >> nodeId;
276 QMap<QString, QVariant> properties;
277 streamsInfo >> properties;
281 if (properties.contains(u"position"_s)) {
282 const auto position = properties[u"position"_s].value<QDBusArgument>();
283 position.beginStructure();
286 position.endStructure();
291 if (properties.contains(u"size"_s)) {
292 const auto size = properties[u"size"_s].value<QDBusArgument>();
293 size.beginStructure();
300 if (properties.contains(u"source_type"_s))
301 sourceType = properties[u"source_type"_s].toUInt();
303 StreamInfo streamInfo;
304 streamInfo.nodeId = nodeId;
305 streamInfo.sourceType = sourceType;
306 streamInfo.rect = {x, y, width, height};
307 m_streams << streamInfo;
310 streamsInfo.endArray();
311 streamsInfo.endStructure();
317 if (!m_screenCastInterface)
321 QDBusReply<QDBusUnixFileDescriptor> reply = m_screenCastInterface->call(
322 u"OpenPipeWireRemote"_s, QDBusObjectPath(m_sessionHandle), options);
323 if (!reply.isValid()) {
325 QPlatformSurfaceCapture::Error::InternalError,
326 u"Failed to open pipewire remote for org.freedesktop.portal.ScreenCast. Error: name="_s
327 + reply.error().name() + u", message="_s + reply.error().message());
331 m_pipewireFd = reply.value().fileDescriptor();
332 bool ok =
open(m_pipewireFd
);
333 qCDebug(qLcPipeWireCapture) <<
"open(" << m_pipewireFd <<
") result=" << ok;
335 updateError(QPlatformSurfaceCapture::Error::InternalError,
336 u"Failed to open pipewire remote file descriptor"_s);
340 m_operationState = OpenPipeWireRemote;
347 LoopLocker(pw_thread_loop *threadLoop)
348 : m_threadLoop(threadLoop) {
357 pw_thread_loop_lock(m_threadLoop);
362 pw_thread_loop_unlock(m_threadLoop);
363 m_threadLoop =
nullptr;
368 pw_thread_loop *m_threadLoop =
nullptr;
374 if (m_streams.isEmpty())
381 m_instance = QPipeWireInstance::instance();
383 static const pw_core_events coreEvents = {
384 .version = PW_VERSION_CORE_EVENTS,
385 .info = [](
void *data,
const struct pw_core_info *info) {
389 .done = [](
void *object, uint32_t id,
int seq) {
392 .ping = [](
void *data, uint32_t id,
int seq) {
397 .error = [](
void *data, uint32_t id,
int seq,
int res,
const char *message) {
404 .remove_id = [](
void *data, uint32_t id) {
408 .bound_id = [](
void *data, uint32_t id, uint32_t global_id) {
413 .add_mem = [](
void *data, uint32_t id, uint32_t type,
int fd, uint32_t flags) {
420 .remove_mem = [](
void *data, uint32_t id) {
424#if defined(PW_CORE_EVENT_BOUND_PROPS)
425 .bound_props = [](
void *data, uint32_t id, uint32_t global_id,
const struct spa_dict *props) {
434 static const pw_registry_events registryEvents = {
435 .version = PW_VERSION_REGISTRY_EVENTS,
436 .global = [](
void *object, uint32_t id, uint32_t permissions,
const char *type, uint32_t version,
const spa_dict *props) {
437 reinterpret_cast<QPipeWireCaptureHelper *>(object)->onRegistryEventGlobal(id, permissions, type, version, props);
439 .global_remove = [](
void *data, uint32_t id) {
445 m_threadLoop = PwThreadLoopHandle{
446 pw_thread_loop_new(
"qt-multimedia-pipewire-loop",
nullptr),
450 updateError(QPlatformSurfaceCapture::Error::InternalError,
451 u"QPipeWireCaptureHelper failed at pw_thread_loop_new()."_s);
455 m_context = PwContextHandle{
456 pw_context_new(pw_thread_loop_get_loop(m_threadLoop.get()),
nullptr, 0),
460 updateError(QPlatformSurfaceCapture::Error::InternalError,
461 u"QPipeWireCaptureHelper failed at pw_context_new()."_s);
465 m_core = PwCoreConnectionHandle{
466 pw_context_connect_fd(m_context.get(), fcntl(pipewireFd, F_DUPFD_CLOEXEC, 5),
nullptr, 0),
470 updateError(QPlatformSurfaceCapture::Error::InternalError,
471 u"QPipeWireCaptureHelper failed at pw_context_connect_fd()."_s);
475 pw_core_add_listener(m_core.get(), &m_coreListener, &coreEvents,
this);
477 m_registry = PwRegistryHandle{
478 pw_core_get_registry(m_core.get(), PW_VERSION_REGISTRY, 0),
482 updateError(QPlatformSurfaceCapture::Error::InternalError,
483 u"QPipeWireCaptureHelper failed at pw_core_get_registry()."_s);
486 pw_registry_add_listener(m_registry.get(), &m_registryListener, ®istryEvents,
this);
490 if (pw_thread_loop_start(m_threadLoop.get()) != 0) {
492 updateError(QPlatformSurfaceCapture::Error::InternalError,
493 u"QPipeWireCaptureHelper failed at pw_thread_loop_start()."_s);
497 LoopLocker locker(m_threadLoop.get());
498 while (!m_initDone) {
499 if (pw_thread_loop_timed_wait(m_threadLoop.get(), 2) != 0)
503 return m_initDone && m_hasSource;
508 m_coreInitSeq = pw_core_sync(m_core.get(), PW_ID_CORE, m_coreInitSeq);
513 if (id == PW_ID_CORE && seq == m_coreInitSeq) {
514 spa_hook_remove(&m_registryListener);
515 spa_hook_remove(&m_coreListener);
518 pw_thread_loop_signal(m_threadLoop.get(),
false);
522void QPipeWireCaptureHelper::onRegistryEventGlobal(uint32_t id, uint32_t permissions,
const char *type, uint32_t version,
const spa_dict *props)
525 Q_UNUSED(permissions)
528 if (qstrcmp(type, PW_TYPE_INTERFACE_Node) != 0)
531 const auto* media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
535 if (qstrcmp(media_class,
"Stream/Output/Video") != 0
536 && qstrcmp(media_class,
"Video/Source") != 0)
553Rate rateFromFps(qreal fps)
556 const std::initializer_list<Rate> ntscRates = {
557 { 23.976, SPA_FRACTION(24'000, 1'001) },
558 { 29.97, SPA_FRACTION(30'000, 1'001) },
559 { 59.94, SPA_FRACTION(60'000, 1'001) },
564 for (
const Rate &rate : ntscRates) {
565 constexpr float precision = 0.01f;
566 if (qAbs(fps - rate.fps) < precision)
572 quint32 roundedFps = qMax(qFloor(fps), 1);
573 return { qreal(roundedFps), SPA_FRACTION(roundedFps, 1) };
580 static const pw_stream_events streamEvents = {
581 .version = PW_VERSION_STREAM_EVENTS,
582 .destroy = [](
void *data) {
585 .state_changed = [](
void *data, pw_stream_state old, pw_stream_state state,
const char *error) {
588 .control_info = [](
void *data, uint32_t id,
const struct pw_stream_control *control) {
593 .io_changed = [](
void *data, uint32_t id,
void *area, uint32_t size) {
599 .param_changed = [](
void *data, uint32_t id,
const struct spa_pod *param) {
602 .add_buffer = [](
void *data,
struct pw_buffer *buffer) {
606 .remove_buffer = [](
void *data,
struct pw_buffer *buffer) {
610 .process = [](
void *data) {
613 .drained = [](
void *data) {
616#if PW_VERSION_STREAM_EVENTS
>= 1
617 .command = [](
void *data,
const struct spa_command *command) {
622#if PW_VERSION_STREAM_EVENTS
>= 2
623 .trigger_done = [](
void *data) {
631 auto streamInfo = m_streams[0];
632 struct std::array<spa_dict_item, 4> items;
633 struct spa_dict info;
634 items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_TYPE,
"Video");
635 items[1] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_CATEGORY,
"Capture");
636 items[2] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_ROLE,
"Screen");
637 info = SPA_DICT_INIT(items.data(), 3);
638 auto *props = pw_properties_new_dict(&info);
640 LoopLocker locker(m_threadLoop.get());
642 m_stream = PwStreamHandle{
643 pw_stream_new(m_core.get(),
"video-capture", props),
648 updateError(QPlatformSurfaceCapture::Error::InternalError,
649 u"QPipeWireCaptureHelper failed at pw_stream_new()."_s);
653 m_streamListener = {};
654 pw_stream_add_listener(m_stream.get(), &m_streamListener, &streamEvents,
this);
658 QT_WARNING_DISABLE_GCC(
"-Wmissing-field-initializers")
659 QT_WARNING_DISABLE_CLANG(
"-Wmissing-field-initializers")
661 std::array<uint8_t, 4096> buffer;
662 struct spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer.data(),
sizeof(buffer));
663 struct spa_rectangle defsize = SPA_RECTANGLE(quint32(streamInfo.rect.width()), quint32(streamInfo.rect.height()));
664 struct spa_rectangle maxsize = SPA_RECTANGLE(4096, 4096);
665 struct spa_rectangle minsize = SPA_RECTANGLE(1,1);
668 struct spa_fraction maxrate = SPA_FRACTION(1000, 1);
669 struct spa_fraction minrate = SPA_FRACTION(0, 1);
670 auto rate = rateFromFps(frameRate());
672 std::array<
const struct spa_pod *, 1> params{
static_cast<
const spa_pod*>(spa_pod_builder_add_object(
674 SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
675 SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),
676 SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
677 SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(6,
678 SPA_VIDEO_FORMAT_RGB,
679 SPA_VIDEO_FORMAT_BGR,
680 SPA_VIDEO_FORMAT_RGBA,
681 SPA_VIDEO_FORMAT_BGRA,
682 SPA_VIDEO_FORMAT_RGBx,
683 SPA_VIDEO_FORMAT_BGRx),
684 SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
685 &defsize, &minsize, &maxsize),
686 SPA_FORMAT_VIDEO_framerate, SPA_POD_CHOICE_RANGE_Fraction(
687 &rate.frac, &minrate, &maxrate),
688 SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_Fraction(&rate.frac))
692 const int connectErr = pw_stream_connect(
693 m_stream.get(), PW_DIRECTION_INPUT, streamInfo.nodeId,
694 static_cast<pw_stream_flags>(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS),
696 if (connectErr != 0) {
699 updateError(QPlatformSurfaceCapture::Error::InternalError,
700 u"QPipeWireCaptureHelper failed at pw_stream_connect()."_s);
710 LoopLocker locker(m_threadLoop.get());
711 while (!m_streamPaused && !m_silence && !m_err) {
712 if (pw_thread_loop_timed_wait(m_threadLoop.get(), 1) != 0)
717 LoopLocker locker(m_threadLoop.get());
718 m_ignoreStateChange =
true;
719 pw_stream_disconnect(m_stream.get());
721 m_ignoreStateChange =
false;
733 pw_thread_loop_signal(m_threadLoop.get(),
false);
741 if (m_ignoreStateChange)
746 case PW_STREAM_STATE_UNCONNECTED:
747 signalLoop(
false,
true);
749 case PW_STREAM_STATE_PAUSED:
750 m_streamPaused =
true;
751 signalLoop(
false,
false);
753 case PW_STREAM_STATE_STREAMING:
754 m_streamPaused =
false;
755 signalLoop(
false,
false);
763 struct pw_buffer *pwBuffer = pw_stream_dequeue_buffer(m_stream.get());
765 updateError(QPlatformSurfaceCapture::Error::InternalError,
766 u"Out of buffers in pipewire stream dequeue."_s);
770 struct spa_buffer *buf = pwBuffer->buffer;
771 void *sdata = buf->datas[0].data;
775 int sstride = buf->datas[0].chunk->stride;
777 sstride =
int(buf->datas[0].chunk->size / m_size.height());
778 qsizetype size = buf->datas[0].chunk->size;
780 if (m_videoFrameFormat.frameSize() != m_size || m_videoFrameFormat.pixelFormat() != m_pixelFormat)
781 m_videoFrameFormat = QVideoFrameFormat(m_size, m_pixelFormat);
783 m_currentFrame = QVideoFramePrivate::createFrame(
784 std::make_unique<QMemoryVideoBuffer>(QByteArray(
static_cast<
const char *>(sdata), size), sstride),
786 qCDebug(qLcPipeWireCaptureMore) <<
"got a frame of size " << buf->datas[0].chunk->size;
788 pw_stream_queue_buffer(m_stream.get(), pwBuffer);
790 signalLoop(
true,
false);
798 destroyStream(
false);
800 pw_thread_loop_stop(m_threadLoop.get());
812 if (param ==
nullptr || id != SPA_PARAM_Format)
815 if (spa_format_parse(param,
816 &m_format.media_type,
817 &m_format.media_subtype) < 0)
820 if (m_format.media_type != SPA_MEDIA_TYPE_video
821 || m_format.media_subtype != SPA_MEDIA_SUBTYPE_raw)
824 if (spa_format_video_raw_parse(param, &m_format.info.raw) < 0)
827 qCDebug(qLcPipeWireCapture) <<
"got video format:";
828 qCDebug(qLcPipeWireCapture) <<
" format: " << m_format.info.raw.format
829 <<
" (" << spa_debug_type_find_name(spa_type_video_format, m_format.info.raw.format) <<
")";
830 qCDebug(qLcPipeWireCapture) <<
" size: " << m_format.info.raw.size.width
831 <<
" x " << m_format.info.raw.size.height;
832 qCDebug(qLcPipeWireCapture) <<
" framerate: " << m_format.info.raw.framerate.num
833 <<
" / " << m_format.info.raw.framerate.denom;
835 m_size = QSize(
static_cast<
int>(m_format.info.raw.size.width),
836 static_cast<
int>(m_format.info.raw.size.height));
837 m_pixelFormat = QPipeWireCaptureHelper::toQtPixelFormat(m_format.info.raw.format);
838 qCDebug(qLcPipeWireCapture) <<
"m_pixelFormat=" << m_pixelFormat;
846 switch (spaVideoFormat) {
849 case SPA_VIDEO_FORMAT_I420:
850 return QVideoFrameFormat::Format_YUV420P;
851 case SPA_VIDEO_FORMAT_Y42B:
852 return QVideoFrameFormat::Format_YUV422P;
853 case SPA_VIDEO_FORMAT_YV12:
854 return QVideoFrameFormat::Format_YV12;
855 case SPA_VIDEO_FORMAT_UYVY:
856 return QVideoFrameFormat::Format_UYVY;
857 case SPA_VIDEO_FORMAT_YUY2:
858 return QVideoFrameFormat::Format_YUYV;
859 case SPA_VIDEO_FORMAT_NV12:
860 return QVideoFrameFormat::Format_NV12;
861 case SPA_VIDEO_FORMAT_NV21:
862 return QVideoFrameFormat::Format_NV21;
863 case SPA_VIDEO_FORMAT_AYUV:
864 return QVideoFrameFormat::Format_AYUV;
865 case SPA_VIDEO_FORMAT_GRAY8:
866 return QVideoFrameFormat::Format_Y8;
867 case SPA_VIDEO_FORMAT_xRGB:
868 return QVideoFrameFormat::Format_XRGB8888;
869 case SPA_VIDEO_FORMAT_xBGR:
870 return QVideoFrameFormat::Format_XBGR8888;
871 case SPA_VIDEO_FORMAT_RGBx:
872 return QVideoFrameFormat::Format_RGBX8888;
873 case SPA_VIDEO_FORMAT_BGRx:
874 return QVideoFrameFormat::Format_BGRX8888;
875 case SPA_VIDEO_FORMAT_ARGB:
876 return QVideoFrameFormat::Format_ARGB8888;
877 case SPA_VIDEO_FORMAT_ABGR:
878 return QVideoFrameFormat::Format_ABGR8888;
879 case SPA_VIDEO_FORMAT_RGBA:
880 return QVideoFrameFormat::Format_RGBA8888;
881 case SPA_VIDEO_FORMAT_BGRA:
882 return QVideoFrameFormat::Format_BGRA8888;
883#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
884 case SPA_VIDEO_FORMAT_GRAY16_LE:
885 return QVideoFrameFormat::Format_Y16;
886 case SPA_VIDEO_FORMAT_P010_10LE:
887 return QVideoFrameFormat::Format_P010;
889 case SPA_VIDEO_FORMAT_GRAY16_BE:
890 return QVideoFrameFormat::Format_Y16;
891 case SPA_VIDEO_FORMAT_P010_10BE:
892 return QVideoFrameFormat::Format_P010;
896 return QVideoFrameFormat::Format_Invalid;
901 switch (pixelFormat) {
904 case QVideoFrameFormat::Format_YUV420P:
905 return SPA_VIDEO_FORMAT_I420;
906 case QVideoFrameFormat::Format_YUV422P:
907 return SPA_VIDEO_FORMAT_Y42B;
908 case QVideoFrameFormat::Format_YV12:
909 return SPA_VIDEO_FORMAT_YV12;
910 case QVideoFrameFormat::Format_UYVY:
911 return SPA_VIDEO_FORMAT_UYVY;
912 case QVideoFrameFormat::Format_YUYV:
913 return SPA_VIDEO_FORMAT_YUY2;
914 case QVideoFrameFormat::Format_NV12:
915 return SPA_VIDEO_FORMAT_NV12;
916 case QVideoFrameFormat::Format_NV21:
917 return SPA_VIDEO_FORMAT_NV21;
918 case QVideoFrameFormat::Format_AYUV:
919 return SPA_VIDEO_FORMAT_AYUV;
920 case QVideoFrameFormat::Format_Y8:
921 return SPA_VIDEO_FORMAT_GRAY8;
922 case QVideoFrameFormat::Format_XRGB8888:
923 return SPA_VIDEO_FORMAT_xRGB;
924 case QVideoFrameFormat::Format_XBGR8888:
925 return SPA_VIDEO_FORMAT_xBGR;
926 case QVideoFrameFormat::Format_RGBX8888:
927 return SPA_VIDEO_FORMAT_RGBx;
928 case QVideoFrameFormat::Format_BGRX8888:
929 return SPA_VIDEO_FORMAT_BGRx;
930 case QVideoFrameFormat::Format_ARGB8888:
931 return SPA_VIDEO_FORMAT_ARGB;
932 case QVideoFrameFormat::Format_ABGR8888:
933 return SPA_VIDEO_FORMAT_ABGR;
934 case QVideoFrameFormat::Format_RGBA8888:
935 return SPA_VIDEO_FORMAT_RGBA;
936 case QVideoFrameFormat::Format_BGRA8888:
937 return SPA_VIDEO_FORMAT_BGRA;
938#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
939 case QVideoFrameFormat::Format_Y16:
940 return SPA_VIDEO_FORMAT_GRAY16_LE;
941 case QVideoFrameFormat::Format_P010:
942 return SPA_VIDEO_FORMAT_P010_10LE;
944 case QVideoFrameFormat::Format_Y16:
945 return SPA_VIDEO_FORMAT_GRAY16_BE;
946 case QVideoFrameFormat::Format_P010:
947 return SPA_VIDEO_FORMAT_P010_10BE;
951 return SPA_VIDEO_FORMAT_UNKNOWN;
void finalizeGrabbingContext() override
static bool isSupported()
QVideoFrameFormat frameFormat() const
void initializeGrabbingContext() override
QVideoFrame grabFrame() override
~QPipeWireCaptureHelper() override
static int generateRequestToken()
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
PipeWireCaptureGlobalState()