Defer source failures and end calls that cannot reserve audio capture
This commit is contained in:
1 parent
50fad4ceff
commit
ce461521e4
2 files changed
+17
-5
No files matched your search
@@ -619,7 +619,12 @@ void MainWindow::setupBridgeCallbacks() {
|
|||||||
|
|
||||||
void MainWindow::setupConnects() {
|
void MainWindow::setupConnects() {
|
||||||
connect(m_messageList, &MessageList::streamPublishRequested, this, [this](quint64 group) {
|
connect(m_messageList, &MessageList::streamPublishRequested, this, [this](quint64 group) {
|
||||||
if (!m_streamPublisher) m_streamPublisher = new StreamPublishEngine(this);
|
if (!m_streamPublisher) {
|
||||||
|
m_streamPublisher = new StreamPublishEngine(this);
|
||||||
|
connect(m_streamPublisher, &StreamPublishEngine::stateChanged, this, [this](const QString& state) {
|
||||||
|
if (m_trayIcon) m_trayIcon->setToolTip(m_streamPublisher->active() ? QStringLiteral("vibechat · ") + state : QStringLiteral("vibechat"));
|
||||||
|
});
|
||||||
|
}
|
||||||
if (m_streamPublishWindow) delete m_streamPublishWindow.data();
|
if (m_streamPublishWindow) delete m_streamPublishWindow.data();
|
||||||
m_streamPublishWindow = new StreamPublishWindow(m_streamPublisher, m_streamPublisher->active() ? m_streamPublisher->group() : group, this);
|
m_streamPublishWindow = new StreamPublishWindow(m_streamPublisher, m_streamPublisher->active() ? m_streamPublisher->group() : group, this);
|
||||||
m_streamPublishWindow->show(); m_streamPublishWindow->raise(); m_streamPublishWindow->activateWindow();
|
m_streamPublishWindow->show(); m_streamPublishWindow->raise(); m_streamPublishWindow->activateWindow();
|
||||||
@@ -772,7 +777,14 @@ void MainWindow::onCallAccepted(quint64 callId) {
|
|||||||
CallWindow* w = m_activeCalls.value(callId, nullptr);
|
CallWindow* w = m_activeCalls.value(callId, nullptr);
|
||||||
if (w) w->setState(CallWindow::Active);
|
if (w) w->setState(CallWindow::Active);
|
||||||
if (!s_mainWindow) return;
|
if (!s_mainWindow) return;
|
||||||
CallAudioEngine::instance()->start(callId);
|
if (CallAudioEngine::instance()->start(callId) != 0) {
|
||||||
|
DEBUG_WARN(DEBUG_CATEGORY_CALL, "desktop call cannot acquire audio; hangup id=%llu", (unsigned long long)callId);
|
||||||
|
auto* request = static_cast<call_id_arg*>(u_malloc(sizeof(call_id_arg)));
|
||||||
|
if (request) { request->inst = gui_bridge_get_inst(); request->call_id = callId; gui_bridge_post_uasync_fn(call_hangup_trampoline, request); }
|
||||||
|
else DEBUG_ERROR(DEBUG_CATEGORY_CALL, "desktop failed call hangup allocation failed");
|
||||||
|
closeCallWindow(callId);
|
||||||
|
QMessageBox::information(this, QStringLiteral("vibechat"), QCoreApplication::translate("ChatGui", "The microphone is used by a call, radio or recording"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onCallEnded(quint64 callId, uint8_t reason) {
|
void MainWindow::onCallEnded(quint64 callId, uint8_t reason) {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
|||||||
}
|
}
|
||||||
if (best.isNull()) { DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "desktop camera lacks requested fps=%d", config.video.fps); return false; }
|
if (best.isNull()) { DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "desktop camera lacks requested fps=%d", config.video.fps); return false; }
|
||||||
m->camera->setCameraFormat(best); m->session->setCamera(m->camera.get());
|
m->camera->setCameraFormat(best); m->session->setCamera(m->camera.get());
|
||||||
connect(m->camera.get(), &QCamera::errorOccurred, this, [failed](QCamera::Error, const QString& error) { failed(error); });
|
connect(m->camera.get(), &QCamera::errorOccurred, this, [failed](QCamera::Error, const QString& error) { failed(error); }, Qt::QueuedConnection);
|
||||||
m->camera->start();
|
m->camera->start();
|
||||||
} else if (config.source.kind == StreamVideoSource::Screen) {
|
} else if (config.source.kind == StreamVideoSource::Screen) {
|
||||||
m->screen = std::make_unique<QScreenCapture>();
|
m->screen = std::make_unique<QScreenCapture>();
|
||||||
@@ -162,13 +162,13 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
|||||||
m->screen->setScreen(selected);
|
m->screen->setScreen(selected);
|
||||||
}
|
}
|
||||||
m->session->setScreenCapture(m->screen.get());
|
m->session->setScreenCapture(m->screen.get());
|
||||||
connect(m->screen.get(), &QScreenCapture::errorOccurred, this, [failed](QScreenCapture::Error, const QString& error) { failed(error); });
|
connect(m->screen.get(), &QScreenCapture::errorOccurred, this, [failed](QScreenCapture::Error, const QString& error) { failed(error); }, Qt::QueuedConnection);
|
||||||
m->screen->start();
|
m->screen->start();
|
||||||
} else {
|
} else {
|
||||||
auto window = config.source.window.value<QCapturableWindow>();
|
auto window = config.source.window.value<QCapturableWindow>();
|
||||||
if (!window.isValid()) { DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "desktop window is unavailable"); return false; }
|
if (!window.isValid()) { DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "desktop window is unavailable"); return false; }
|
||||||
m->window = std::make_unique<QWindowCapture>(); m->window->setWindow(window); m->session->setWindowCapture(m->window.get());
|
m->window = std::make_unique<QWindowCapture>(); m->window->setWindow(window); m->session->setWindowCapture(m->window.get());
|
||||||
connect(m->window.get(), &QWindowCapture::errorOccurred, this, [failed](QWindowCapture::Error, const QString& error) { failed(error); });
|
connect(m->window.get(), &QWindowCapture::errorOccurred, this, [failed](QWindowCapture::Error, const QString& error) { failed(error); }, Qt::QueuedConnection);
|
||||||
m->window->start();
|
m->window->start();
|
||||||
}
|
}
|
||||||
DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "desktop capture started generation=%llu kind=%d source=%s target=%dx%d/%dfps",
|
DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "desktop capture started generation=%llu kind=%d source=%s target=%dx%d/%dfps",
|
||||||
|
|||||||
Reference in new issue
Block a user