Browse Source

refactor(coreav): move call controll to ToxCall objects

reviewable/pr6235/r21
sudden6 5 years ago committed by Anthony Bilinski
parent
commit
a67277074b
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 168
      src/core/coreav.cpp
  2. 19
      src/core/coreav.h
  3. 20
      src/core/toxcall.cpp
  4. 23
      src/core/toxcall.h
  5. 79
      src/widget/form/chatform.cpp
  6. 2
      src/widget/form/chatform.h
  7. 7
      src/widget/widget.cpp
  8. 1
      src/widget/widget.h

168
src/core/coreav.cpp

@ -195,43 +195,6 @@ void CoreAV::process() @@ -195,43 +195,6 @@ void CoreAV::process()
iterateTimer->start(toxav_iteration_interval(toxav.get()));
}
/**
* @brief Checks the call status for a Tox friend.
* @param f the friend to check
* @return true, if call is started for the friend, false otherwise
*/
bool CoreAV::isCallStarted(const Friend* f) const
{
QReadLocker locker{&callsLock};
return f && (calls.find(f->getId()) != calls.end());
}
/**
* @brief Checks the call status for a Tox group.
* @param g the group to check
* @return true, if call is started for the group, false otherwise
*/
bool CoreAV::isCallStarted(const Group* g) const
{
QReadLocker locker{&callsLock};
return g && (groupCalls.find(g->getId()) != groupCalls.end());
}
/**
* @brief Checks the call status for a Tox friend.
* @param f the friend to check
* @return true, if call is active for the friend, false otherwise
*/
bool CoreAV::isCallActive(const Friend* f) const
{
QReadLocker locker{&callsLock};
auto it = calls.find(f->getId());
if (it == calls.end()) {
return false;
}
return isCallStarted(f) && it->second->isActive();
}
/**
* @brief Checks the call status for a Tox group.
* @param g the group to check
@ -244,17 +207,10 @@ bool CoreAV::isCallActive(const Group* g) const @@ -244,17 +207,10 @@ bool CoreAV::isCallActive(const Group* g) const
if (it == groupCalls.end()) {
return false;
}
return isCallStarted(g) && it->second->isActive();
}
bool CoreAV::isCallVideoEnabled(const Friend* f) const
{
QReadLocker locker{&callsLock};
auto it = calls.find(f->getId());
return isCallStarted(f) && it->second->getVideoEnabled();
return it->second->isActive();
}
bool CoreAV::answerCall(uint32_t friendNum, bool video)
CoreAV::ToxFriendCallPtr CoreAV::answerCall(uint32_t friendNum, bool video)
{
QWriteLocker locker{&callsLock};
QMutexLocker coreLocker{&coreLock};
@ -268,18 +224,18 @@ bool CoreAV::answerCall(uint32_t friendNum, bool video) @@ -268,18 +224,18 @@ bool CoreAV::answerCall(uint32_t friendNum, bool video)
if (toxav_answer(toxav.get(), friendNum, audioSettings.getAudioBitrate(),
videoBitrate, &err)) {
it->second->setActive(true);
return true;
return it->second;
} else {
qWarning() << "Failed to answer call with error" << err;
Toxav_Err_Call_Control controlErr;
toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, &controlErr);
PARSE_ERR(controlErr);
calls.erase(it);
return false;
return {};
}
}
bool CoreAV::startCall(uint32_t friendNum, bool video)
CoreAV::ToxFriendCallPtr CoreAV::startCall(uint32_t friendNum, bool video)
{
QWriteLocker locker{&callsLock};
QMutexLocker coreLocker{&coreLock};
@ -288,7 +244,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video) @@ -288,7 +244,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
auto it = calls.find(friendNum);
if (it != calls.end()) {
qWarning() << QString("Can't start call with %1, we're already in this call!").arg(friendNum);
return false;
return {};
}
uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
@ -296,7 +252,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video) @@ -296,7 +252,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
toxav_call(toxav.get(), friendNum, audioSettings.getAudioBitrate(), videoBitrate,
&err);
if (!PARSE_ERR(err)) {
return false;
return {};
}
// Audio backend must be set before making a call
@ -306,8 +262,8 @@ bool CoreAV::startCall(uint32_t friendNum, bool video) @@ -306,8 +262,8 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
// Call object must be owned by this thread or there will be locking problems with Audio
call->moveToThread(thread());
assert(call != nullptr);
calls.emplace(friendNum, std::move(call));
return true;
calls.emplace(friendNum, call);
return call;
}
bool CoreAV::cancelCall(uint32_t friendNum)
@ -315,6 +271,12 @@ bool CoreAV::cancelCall(uint32_t friendNum) @@ -315,6 +271,12 @@ bool CoreAV::cancelCall(uint32_t friendNum)
QWriteLocker locker{&callsLock};
QMutexLocker coreLocker{&coreLock};
auto it = calls.find(friendNum);
if (it == calls.end()) {
qWarning() << QString("Can't cancel call with %1, it doesn't exist!").arg(friendNum);
return false;
}
qDebug() << QString("Cancelling call with %1").arg(friendNum);
Toxav_Err_Call_Control err;
toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, &err);
@ -322,6 +284,9 @@ bool CoreAV::cancelCall(uint32_t friendNum) @@ -322,6 +284,9 @@ bool CoreAV::cancelCall(uint32_t friendNum)
return false;
}
// Set inactive for others
it->second->setActive(false);
calls.erase(friendNum);
locker.unlock();
@ -329,17 +294,6 @@ bool CoreAV::cancelCall(uint32_t friendNum) @@ -329,17 +294,6 @@ bool CoreAV::cancelCall(uint32_t friendNum)
return true;
}
void CoreAV::timeoutCall(uint32_t friendNum)
{
QWriteLocker locker{&callsLock};
if (!cancelCall(friendNum)) {
qWarning() << QString("Failed to timeout call with %1").arg(friendNum);
return;
}
qDebug() << "Call with friend" << friendNum << "timed out";
}
/**
* @brief Send audio frame to a friend
* @param callId Id of friend in call list.
@ -441,36 +395,6 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe) @@ -441,36 +395,6 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
}
}
/**
* @brief Toggles the mute state of the call's input (microphone).
* @param f The friend assigned to the call
*/
void CoreAV::toggleMuteCallInput(const Friend* f)
{
QWriteLocker locker{&callsLock};
auto it = calls.find(f->getId());
if (f && (it != calls.end())) {
ToxCall& call = *it->second;
call.setMuteMic(!call.getMuteMic());
}
}
/**
* @brief Toggles the mute state of the call's output (speaker).
* @param f The friend assigned to the call
*/
void CoreAV::toggleMuteCallOutput(const Friend* f)
{
QWriteLocker locker{&callsLock};
auto it = calls.find(f->getId());
if (f && (it != calls.end())) {
ToxCall& call = *it->second;
call.setMuteVol(!call.getMuteVol());
}
}
/**
* @brief Called from Tox API when group call receives audio data.
*
@ -538,24 +462,6 @@ void CoreAV::invalidateGroupCallPeerSource(const Group& group, ToxPk peerPk) @@ -538,24 +462,6 @@ void CoreAV::invalidateGroupCallPeerSource(const Group& group, ToxPk peerPk)
it->second->removePeer(peerPk);
}
/**
* @brief Get a call's video source.
* @param friendNum Id of friend in call list.
* @return Video surface to show
*/
VideoSource* CoreAV::getVideoSourceFromCall(int friendNum) const
{
QReadLocker locker{&callsLock};
auto it = calls.find(friendNum);
if (it == calls.end()) {
qWarning() << "CoreAV::getVideoSourceFromCall: No such call, possibly cancelled";
return nullptr;
}
return it->second->getVideoSource();
}
/**
* @brief Starts a call in an existing AV groupchat.
* @note Call from the GUI thread.
@ -682,40 +588,6 @@ bool CoreAV::isGroupCallOutputMuted(const Group* g) const @@ -682,40 +588,6 @@ bool CoreAV::isGroupCallOutputMuted(const Group* g) const
return (it != groupCalls.end()) && it->second->getMuteVol();
}
/**
* @brief Returns the calls input (microphone) mute state.
* @param f The friend to check
* @return true when muted, false otherwise
*/
bool CoreAV::isCallInputMuted(const Friend* f) const
{
QReadLocker locker{&callsLock};
if (!f) {
return false;
}
const uint32_t friendId = f->getId();
auto it = calls.find(friendId);
return (it != calls.end()) && it->second->getMuteMic();
}
/**
* @brief Returns the calls output (speaker) mute state.
* @param friendId The friend to check
* @return true when muted, false otherwise
*/
bool CoreAV::isCallOutputMuted(const Friend* f) const
{
QReadLocker locker{&callsLock};
if (!f) {
return false;
}
const uint32_t friendId = f->getId();
auto it = calls.find(friendId);
return (it != calls.end()) && it->second->getMuteVol();
}
/**
* @brief Signal to all peers that we're not sending video anymore.
* @note The next frame sent cancels this.
@ -793,11 +665,15 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi @@ -793,11 +665,15 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
if (state & TOXAV_FRIEND_CALL_STATE_ERROR) {
qWarning() << "Call with friend" << friendNum << "died of unnatural causes!";
// Set inactive for others
it->second->setActive(false);
self->calls.erase(friendNum);
locker.unlock();
emit self->avEnd(friendNum, true);
} else if (state & TOXAV_FRIEND_CALL_STATE_FINISHED) {
qDebug() << "Call with friend" << friendNum << "finished quietly";
// Set inactive for others
it->second->setActive(false);
self->calls.erase(friendNum);
locker.unlock();
emit self->avEnd(friendNum);

19
src/core/coreav.h

@ -50,6 +50,8 @@ class CoreAV : public QObject @@ -50,6 +50,8 @@ class CoreAV : public QObject
public:
using CoreAVPtr = std::unique_ptr<CoreAV>;
using ToxFriendCallPtr = std::shared_ptr<ToxFriendCall>;
static CoreAVPtr makeCoreAV(Tox* core, CompatibleRecursiveMutex& toxCoreLock,
IAudioSettings& audioSettings, IGroupSettings& groupSettings,
CameraSource& cameraSource);
@ -59,18 +61,13 @@ public: @@ -59,18 +61,13 @@ public:
~CoreAV();
bool isCallStarted(const Friend* f) const;
bool isCallStarted(const Group* g) const;
bool isCallActive(const Friend* f) const;
bool isCallActive(const Group* g) const;
bool isCallVideoEnabled(const Friend* f) const;
bool sendCallAudio(uint32_t callId, const int16_t* pcm, size_t samples, uint8_t chans,
uint32_t rate) const;
void sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> frame);
bool sendGroupCallAudio(int groupNum, const int16_t* pcm, size_t samples, uint8_t chans,
uint32_t rate) const;
VideoSource* getVideoSourceFromCall(int friendNum) const;
void sendNoVideo();
void joinGroupCall(const Group& group);
@ -80,20 +77,15 @@ public: @@ -80,20 +77,15 @@ public:
bool isGroupCallInputMuted(const Group* g) const;
bool isGroupCallOutputMuted(const Group* g) const;
bool isCallInputMuted(const Friend* f) const;
bool isCallOutputMuted(const Friend* f) const;
void toggleMuteCallInput(const Friend* f);
void toggleMuteCallOutput(const Friend* f);
static void groupCallCallback(void* tox, uint32_t group, uint32_t peer, const int16_t* data,
unsigned samples, uint8_t channels, uint32_t sample_rate,
void* core);
void invalidateGroupCallPeerSource(const Group& group, ToxPk peerPk);
public slots:
bool startCall(uint32_t friendNum, bool video);
bool answerCall(uint32_t friendNum, bool video);
ToxFriendCallPtr startCall(uint32_t friendNum, bool video);
ToxFriendCallPtr answerCall(uint32_t friendNum, bool video);
bool cancelCall(uint32_t friendNum);
void timeoutCall(uint32_t friendNum);
void start();
signals:
@ -139,7 +131,6 @@ private: @@ -139,7 +131,6 @@ private:
std::unique_ptr<ToxAV, ToxAVDeleter> toxav;
std::unique_ptr<QThread> coreavThread;
QTimer* iterateTimer = nullptr;
using ToxFriendCallPtr = std::unique_ptr<ToxFriendCall>;
/**
* @brief Maps friend IDs to ToxFriendCall.
* @note Need to use STL container here, because Qt containers need a copy constructor.
@ -147,7 +138,7 @@ private: @@ -147,7 +138,7 @@ private:
std::map<uint32_t, ToxFriendCallPtr> calls;
using ToxGroupCallPtr = std::unique_ptr<ToxGroupCall>;
using ToxGroupCallPtr = std::shared_ptr<ToxGroupCall>;
/**
* @brief Maps group IDs to ToxGroupCalls.
* @note Need to use STL container here, because Qt containers need a copy constructor.

20
src/core/toxcall.cpp

@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
*/
ToxCall::ToxCall(bool VideoEnabled_, CoreAV& av_, IAudioControl& audio_)
: av{&av_}
: av{av_}
, audio(audio_)
, videoEnabled{VideoEnabled_}
, audioSource(audio_.makeSource())
@ -126,7 +126,7 @@ ToxFriendCall::ToxFriendCall(uint32_t friendNum, bool VideoEnabled, CoreAV& av_, @@ -126,7 +126,7 @@ ToxFriendCall::ToxFriendCall(uint32_t friendNum, bool VideoEnabled, CoreAV& av_,
{
connect(audioSource.get(), &IAudioSource::frameAvailable, this,
[this](const int16_t* pcm, size_t samples, uint8_t chans, uint32_t rate) {
av->sendCallAudio(friendId, pcm, samples, chans, rate);
av.sendCallAudio(friendId, pcm, samples, chans, rate);
});
connect(audioSource.get(), &IAudioSource::invalidated, this, &ToxFriendCall::onAudioSourceInvalidated);
@ -166,7 +166,7 @@ void ToxFriendCall::onAudioSourceInvalidated() @@ -166,7 +166,7 @@ void ToxFriendCall::onAudioSourceInvalidated()
auto newSrc = audio.makeSource();
connect(newSrc.get(), &IAudioSource::frameAvailable, this,
[this](const int16_t* pcm, size_t samples, uint8_t chans, uint32_t rate) {
av->sendCallAudio(friendId, pcm, samples, chans, rate);
av.sendCallAudio(friendId, pcm, samples, chans, rate);
});
audioSource = std::move(newSrc);
@ -202,6 +202,11 @@ void ToxFriendCall::playAudioBuffer(const int16_t* data, int samples, unsigned c @@ -202,6 +202,11 @@ void ToxFriendCall::playAudioBuffer(const int16_t* data, int samples, unsigned c
}
}
void ToxFriendCall::endCall()
{
av.cancelCall(friendId);
}
ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audio_)
: ToxCall(false, av_, audio_)
, group{group_}
@ -213,7 +218,7 @@ ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audi @@ -213,7 +218,7 @@ ToxGroupCall::ToxGroupCall(const Group& group_, CoreAV& av_, IAudioControl& audi
return;
}
av->sendGroupCallAudio(group.getId(), pcm, samples, chans, rate);
av.sendGroupCallAudio(group.getId(), pcm, samples, chans, rate);
});
connect(audioSource.get(), &IAudioSource::invalidated, this, &ToxGroupCall::onAudioSourceInvalidated);
@ -234,7 +239,7 @@ void ToxGroupCall::onAudioSourceInvalidated() @@ -234,7 +239,7 @@ void ToxGroupCall::onAudioSourceInvalidated()
return;
}
av->sendGroupCallAudio(group.getId(), pcm, samples, chans, rate);
av.sendGroupCallAudio(group.getId(), pcm, samples, chans, rate);
});
audioSource = std::move(newSrc);
@ -303,3 +308,8 @@ void ToxGroupCall::playAudioBuffer(const ToxPk& peer, const int16_t* data, int s @@ -303,3 +308,8 @@ void ToxGroupCall::playAudioBuffer(const ToxPk& peer, const int16_t* data, int s
source->second->playAudioBuffer(data, samples, channels, sampleRate);
}
}
void ToxGroupCall::endCall()
{
av.leaveGroupCall(group.getId());
}

