16#include <QSharedPointer>
20#include <pipewire/pipewire.h>
21#include <spa/param/format-utils.h>
22#include <spa/param/props.h>
23#include <spa/param/video/format-utils.h>
25#include <kpipewire_export.h>
33typedef void *EGLDisplay;
41struct DmaBufAttributes {
45 uint64_t modifier = 0;
50struct PipeWireCursor {
54 bool operator!=(
const PipeWireCursor &other)
const
56 return !operator==(other);
58 bool operator==(
const PipeWireCursor &other)
const
60 return position == other.position && hotspot == other.hotspot && texture == other.texture;
64class KPIPEWIRE_EXPORT PipeWireFrameData
66 Q_DISABLE_COPY(PipeWireFrameData)
72 std::shared_ptr<PipeWireFrameData>
copy()
const;
74 const spa_video_format format;
75 void *
const data =
nullptr;
77 const qint32 stride = 0;
81struct KPIPEWIRE_EXPORT PipeWireFrame {
82 spa_video_format format;
83 std::optional<quint64> sequential;
84 std::optional<std::chrono::nanoseconds> presentationTimestamp;
85 std::optional<DmaBufAttributes> dmabuf;
86 std::optional<QRegion> damage;
87 std::optional<PipeWireCursor> cursor;
88 std::shared_ptr<PipeWireFrameData> dataFrame;
92 bool operator==(
const Fraction &other)
const
94 return numerator == other.numerator && denominator == other.denominator;
96 explicit operator bool()
const
102 return denominator > 0;
104 quint32 numerator = 0;
105 quint32 denominator = 0;
108struct PipeWireSourceStreamPrivate;
110class KPIPEWIRE_EXPORT PipeWireSourceStream :
public QObject
119 enum class UsageHint {
125 explicit PipeWireSourceStream(
QObject *parent =
nullptr);
126 ~PipeWireSourceStream();
128 Fraction framerate()
const;
129 void setMaxFramerate(
const Fraction &framerate);
134 pw_stream_state state()
const;
135 bool createStream(uint nodeid,
int fd);
136 void setActive(
bool active);
137 void setDamageEnabled(
bool withDamage);
139 UsageHint usageHint()
const;
140 void setUsageHint(UsageHint hint);
142 void handleFrame(
struct pw_buffer *buffer);
144 void renegotiateModifierFailed(spa_video_format format, quint64 modifier);
146 std::optional<std::chrono::nanoseconds> currentPresentationTimestamp()
const;
148 static uint32_t spaVideoFormatToDrmFormat(spa_video_format spa_format);
150 bool usingDmaBuf()
const;
151 bool allowDmaBuf()
const;
152 void setAllowDmaBuf(
bool allowed);
156 void startStreaming();
157 void stopStreaming();
158 void streamParametersChanged();
159 void frameReceived(
const PipeWireFrame &frame);
160 void stateChanged(pw_stream_state state, pw_stream_state oldState);
163 static void onStreamParamChanged(
void *data, uint32_t
id,
const struct spa_pod *format);
164 static void onStreamStateChanged(
void *data, pw_stream_state old, pw_stream_state state,
const char *error_message);
165 static void onRenegotiate(
void *data, uint64_t);
166 static void onDestroy(
void *data);
169 void coreFailed(
const QString &errorMessage);
The to track the lifetime of a pipewire frame.
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
const QList< QKeySequence > & copy()