1
0
mirror of https://invent.kde.org/network/krfb synced 2024-06-29 06:24:57 +00:00

pw: Improve fb allocation code.

Don't set the video size using the data coming from xdp, instead use the
data coming from pipewire, which is what matters.
Also make sure setVideoSize is called before using the buffer rather
than after.
This commit is contained in:
Aleix Pol 2024-03-12 00:43:55 +01:00
parent 2995637d27
commit 378472f8b2

View File

@ -334,7 +334,6 @@ void PWFrameBuffer::Private::handleRemoteDesktopStarted(quint32 code, const QVar
isValid = false;
return;
}
setVideoSize(qdbus_cast<QSize>(streams.first().map[QStringLiteral("size")].value<QDBusArgument>()));
}
void PWFrameBuffer::Private::handleFrame(const PipeWireFrame &frame)
@ -348,17 +347,20 @@ void PWFrameBuffer::Private::handleFrame(const PipeWireFrame &frame)
}
if (frame.dataFrame) {
memcpy(q->fb, frame.dataFrame->data, frame.dataFrame->size.width() * frame.dataFrame->stride);
// FIXME: Assuming stride == width * 4, not sure to which extent this holds
setVideoSize(frame.dataFrame->size);
memcpy(q->fb, frame.dataFrame->data, frame.dataFrame->size.width() * frame.dataFrame->stride);
}
else if (frame.dmabuf) {
QImage src((uchar*) q->fb, videoSize.width(), videoSize.height(), QImage::Format_RGB32);
// FIXME: Assuming stride == width * 4, not sure to which extent this holds
const QSize size = { frame.dmabuf->width, frame.dmabuf->height };
setVideoSize(size);
QImage src(reinterpret_cast<uchar*>(q->fb), size.width(), size.height(), QImage::Format_RGB32);
if (!m_dmabufHandler.downloadFrame(src, frame)) {
stream->renegotiateModifierFailed(frame.format, frame.dmabuf->modifier);
qCDebug(KRFB_FB_PIPEWIRE) << "Failed to download frame.";
return;
}
setVideoSize(src.size());
} else {
qCDebug(KRFB_FB_PIPEWIRE) << "Unknown kind of frame";
}