Carry selected video frame rate through desktop call settings

This commit is contained in:
evgeny committed 2026-10-20 00:07:36 +02:00
1 parent f6701f81f9
commit 0830fe4461
2 files changed
+36 -22

No files matched your search

+13 -7
View File
@@ -343,26 +343,31 @@ CallWindow::CallWindow(QWidget* parent)
m_resolution = new QComboBox(this);
auto refreshModes = [this] {
QSize wanted = m_resolution->currentData().toSize();
const int wantedFps = m_resolution->currentData(Qt::UserRole + 1).toInt() ?: 30;
if (wanted.isEmpty()) wanted = QSize(640, 480);
m_resolution->clear();
for (const auto& value : m_camera->currentData(Qt::UserRole + 1).toList()) {
const QSize size = value.toSize();
m_resolution->addItem(QStringLiteral("%1×%2").arg(size.width()).arg(size.height()), size);
const auto mode = value.toList(); const QSize size = mode[0].toSize(); const int fps = mode[1].toInt();
m_resolution->addItem(QStringLiteral("%1×%2 · %3 fps").arg(size.width()).arg(size.height()).arg(fps), size);
m_resolution->setItemData(m_resolution->count() - 1, fps, Qt::UserRole + 1);
}
int index = m_resolution->findData(wanted);
int index = -1;
for (int i = 0; i < m_resolution->count(); ++i)
if (m_resolution->itemData(i).toSize() == wanted && m_resolution->itemData(i, Qt::UserRole + 1).toInt() == wantedFps) index = i;
if (index < 0) index = m_resolution->findData(QSize(640, 480));
if (index < 0) index = m_resolution->count() - 1;
m_resolution->setCurrentIndex(index); m_resolution->setEnabled(index >= 0);
DEBUG_INFO(DEBUG_CATEGORY_CALL, "call camera resolutions device=%s count=%d requested=%dx%d selected=%dx%d fps=30",
DEBUG_INFO(DEBUG_CATEGORY_CALL, "call camera resolutions device=%s count=%d requested=%dx%d selected=%dx%d fps=%d",
m_camera->currentData().toByteArray().constData(), m_resolution->count(), wanted.width(), wanted.height(),
m_resolution->currentData().toSize().width(), m_resolution->currentData().toSize().height());
m_resolution->currentData().toSize().width(), m_resolution->currentData().toSize().height(),
m_resolution->currentData(Qt::UserRole + 1).toInt());
};
connect(m_video, &CallVideoEngine::camerasChanged, this, [this, refreshModes](const CallCameraDevices& cameras) {
const auto selected = m_camera->currentData();
m_camera->clear();
for (const auto& camera : cameras) {
QVariantList sizes;
for (const auto& mode : camera.modes) sizes.append(mode.size);
for (const auto& mode : camera.modes) sizes.append(QVariant(QVariantList{mode.size, mode.fps}));
m_camera->addItem(camera.name, camera.id);
m_camera->setItemData(m_camera->count() - 1, sizes, Qt::UserRole + 1);
}
@@ -568,7 +573,8 @@ void CallWindow::applyVideo() {
m_videoStatus->setText(callText("No supported video modes")); m_videoStatus->show();
}
if (size.isEmpty()) size = QSize(640, 480);
m_video->setVideo(enabled, m_camera->currentData().toByteArray(), size.width(), size.height(), m_codec->currentData().toInt());
const int fps = m_resolution->currentData(Qt::UserRole + 1).toInt();
m_video->setVideo(enabled, m_camera->currentData().toByteArray(), size.width(), size.height(), m_codec->currentData().toInt(), fps ? fps : 30);
}
void CallWindow::postCallFn(void (*fn)(void*), uint64_t callId) {