23
src/core/toxcall.h

@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
#include <QMetaObject>
#include <QtGlobal>
#include <atomic>
#include <cstdint>
#include <memory>
@ -70,20 +71,22 @@ public: @@ -70,20 +71,22 @@ public:
bool getNullVideoBitrate() const;
void setNullVideoBitrate(bool value);
virtual void endCall() = 0;
CoreVideoSource* getVideoSource() const;
protected:
bool active{false};
CoreAV* av{nullptr};
std::atomic<bool> active{false};
CoreAV& av;
// audio
IAudioControl& audio;
bool muteMic{false};
bool muteVol{false};
std::atomic<bool> muteMic{false};
std::atomic<bool> muteVol{false};
// video
CoreVideoSource* videoSource{nullptr};
QMetaObject::Connection videoInConn;
bool videoEnabled{false};
bool nullVideoBitrate{false};
std::atomic<bool> videoEnabled{false};
std::atomic<bool> nullVideoBitrate{false};
std::unique_ptr<IAudioSource> audioSource;
};
@ -102,6 +105,10 @@ public: @@ -102,6 +105,10 @@ public:
void playAudioBuffer(const int16_t* data, int samples, unsigned channels, int sampleRate) const;
// ToxCall interface
public:
void endCall() override;
private slots:
void onAudioSourceInvalidated();
void onAudioSinkInvalidated();
@ -129,6 +136,10 @@ public: @@ -129,6 +136,10 @@ public:
void playAudioBuffer(const ToxPk& peer, const int16_t* data, int samples, unsigned channels,
int sampleRate);
// ToxCall interface
public:
void endCall() override;
private:
void addPeer(ToxPk peerId);
bool havePeer(ToxPk peerId);

