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_instance_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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_INSTANCE_P_H
5#define QPIPEWIRE_INSTANCE_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_support_p.h>
19
20#include <QtCore/private/qexpected_p.h>
21#include <QtCore/qglobal.h>
22#include <QtCore/qloggingcategory.h>
23#include <QtCore/private/qexpected_p.h>
24
25#include <pipewire/pipewire.h>
26
27#include <optional>
28#include <system_error>
29
30QT_BEGIN_NAMESPACE
31
32namespace QtPipeWire {
33
34Q_DECLARE_LOGGING_CATEGORY(lcPipewire); // "qt.multimedia.pipewire"
35
41
43{
44public:
45 [[nodiscard]] static std::shared_ptr<QPipeWireInstance> instance();
46 [[nodiscard]] static bool isLoaded();
47 [[nodiscard]] static q23::expected<void, std::error_code> hasSPAFactory(const char *factoryName);
48
49 // event loop
50 template <typename Closure>
51 auto runWithEventLoopLock(Closure &&c)
52 {
53 return m_eventLoop.runWithEventLoopLock(std::forward<Closure>(c));
54 }
55
56 auto eventLoopLock() { return std::unique_lock{ m_eventLoop }; }
57 bool isInPwThreadLoop() const;
58 pw_loop *eventLoop() const;
59 PWThreadedEventLoop &pwEventLoop() { return m_eventLoop; };
60
61 // portal
63
64 // connection factories
67
69
70private:
71 static std::unique_ptr<QPipeWireInstance> create();
72 QPipeWireInstance();
73
74 PWThreadedEventLoop m_eventLoop{ "PwEventLoop" };
75 PwContextHandle m_context;
76
77 std::optional<bool> m_hasScreenCastPortal;
78};
79
80} // namespace QtPipeWire
81
82QT_END_NAMESPACE
83
84#endif // QPIPEWIRE_INSTANCE_P_H
PWThreadedEventLoop & pwEventLoop()
q23::expected< PwCoreConnectionHandle, std::error_code > connectToPortal(int fd)
q23::expected< PwCoreConnectionHandle, std::error_code > connectToDaemon()
static q23::expected< void, std::error_code > hasSPAFactory(const char *factoryName)
static std::shared_ptr< QPipeWireInstance > instance()
static std::optional< uint > portalInterfaceVersion(const QString &interface)
Q_LOGGING_CATEGORY(lcPipewire, "qt.multimedia.pipewire")
Q_DECLARE_LOGGING_CATEGORY(lcPipewire)