Browse Source

Own publication independently of its window and reserve call capture

master
evgeny 5 days ago
parent
commit
c1d7460254
  1. 7
      tools/chatgui/src/call_audio_engine.cpp
  2. 2
      tools/chatgui/src/call_audio_engine.h
  3. 10
      tools/chatgui/src/mainwindow.cpp

7
tools/chatgui/src/call_audio_engine.cpp

@ -33,13 +33,17 @@ CallAudioEngine::CallAudioEngine() {
int CallAudioEngine::start(quint64 callId) {
if (m_active && m_callId == callId && !m_ending) return 0;
stop();
if (!m_microphone.acquire()) {
DEBUG_WARN(DEBUG_CATEGORY_CALL, "CallAudio: microphone owned by another operation"); return -1;
}
if (!gui_bridge_get_inst() || call_audio_start_prepared(callId) != 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "CallAudio: cannot start call=%016llx", (unsigned long long)callId);
m_microphone.release();
return -1;
}
++m_generation;
m_callId = callId;
if (!m_voice.start(VoiceAudioIo::Kind::Call, callId)) { call_audio_release(callId); m_callId = 0; return -1; }
if (!m_voice.start(VoiceAudioIo::Kind::Call, callId)) { call_audio_release(callId); m_callId = 0; m_microphone.release(); return -1; }
m_muted = false;
m_ending = false;
m_active = true;
@ -127,6 +131,7 @@ void CallAudioEngine::stop() {
m_recoveryTimer.stop();
m_active = false;
pauseDevices(); m_voice.stop();
m_microphone.release();
uint64_t id = m_callId.exchange(0);
if (id) call_audio_release(id);
m_muted = false;

2
tools/chatgui/src/call_audio_engine.h

@ -6,6 +6,7 @@
#include <vector>
#include <QTimer>
#include "audio_device.h"
#include "audio_capture_lease.h"
#include "voice_audio_io.h"
struct ma_device;
@ -59,6 +60,7 @@ private:
QString m_captureId;
AudioDevice m_capture;
AudioCaptureLease m_microphone;
VoiceAudioIo m_voice;
bool m_outputAttached = false;
QTimer m_recoveryTimer;

10
tools/chatgui/src/mainwindow.cpp

@ -1,6 +1,8 @@
#include <QCoreApplication>
#include "mainwindow.h"
#include "streamplayer_window.h"
#include "stream_publish_engine.h"
#include "stream_publish_window.h"
#include "channellist.h"
#include "messagelist.h"
#include "messagedelegate.h"
@ -198,6 +200,8 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
}
MainWindow::~MainWindow() {
if (m_streamPublishWindow) delete m_streamPublishWindow.data();
delete m_streamPublisher; m_streamPublisher = nullptr;
if (m_streamPlayer) delete m_streamPlayer.data();
gui_bridge_set_stream_sources_cb(nullptr);
s_mainWindow = nullptr;
@ -614,6 +618,12 @@ void MainWindow::setupBridgeCallbacks() {
}
void MainWindow::setupConnects() {
connect(m_messageList, &MessageList::streamPublishRequested, this, [this](quint64 group) {
if (!m_streamPublisher) m_streamPublisher = new StreamPublishEngine(this);
if (m_streamPublishWindow) delete m_streamPublishWindow.data();
m_streamPublishWindow = new StreamPublishWindow(m_streamPublisher, m_streamPublisher->active() ? m_streamPublisher->group() : group, this);
m_streamPublishWindow->show(); m_streamPublishWindow->raise(); m_streamPublishWindow->activateWindow();
});
connect(m_messageList, &MessageList::streamRequested, this,
[this](quint64 group, quint64 source, quint64 epoch, const QString& name) {
if (m_streamPlayer) delete m_streamPlayer.data();

Loading…
Cancel
Save