From ef92eedce2e911de08107fc6c6f2a3ae759310de Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 13 Apr 2023 12:28:34 +0200 Subject: [PATCH] screencast: Base the frame skippin on max_framerate the fixed framerate apparently needs to br 0/1 and to control the actual framerate need to set the max one --- src/plugins/screencast/screencaststream.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index e13d714184..6a5e0e1e89 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -431,8 +431,8 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) QRegion damagedRegion = _damagedRegion; Q_ASSERT(!m_stopped); - if (videoFormat.framerate.num != 0 && !m_lastSent.isNull()) { - auto frameInterval = (1000. * videoFormat.framerate.denom / videoFormat.framerate.num); + if (videoFormat.max_framerate.num != 0 && !m_lastSent.isNull()) { + auto frameInterval = (1000. * videoFormat.max_framerate.denom / videoFormat.max_framerate.num); auto lastSentAgo = m_lastSent.msecsTo(QDateTime::currentDateTimeUtc()); if (lastSentAgo < frameInterval) { m_pendingDamages |= damagedRegion; @@ -706,6 +706,7 @@ QVector ScreenCastStream::buildFormats(bool fixate, char buffer { const auto format = drmFourCCToSpaVideoFormat(m_drmFormat); spa_pod_builder podBuilder = SPA_POD_BUILDER_INIT(buffer, 2048); + spa_fraction defFramerate = SPA_FRACTION(0, 1); spa_fraction minFramerate = SPA_FRACTION(1, 1); spa_fraction maxFramerate = SPA_FRACTION(m_source->refreshRate() / 1000, 1); @@ -714,12 +715,12 @@ QVector ScreenCastStream::buildFormats(bool fixate, char buffer QVector params; params.reserve(fixate + m_hasDmaBuf + 1); if (fixate) { - params.append(buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &maxFramerate, &minFramerate, &maxFramerate, {m_dmabufParams->modifier}, SPA_POD_PROP_FLAG_MANDATORY)); + params.append(buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &defFramerate, &minFramerate, &maxFramerate, {m_dmabufParams->modifier}, SPA_POD_PROP_FLAG_MANDATORY)); } if (m_hasDmaBuf) { - params.append(buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &maxFramerate, &minFramerate, &maxFramerate, m_modifiers, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE)); + params.append(buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &defFramerate, &minFramerate, &maxFramerate, m_modifiers, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE)); } - params.append(buildFormat(&podBuilder, format, &resolution, &maxFramerate, &minFramerate, &maxFramerate, {}, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE)); + params.append(buildFormat(&podBuilder, format, &resolution, &defFramerate, &minFramerate, &maxFramerate, {}, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE)); return params; } @@ -739,6 +740,7 @@ spa_pod *ScreenCastStream::buildFormat(struct spa_pod_builder *b, enum spa_video SPA_POD_Fraction(minFramerate), SPA_POD_Fraction(maxFramerate)), 0); + if (format == SPA_VIDEO_FORMAT_BGRA) { /* announce equivalent format without alpha */ spa_pod_builder_add(b, SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(3, format, format, SPA_VIDEO_FORMAT_BGRx), 0);