// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // KOutNet - Voice call manager (P2P calls, group calls via per-peer jitter buffers) #pragma once #include #include #include #include namespace koutnet { class NetworkManager; class AudioEngine; // Voice frames travel raw over the voice TCP sockets. Confidentiality and peer // authentication belong to the transport: when the identity is present the // voice sockets are TLS 1.3 wrapped in the identity-derived certificate and // the accept side only admits peers the chat channel already pinned. There is // no per-frame app cipher here any more - CryptoManager owns no wire crypto. class VoiceCallManager : public QObject { Q_OBJECT public: explicit VoiceCallManager(NetworkManager *net, QObject *parent = nullptr); // candidates: addresses to dial in parallel for this peer, first to connect // wins. empty means the peer address itself, the LAN path. The Matrix room // bridge passes the far side's whole offer (host + reflexive candidates). Q_INVOKABLE bool call(const QString &ip, const QStringList &candidates = {}); Q_INVOKABLE void hangup(const QString &ip); Q_INVOKABLE void hangupAll(); Q_INVOKABLE void setMute(bool muted); Q_INVOKABLE void setDeafen(bool deafened); Q_INVOKABLE void setVad(bool enabled); Q_INVOKABLE void setAudioInputDevice(const QString &id); Q_INVOKABLE void setAudioOutputDevice(const QString &id); Q_INVOKABLE void setAudioVolume(qreal volume); const QSet &activeCalls() const { return m_active; } Q_SIGNALS: void callStarted(QString ip); // any call going on, in either direction. NetworkManager listens to this to // answer incoming call requests with the busy reply while one is live. void activeCallsChanged(); private Q_SLOTS: void onCaptured(const QByteArray &data); void onPeerAudio(const QString &ip, const QByteArray &data); private: NetworkManager *m_net; AudioEngine *m_audio = nullptr; // channel is really up (voiceConnected arrived) vs a dial still connecting. // only m_active counts as a call: audio flows through it and the busy logic // mirrors it, so a peer that never picks up is not a call with no sound. QSet m_active; QSet m_dialing; bool m_muted = false; bool m_deafened = false; }; } // namespace koutnet