Browse Source

Keep desktop stream mute controls synchronized with publication

master
evgeny 3 days ago
parent
commit
e47ff579b3
  1. 13
      tools/chatgui/src/stream_publish_engine.cpp
  2. 1
      tools/chatgui/src/stream_publish_engine.h
  3. 6
      tools/chatgui/src/stream_publish_window.cpp

13
tools/chatgui/src/stream_publish_engine.cpp

@ -108,7 +108,18 @@ bool StreamPublishEngine::running() const { return m->running.load(); }
uint64_t StreamPublishEngine::group() const { return m->group; }
StreamPublishConfig StreamPublishEngine::config() const { std::lock_guard<std::mutex> guard(m->lock); return m->wanted; }
QList<int> StreamPublishEngine::codecs() const { std::lock_guard<std::mutex> guard(m->lock); return m->codecs; }
void StreamPublishEngine::setMuted(bool muted) { m->muted = muted; }
bool StreamPublishEngine::muted() const { return m->muted.load(); }
void StreamPublishEngine::setMuted(bool muted) {
if (!m->running || !config().audio) {
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop stream mute without active audio"); return;
}
bool previous = m->muted.exchange(muted);
if (!gui_stream_publish_audio(m->id, !muted)) {
m->muted = previous; publicationFailed(m->id, text("Could not change stream audio")); return;
}
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream audio id=%llu muted=%d", (unsigned long long)m->id, muted);
emit configurationChanged();
}
QList<StreamVideoSource> StreamPublishEngine::sources() {
QList<StreamVideoSource> sources;

1
tools/chatgui/src/stream_publish_engine.h

@ -42,6 +42,7 @@ public:
static QList<StreamVideoSource> sources();
static bool supported();
void setMuted(bool muted);
bool muted() const;
signals:
void codecsChanged();
void stateChanged(const QString& state);

6
tools/chatgui/src/stream_publish_window.cpp

@ -12,6 +12,7 @@
#include <QButtonGroup>
#include <QPainter>
#include <QScrollArea>
#include <QSignalBlocker>
#ifdef HAVE_STREAM_CAPTURE
#include <QVideoWidget>
#include <QVideoSink>
@ -74,7 +75,7 @@ StreamPublishWindow::StreamPublishWindow(StreamPublishEngine* engine, uint64_t g
for (const auto& device : SoundManager::enumerateCaptureDevices()) m_microphone->addItem(device.name, device.id);
form->addRow(text("Microphone"), m_microphone);
m_inputChannels = new QLabel(settings); form->addRow(text("Audio input"), m_inputChannels);
m_mute = new QCheckBox(text("Mute microphone"), settings); form->addRow(m_mute);
m_mute = new QCheckBox(text("Mute stream audio"), settings); form->addRow(m_mute);
connect(m_mute, &QCheckBox::toggled, engine, &StreamPublishEngine::setMuted);
m_status = new QLabel(this); m_status->setWordWrap(true); layout->addWidget(m_status);
m_stats = new QLabel(this); m_stats->setWordWrap(true); m_stats->setMinimumHeight(46); layout->addWidget(m_stats);
@ -140,7 +141,8 @@ void StreamPublishWindow::synchronize() {
m_start->setText(active ? text("Stop stream") : text("Start stream"));
m_start->setEnabled((active && m_engine->running()) || (!active && StreamPublishEngine::supported() && m_source->count() && m_codec->count()));
for (auto* box : {m_source, m_mode, m_codec, m_bitrate}) box->setEnabled(!active || m_engine->running());
m_audio->setEnabled(!active); m_microphone->setEnabled(!active); m_mute->setEnabled(active && m_engine->config().audio);
m_audio->setEnabled(!active); m_microphone->setEnabled(!active); m_mute->setEnabled(m_engine->running() && m_engine->config().audio);
{ QSignalBlocker blocked(m_mute); m_mute->setChecked(m_engine->muted()); }
if (active) {
auto config = m_engine->config();
for (int i = 0; i < m_sources.size(); i++) if (m_sources[i].kind == config.source.kind

Loading…
Cancel
Save