diff --git a/tools/chatgui/src/capture_controls.h b/tools/chatgui/src/capture_controls.h index cd625775b..13ef08e57 100644 --- a/tools/chatgui/src/capture_controls.h +++ b/tools/chatgui/src/capture_controls.h @@ -12,6 +12,8 @@ #include #include #include +#include "stream_video_modes.h" +#include "debug_config.h" namespace CaptureControls { class MenuStyle : public QProxyStyle { @@ -62,6 +64,33 @@ inline QAction* addOption(QMenu* menu, const QString& label, const QVariant& dat } inline void clearOptions(QMenu* menu, const char* heading) { menu->clear(); menu->addSection(QCoreApplication::translate("ChatGui", heading)); } +/* Все стандартные и аппаратные FPS остаются в меню; доступность зависит от точного size. + * Сохраняет previous, иначе выбирает 30 либо первый доступный; без режимов снимает выбор. */ +inline void populateFrameRates(QMenu* menu, const QList& modes, QSize size, int previous) { + clearOptions(menu, "Frame rate"); QList rates{15, 24, 25, 30, 50, 60}; + for (const auto& mode : modes) if (!rates.contains(mode.fps)) rates.append(mode.fps); + std::sort(rates.begin(), rates.end()); int fallback = -1; + for (int fps : rates) { + auto* action = addOption(menu, QCoreApplication::translate("ChatGui", "%1 fps").arg(fps), fps); + bool available = modes.contains({size, fps}); action->setEnabled(available); + if (available && (fallback < 0 || fps == 30)) fallback = fps; + } + auto* requested = option(menu, previous); + if (requested && requested->isEnabled()) select(menu, previous); + else if (fallback >= 0) { + select(menu, fallback); + DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "desktop capture FPS adjusted resolution=%dx%d requested=%d selected=%d", + size.width(), size.height(), previous, fallback); + } else { + auto* group = menu->findChild(); group->setExclusive(false); + if (auto* action = selected(menu)) action->setChecked(false); + group->setExclusive(true); + DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "desktop capture resolution has no available FPS width=%d height=%d", size.width(), size.height()); + } + DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO, "desktop capture FPS choices width=%d height=%d choices=%lld selected=%d", + size.width(), size.height(), (long long)rates.size(), value(menu).toInt()); +} + /* Компактные векторные значки с текущим значением, читаемые в обеих темах. */ inline QIcon controlIcon(const QPalette& palette, const QString& shape, const QString& label = {}, const QString& detail = {}, int rotation = 0) { QPixmap pixmap(80, 72); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.scale(2, 2); diff --git a/tools/chatgui/src/stream_publish_window.cpp b/tools/chatgui/src/stream_publish_window.cpp index dbab0222b..432ac7c5f 100644 --- a/tools/chatgui/src/stream_publish_window.cpp +++ b/tools/chatgui/src/stream_publish_window.cpp @@ -378,31 +378,7 @@ void StreamPublishWindow::refreshModes(const StreamPublishConfig& previous, bool } void StreamPublishWindow::refreshFrameRates(int previous) { - clearOptions(m_fps, "Frame rate"); - QList rates{15, 24, 25, 30, 50, 60}; - for (const auto& mode : m_modes) if (!rates.contains(mode.fps)) rates.append(mode.fps); - std::sort(rates.begin(), rates.end()); - QSize size = value(m_resolution).toSize(); - int fallback = -1; - for (int fps : rates) { - auto* action = addOption(m_fps, text("%1 fps").arg(fps), fps); - bool available = selected(m_resolution) && m_modes.contains({size, fps}); action->setEnabled(available); - if (available && (fallback < 0 || fps == 30)) fallback = fps; - } - auto* requested = option(m_fps, previous); - if (requested && requested->isEnabled()) select(m_fps, previous); - else if (fallback >= 0) { - select(m_fps, fallback); - DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "desktop stream FPS adjusted resolution=%dx%d requested=%d selected=%d", - size.width(), size.height(), previous, fallback); - } else { - auto* group = m_fps->findChild(); group->setExclusive(false); - if (auto* action = selected(m_fps)) action->setChecked(false); - group->setExclusive(true); - DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "desktop stream resolution has no available FPS width=%d height=%d", size.width(), size.height()); - } - DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO, "desktop stream FPS choices width=%d height=%d choices=%lld selected=%d", - size.width(), size.height(), (long long)rates.size(), value(m_fps).toInt()); + populateFrameRates(m_fps, m_modes, value(m_resolution).toSize(), previous); } void StreamPublishWindow::refreshCodecs() { QScopedValueRollback updating(m_updating, true);