79
src/widget/form/chatform.cpp

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#include "src/persistence/profile.h"
#include "src/persistence/settings.h"
#include "src/video/netcamview.h"
#include "src/video/corevideosource.h"
#include "src/widget/chatformheader.h"
#include "src/widget/contentdialogmanager.h"
#include "src/widget/form/loadhistorydialog.h"
@ -329,10 +330,8 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video) @@ -329,10 +330,8 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
auto testedFlag = video ? Settings::AutoAcceptCall::Video : Settings::AutoAcceptCall::Audio;
// AutoAcceptCall is set for this friend
if (settings.getAutoAcceptCall(f->getPublicKey()).testFlag(testedFlag)) {
qDebug() << "automatic call answer";
CoreAV* coreav = core.getAv();
QMetaObject::invokeMethod(coreav, "answerCall", Qt::QueuedConnection,
Q_ARG(uint32_t, friendId), Q_ARG(bool, video));
onAnswerCallTriggered(video);
// CoreAV doesn't send a signal when we answer the call
onAvStart(friendId, video);
} else {
headWidget->createCallConfirm(video);
@ -395,20 +394,32 @@ void ChatForm::onAnswerCallTriggered(bool video) @@ -395,20 +394,32 @@ void ChatForm::onAnswerCallTriggered(bool video)
emit acceptCall(friendId);
updateCallButtons();
if (call) {
qDebug() << "Stale call detected";
}
CoreAV* av = core.getAv();
if (!av->answerCall(friendId, video)) {
call = av->answerCall(friendId, video);
if (!call) {
qDebug() << "Failed to answer call";
updateCallButtons();
stopCounter();
hideNetcam();
return;
}
onAvStart(friendId, av->isCallVideoEnabled(f));
// CoreAV doesn't send the avStart() signal when we answer
onAvStart(friendId, call->getVideoEnabled());
}
void ChatForm::onRejectCallTriggered()
{
headWidget->removeCallConfirm();
if (call) {
call->endCall();
call.reset();
}
emit rejectCall(f->getId());
}
@ -416,10 +427,17 @@ void ChatForm::onCallTriggered() @@ -416,10 +427,17 @@ void ChatForm::onCallTriggered()
{
CoreAV* av = core.getAv();
uint32_t friendId = f->getId();
if (av->isCallStarted(f)) {
av->cancelCall(friendId);
} else if (av->startCall(friendId, false)) {
showOutgoingCall(false);
if (call) {
call->endCall();
call.reset();
} else {
call = av->startCall(friendId, false);
if (call) {
showOutgoingCall(false);
} else {
qDebug() << "Failed to start Audio call";
}
}
}
@ -427,21 +445,24 @@ void ChatForm::onVideoCallTriggered() @@ -427,21 +445,24 @@ void ChatForm::onVideoCallTriggered()
{
CoreAV* av = core.getAv();
uint32_t friendId = f->getId();
if (av->isCallStarted(f)) {
// TODO: We want to activate video on the active call.
if (av->isCallVideoEnabled(f)) {
av->cancelCall(friendId);
if (call) {
call->endCall();
call.reset();
} else {
call = av->startCall(friendId, true);
if (call) {
showOutgoingCall(true);
} else {
qDebug() << "Failed to start Video call";
}
} else if (av->startCall(friendId, true)) {
showOutgoingCall(true);
}
}
void ChatForm::updateCallButtons()
{
CoreAV* av = core.getAv();
const bool audio = av->isCallActive(f);
const bool video = av->isCallVideoEnabled(f);
const bool audio = call ? call->isActive() : false;
const bool video = call ? call->getVideoEnabled() : false;
const bool online = Status::isOnline(f->getStatus());
headWidget->updateCallButtons(online, audio, video);
updateMuteMicButton();
@ -450,15 +471,13 @@ void ChatForm::updateCallButtons() @@ -450,15 +471,13 @@ void ChatForm::updateCallButtons()
void ChatForm::onMicMuteToggle()
{
CoreAV* av = core.getAv();
av->toggleMuteCallInput(f);
call->setMuteMic(!call->getMuteMic());
updateMuteMicButton();
}
void ChatForm::onVolMuteToggle()
{
CoreAV* av = core.getAv();
av->toggleMuteCallOutput(f);
call->setMuteVol(!call->getMuteVol());
updateMuteVolButton();
}
@ -515,11 +534,9 @@ void ChatForm::onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic) @@ -515,11 +534,9 @@ void ChatForm::onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic)
std::unique_ptr<NetCamView> ChatForm::createNetcam()
{
qDebug() << "creating netcam";
uint32_t friendId = f->getId();
std::unique_ptr<NetCamView> view = std::unique_ptr<NetCamView>(
new NetCamView(f->getPublicKey(), cameraSource, settings, style, this));
CoreAV* av = core.getAv();
VideoSource* source = av->getVideoSourceFromCall(friendId);
VideoSource* source = call->getVideoSource();
view->show(source, f->getDisplayedName());
connect(view.get(), &NetCamView::videoCallEnd, this, &ChatForm::onVideoCallTriggered);
connect(view.get(), &NetCamView::volMuteToggle, this, &ChatForm::onVolMuteToggle);
@ -656,9 +673,8 @@ void ChatForm::onCopyStatusMessage() @@ -656,9 +673,8 @@ void ChatForm::onCopyStatusMessage()
void ChatForm::updateMuteMicButton()
{
const CoreAV* av = core.getAv();
bool active = av->isCallActive(f);
bool inputMuted = av->isCallInputMuted(f);
const bool active = call ? call->isActive() : false;
const bool inputMuted = call ? call->getMuteMic() : false;
headWidget->updateMuteMicButton(active, inputMuted);
if (netcam) {
netcam->updateMuteMicButton(inputMuted);
@ -667,9 +683,8 @@ void ChatForm::updateMuteMicButton() @@ -667,9 +683,8 @@ void ChatForm::updateMuteMicButton()
void ChatForm::updateMuteVolButton()
{
const CoreAV* av = core.getAv();
bool active = av->isCallActive(f);
bool outputMuted = av->isCallOutputMuted(f);
const bool active = call ? call->isActive() : false;
const bool outputMuted = call ? call->getMuteVol() : false;
headWidget->updateMuteVolButton(active, outputMuted);
if (netcam) {
netcam->updateMuteVolButton(outputMuted);

2
src/widget/form/chatform.h

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include "genericchatform.h"
#include "src/core/core.h"
#include "src/core/coreav.h"
#include "src/model/ichatlog.h"
#include "src/model/imessagedispatcher.h"
#include "src/model/status.h"
@ -152,4 +153,5 @@ private: @@ -152,4 +153,5 @@ private:
Settings& settings;
Style& style;
ContentDialogManager& contentDialogManager;
CoreAV::ToxFriendCallPtr call;
};

7
src/widget/widget.cpp

@ -1144,12 +1144,6 @@ void Widget::dispatchFileSendFailed(uint32_t friendId, const QString& fileName) @@ -1144,12 +1144,6 @@ void Widget::dispatchFileSendFailed(uint32_t friendId, const QString& fileName)
SystemMessageType::fileSendFailed, {fileName});
}
void Widget::onRejectCall(uint32_t friendId)
{
CoreAV* const av = core->getAv();
av->cancelCall(friendId);
}
void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
{
assert(core != nullptr);
@ -1210,7 +1204,6 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk) @@ -1210,7 +1204,6 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
connect(friendForm, &ChatForm::outgoingNotification, this, &Widget::outgoingNotification);
connect(friendForm, &ChatForm::stopNotification, this, &Widget::onStopNotification);
connect(friendForm, &ChatForm::endCallNotification, this, &Widget::onCallEnd);
connect(friendForm, &ChatForm::rejectCall, this, &Widget::onRejectCall);
connect(widget, &FriendWidget::newWindowOpened, this, &Widget::openNewDialog);
connect(widget, &FriendWidget::chatroomWidgetClicked, this, &Widget::onChatroomWidgetClicked);

1
src/widget/widget.h

@ -243,7 +243,6 @@ private slots: @@ -243,7 +243,6 @@ private slots:
void outgoingNotification();
void onCallEnd();
void incomingNotification(uint32_t friendNum);
void onRejectCall(uint32_t friendId);
void onStopNotification();
void dispatchFile(ToxFile file);
void dispatchFileWithBool(ToxFile file, bool pausedOrBroken);

Loading…
Cancel
Save