Populate call resolutions from camera modes and test Full HD IPC
This commit is contained in:
1 parent
eb11d2ebc5
commit
7a0bc9516c
3 files changed
+60
-12
No files matched your search
@@ -340,15 +340,37 @@ CallWindow::CallWindow(QWidget* parent)
|
||||
});
|
||||
auto* modes = new QHBoxLayout();
|
||||
m_camera = new QComboBox(this);
|
||||
connect(m_video, &CallVideoEngine::camerasChanged, this, [this](const CallCameraDevices& cameras) {
|
||||
m_resolution = new QComboBox(this);
|
||||
auto refreshModes = [this] {
|
||||
QSize wanted = m_resolution->currentData().toSize();
|
||||
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);
|
||||
}
|
||||
int index = m_resolution->findData(wanted);
|
||||
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",
|
||||
m_camera->currentData().toByteArray().constData(), m_resolution->count(), wanted.width(), wanted.height(),
|
||||
m_resolution->currentData().toSize().width(), m_resolution->currentData().toSize().height());
|
||||
};
|
||||
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) m_camera->addItem(camera.first, camera.second);
|
||||
for (const auto& camera : cameras) {
|
||||
QVariantList sizes;
|
||||
for (const auto& mode : camera.modes) sizes.append(mode.size);
|
||||
m_camera->addItem(camera.name, camera.id);
|
||||
m_camera->setItemData(m_camera->count() - 1, sizes, Qt::UserRole + 1);
|
||||
}
|
||||
const int index = m_camera->findData(selected);
|
||||
if (index >= 0) m_camera->setCurrentIndex(index);
|
||||
refreshModes();
|
||||
if (m_videoEnabled->isChecked()) applyVideo();
|
||||
});
|
||||
m_resolution = new QComboBox(this); m_resolution->addItem("640×480", QSize(640, 480)); m_resolution->addItem("1280×720", QSize(1280, 720));
|
||||
m_codec = new QComboBox(this); m_codec->addItem(callText("Auto (H.265 → H.264)"), 0); m_codec->addItem("H.265", 2); m_codec->addItem("H.264", 1);
|
||||
modes->addWidget(m_camera, 1); modes->addWidget(m_resolution); modes->addWidget(m_codec); videoLayout->addLayout(modes);
|
||||
auto* rates = new QHBoxLayout(); rates->addWidget(new QLabel(callText("Bitrate range, kbit/s:"), this));
|
||||
@@ -356,7 +378,8 @@ CallWindow::CallWindow(QWidget* parent)
|
||||
for (auto* spin : {m_videoMin, m_videoMax}) { spin->setRange(300, 4000); spin->setSingleStep(100); rates->addWidget(spin); }
|
||||
m_videoMin->setValue(300); m_videoMax->setValue(4000); videoLayout->addLayout(rates); lay->addWidget(m_videoControls);
|
||||
connect(m_videoEnabled, &QCheckBox::toggled, this, [this] { applyVideo(); });
|
||||
for (auto* combo : {m_camera, m_resolution, m_codec})
|
||||
connect(m_camera, QOverload<int>::of(&QComboBox::activated), this, [this, refreshModes] { refreshModes(); applyVideo(); });
|
||||
for (auto* combo : {m_resolution, m_codec})
|
||||
connect(combo, QOverload<int>::of(&QComboBox::activated), this, [this] { applyVideo(); });
|
||||
auto updateRange = [this] {
|
||||
if (m_videoMin->value() > m_videoMax->value()) m_videoMax->setValue(m_videoMin->value());
|
||||
@@ -536,7 +559,13 @@ void CallWindow::updateVideoPresentation() {
|
||||
void CallWindow::applyVideo() {
|
||||
if (!m_videoCall) return;
|
||||
QSize size = m_resolution->currentData().toSize();
|
||||
m_video->setVideo(m_videoEnabled->isChecked(), m_camera->currentData().toByteArray(), size.width(), size.height(), m_codec->currentData().toInt());
|
||||
const bool enabled = m_videoEnabled->isChecked() && !size.isEmpty();
|
||||
if (m_videoEnabled->isChecked() && !enabled) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "call camera has no selected mode device=%s", m_camera->currentData().toByteArray().constData());
|
||||
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());
|
||||
}
|
||||
|
||||
void CallWindow::postCallFn(void (*fn)(void*), uint64_t callId) {
|
||||
|
||||
Reference in new issue
Block a user