Commit dae1abfd authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Vlad Zahorodnii
Browse files

screencasting: Have cursor move frames also send damage information

Otherwise we keep the last use of the buffer's which is clearly wrong.


(cherry picked from commit a2913d1e)
parent a9159743
Pipeline #196995 canceled with stage
......@@ -444,7 +444,30 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion)
(spa_meta_cursor *)spa_buffer_find_meta_data(spa_buffer, SPA_META_Cursor, sizeof(spa_meta_cursor)));
}
if (spa_meta *vdMeta = spa_buffer_find_meta(spa_buffer, SPA_META_VideoDamage)) {
addDamage(spa_buffer, damagedRegion | QRect({0, 0}, size));
addHeader(spa_buffer);
tryEnqueue(buffer);
}
void ScreenCastStream::addHeader(spa_buffer *spaBuffer)
{
spa_meta_header *spaHeader = (spa_meta_header *)spa_buffer_find_meta_data(spaBuffer, SPA_META_Header, sizeof(spaHeader));
if (spaHeader) {
spaHeader->flags = 0;
spaHeader->dts_offset = 0;
spaHeader->seq = m_sequential++;
const auto timestamp = m_source->clock();
if (!m_start) {
m_start = timestamp;
}
spaHeader->pts = (timestamp - m_start.value()).count();
}
}
void ScreenCastStream::addDamage(spa_buffer *spaBuffer, const QRegion &damagedRegion)
{
if (spa_meta *vdMeta = spa_buffer_find_meta(spaBuffer, SPA_META_VideoDamage)) {
struct spa_meta_region *r = (spa_meta_region *)spa_meta_first(vdMeta);
// If there's too many rectangles, we just send the bounding rect
......@@ -467,25 +490,6 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion)
r->region = SPA_REGION(0, 0, 0, 0);
}
}
addHeader(spa_buffer);
tryEnqueue(buffer);
}
void ScreenCastStream::addHeader(spa_buffer *spaBuffer)
{
spa_meta_header *spaHeader = (spa_meta_header *)spa_buffer_find_meta_data(spaBuffer, SPA_META_Header, sizeof(spaHeader));
if (spaHeader) {
spaHeader->flags = 0;
spaHeader->dts_offset = 0;
spaHeader->seq = m_sequential++;
const auto timestamp = m_source->clock();
if (!m_start) {
m_start = timestamp;
}
spaHeader->pts = (timestamp - m_start.value()).count();
}
}
void ScreenCastStream::recordCursor()
......@@ -516,6 +520,7 @@ void ScreenCastStream::recordCursor()
sendCursorData(Cursors::self()->currentCursor(),
(spa_meta_cursor *)spa_buffer_find_meta_data(spa_buffer, SPA_META_Cursor, sizeof(spa_meta_cursor)));
addHeader(spa_buffer);
addDamage(spa_buffer, {});
enqueue();
}
......
......@@ -80,6 +80,7 @@ private:
void coreFailed(const QString &errorMessage);
void sendCursorData(Cursor *cursor, spa_meta_cursor *spa_cursor);
void addHeader(spa_buffer *spaBuffer);
void addDamage(spa_buffer *spaBuffer, const QRegion &damagedRegion);
void newStreamParams();
void tryEnqueue(pw_buffer *buffer);
void enqueue();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment