1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(toxcall): make toxcall a class with getters and setters

This commit is contained in:
sudden6 2017-10-27 19:35:25 +02:00
parent 1dce8f6468
commit 90bf0a7e2c
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 263 additions and 99 deletions

View File

@ -105,8 +105,9 @@ CoreAV::CoreAV(Tox* tox)
CoreAV::~CoreAV()
{
for (const auto& call : calls)
for (const auto& call : calls) {
cancelCall(call.first);
}
killTimerFromThread();
toxav_kill(toxav);
coreavThread->exit(0);
@ -198,7 +199,7 @@ bool CoreAV::isCallStarted(const Group* g) const
*/
bool CoreAV::isCallActive(const Friend* f) const
{
return isCallStarted(f) ? !(calls[f->getId()].inactive) : false;
return isCallStarted(f) && calls[f->getId()].isActive();
}
/**
@ -208,12 +209,12 @@ bool CoreAV::isCallActive(const Friend* f) const
*/
bool CoreAV::isCallActive(const Group* g) const
{
return isCallStarted(g) ? !(groupCalls[g->getId()].inactive) : false;
return isCallStarted(g) && groupCalls[g->getId()].isActive();
}
bool CoreAV::isCallVideoEnabled(const Friend* f) const
{
return isCallStarted(f) ? calls[f->getId()].videoEnabled : false;
return isCallStarted(f) && calls[f->getId()].getVideoEnabled();
}
bool CoreAV::answerCall(uint32_t friendNum, bool video)
@ -238,7 +239,7 @@ bool CoreAV::answerCall(uint32_t friendNum, bool video)
const uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
if (toxav_answer(toxav, friendNum, Settings::getInstance().getAudioBitrate(), videoBitrate, &err)) {
calls[friendNum].inactive = false;
calls[friendNum].setActive(false);
return true;
} else {
qWarning() << "Failed to answer call with error" << err;
@ -275,7 +276,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
if (!toxav_call(toxav, friendNum, Settings::getInstance().getAudioBitrate(), videoBitrate, nullptr))
return false;
calls[friendNum] = ToxFriendCall{friendNum, video, *this};
calls.insert(std::make_pair(friendNum, ToxFriendCall(friendNum, video, *this)));
calls[friendNum].startTimeout(friendNum);
return true;
}
@ -336,12 +337,13 @@ void CoreAV::timeoutCall(uint32_t friendNum)
bool CoreAV::sendCallAudio(uint32_t callId, const int16_t* pcm, size_t samples, uint8_t chans,
uint32_t rate)
{
if (calls.find(callId) == calls.end())
if (calls.find(callId) == calls.end()) {
return false;
}
ToxFriendCall& call = calls[callId];
if (call.muteMic || call.inactive || !(call.state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) {
if (call.getMuteMic() || call.isActive() || !(call.getState() & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) {
return true;
}
@ -358,8 +360,9 @@ bool CoreAV::sendCallAudio(uint32_t callId, const int16_t* pcm, size_t samples,
}
}
} while (err == TOXAV_ERR_SEND_FRAME_SYNC && retries < 5);
if (err == TOXAV_ERR_SEND_FRAME_SYNC)
if (err == TOXAV_ERR_SEND_FRAME_SYNC) {
qDebug() << "toxav_audio_send_frame error: Lock busy, dropping frame";
}
return true;
}
@ -368,18 +371,20 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
{
// We might be running in the FFmpeg thread and holding the CameraSource lock
// So be careful not to deadlock with anything while toxav locks in toxav_video_send_frame
if (calls.find(callId) == calls.end())
if (calls.find(callId) == calls.end()) {
return;
}
ToxFriendCall& call = calls[callId];
if (!call.videoEnabled || call.inactive || !(call.state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V))
if (!call.getVideoEnabled() || call.isActive() || !(call.getState() & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V)) {
return;
}
if (call.nullVideoBitrate) {
if (call.getVideoEnabled()) {
qDebug() << "Restarting video stream to friend" << callId;
toxav_bit_rate_set(toxav, callId, -1, VIDEO_DEFAULT_BITRATE, nullptr);
call.nullVideoBitrate = false;
call.setVideoEnabled(false);
}
ToxYUVFrame frame = vframe->toToxYUVFrame();
@ -403,8 +408,9 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
}
}
} while (err == TOXAV_ERR_SEND_FRAME_SYNC && retries < 5);
if (err == TOXAV_ERR_SEND_FRAME_SYNC)
if (err == TOXAV_ERR_SEND_FRAME_SYNC) {
qDebug() << "toxav_video_send_frame error: Lock busy, dropping frame";
}
}
/**
@ -415,7 +421,7 @@ void CoreAV::toggleMuteCallInput(const Friend* f)
{
if (f && (calls.find(f->getId()) != calls.end())) {
ToxCall& call = calls[f->getId()];
call.muteMic = !call.muteMic;
call.setMuteMic(!call.getMuteMic());
}
}
@ -427,7 +433,7 @@ void CoreAV::toggleMuteCallOutput(const Friend* f)
{
if (f && (calls.find(f->getId()) != calls.end())) {
ToxCall& call = calls[f->getId()];
call.muteVol = !call.muteVol;
call.setMuteVol(call.getMuteVol());
}
}
@ -459,14 +465,16 @@ void CoreAV::groupCallCallback(void* tox, int group, int peer, const int16_t* da
emit c->groupPeerAudioPlaying(group, peer);
if (call.muteVol || call.inactive)
if (call.getMuteVol() || !call.isActive())
{
return;
}
Audio& audio = Audio::getInstance();
if (!call.peers[peer])
audio.subscribeOutput(call.peers[peer]);
if (!call.getPeers()[peer])
audio.subscribeOutput(call.getPeers()[peer]);
audio.playAudioBuffer(call.peers[peer], data, samples, channels, sample_rate);
audio.playAudioBuffer(call.getPeers()[peer], data, samples, channels, sample_rate);
}
/**
@ -477,8 +485,8 @@ void CoreAV::groupCallCallback(void* tox, int group, int peer, const int16_t* da
void CoreAV::invalidateGroupCallPeerSource(int group, int peer)
{
Audio& audio = Audio::getInstance();
audio.unsubscribeOutput(groupCalls[group].peers[peer]);
groupCalls[group].peers[peer] = 0;
audio.unsubscribeOutput(groupCalls[group].getPeers()[peer]);
groupCalls[group].getPeers()[peer] = 0;
}
/**
@ -494,7 +502,7 @@ VideoSource* CoreAV::getVideoSourceFromCall(int friendNum)
return nullptr;
}
return calls[friendNum].videoSource;
return calls[friendNum].getVideoSource();
}
/**
@ -507,7 +515,7 @@ void CoreAV::joinGroupCall(int groupId)
qDebug() << QString("Joining group call %1").arg(groupId);
groupCalls[groupId] = ToxGroupCall{groupId, *this};
groupCalls[groupId].inactive = false;
groupCalls[groupId].setActive(false);
}
/**
@ -531,8 +539,9 @@ bool CoreAV::sendGroupCallAudio(int groupId, const int16_t* pcm, size_t samples,
ToxGroupCall& call = groupCalls[groupId];
if (call.inactive || call.muteMic)
if (call.isActive() || call.getMuteMic()) {
return true;
}
if (toxav_group_send_audio(toxav_get_tox(toxav), groupId, pcm, samples, chans, rate) != 0)
qDebug() << "toxav_group_send_audio error";
@ -547,8 +556,9 @@ bool CoreAV::sendGroupCallAudio(int groupId, const int16_t* pcm, size_t samples,
*/
void CoreAV::muteCallInput(const Group* g, bool mute)
{
if (g && (groupCalls.find(g->getId()) != groupCalls.end()))
groupCalls[g->getId()].muteMic = mute;
if (g && (groupCalls.find(g->getId()) != groupCalls.end())) {
groupCalls[g->getId()].setMuteMic(mute);
}
}
/**
@ -558,8 +568,9 @@ void CoreAV::muteCallInput(const Group* g, bool mute)
*/
void CoreAV::muteCallOutput(const Group* g, bool mute)
{
if (g && (groupCalls.find(g->getId()) != groupCalls.end()))
groupCalls[g->getId()].muteVol = mute;
if (g && (groupCalls.find(g->getId()) != groupCalls.end())) {
groupCalls[g->getId()].setMuteVol(mute);
}
}
/**
@ -569,7 +580,12 @@ void CoreAV::muteCallOutput(const Group* g, bool mute)
*/
bool CoreAV::isGroupCallInputMuted(const Group* g) const
{
return g && (groupCalls.find(g->getId()) != groupCalls.end()) ? groupCalls[g->getId()].muteMic : false;
if (!g) {
return false;
}
const uint32_t groupId = g->getId();
return (groupCalls.find(groupId) != groupCalls.end()) && groupCalls[groupId].getMuteMic();
}
/**
@ -579,7 +595,12 @@ bool CoreAV::isGroupCallInputMuted(const Group* g) const
*/
bool CoreAV::isGroupCallOutputMuted(const Group* g) const
{
return g && (groupCalls.find(g->getId()) != groupCalls.end()) ? groupCalls[g->getId()].muteVol : false;
if (!g) {
return false;
}
const uint32_t groupId = g->getId();
return (groupCalls.find(groupId) != groupCalls.end()) && groupCalls[groupId].getMuteVol();
}
/**
@ -612,7 +633,11 @@ bool CoreAV::isGroupAvEnabled(int groupId) const
*/
bool CoreAV::isCallInputMuted(const Friend* f) const
{
return f && (calls.find(f->getId()) != calls.end()) ? calls[f->getId()].muteMic : false;
if (!f) {
return false;
}
const uint32_t friendId = f->getId();
return (calls.find(friendId) != calls.end()) && calls[friendId].getMuteMic();
}
/**
@ -622,7 +647,11 @@ bool CoreAV::isCallInputMuted(const Friend* f) const
*/
bool CoreAV::isCallOutputMuted(const Friend* f) const
{
return f && (calls.find(f->getId()) != calls.end()) ? calls[f->getId()].muteVol : false;
if (!f) {
return false;
}
const uint32_t friendId = f->getId();
return (calls.find(friendId) != calls.end()) && calls[f->getId()].getMuteVol();
}
/**
@ -631,11 +660,12 @@ bool CoreAV::isCallOutputMuted(const Friend* f) const
void CoreAV::invalidateCallSources()
{
for (auto& kv : groupCalls) {
kv.second.peers.clear();
kv.second.getPeers().clear();
}
for (auto& kv : calls) {
kv.second.alSource = 0;
// TODO: this is wrong, "0" is a valid source id
kv.second.setAlSource(0);
}
}
@ -650,7 +680,7 @@ void CoreAV::sendNoVideo()
for (auto& kv : calls) {
ToxFriendCall& call = kv.second;
toxav_bit_rate_set(toxav, kv.first, -1, 0, nullptr);
call.nullVideoBitrate = true;
call.setNullVideoBitrate(true);
}
}
@ -693,7 +723,7 @@ void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool vid
state |= TOXAV_FRIEND_CALL_STATE_SENDING_A | TOXAV_FRIEND_CALL_STATE_ACCEPTING_A;
if (video)
state |= TOXAV_FRIEND_CALL_STATE_SENDING_V | TOXAV_FRIEND_CALL_STATE_ACCEPTING_V;
calls[friendNum].state = static_cast<TOXAV_FRIEND_CALL_STATE>(state);
calls[friendNum].setState(static_cast<TOXAV_FRIEND_CALL_STATE>(state));
emit reinterpret_cast<CoreAV*>(self)->avInvite(friendNum, video);
self->threadSwitchLock.clear(std::memory_order_release);
@ -738,27 +768,29 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
emit self->avEnd(friendNum);
} else {
// If our state was null, we started the call and were still ringing
if (!call.state && state) {
if (!call.getState() && state) {
call.stopTimeout();
call.inactive = false;
emit self->avStart(friendNum, call.videoEnabled);
} else if ((call.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)
call.setActive(false);
emit self->avStart(friendNum, call.getVideoEnabled());
} else if ((call.getState() & TOXAV_FRIEND_CALL_STATE_SENDING_V)
&& !(state & TOXAV_FRIEND_CALL_STATE_SENDING_V)) {
qDebug() << "Friend" << friendNum << "stopped sending video";
if (call.videoSource)
call.videoSource->stopSource();
} else if (!(call.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)
if (call.getVideoSource()) {
call.getVideoSource()->stopSource();
}
} else if (!(call.getState() & TOXAV_FRIEND_CALL_STATE_SENDING_V)
&& (state & TOXAV_FRIEND_CALL_STATE_SENDING_V)) {
// Workaround toxav sometimes firing callbacks for "send last frame" -> "stop sending
// video"
// out of orders (even though they were sent in order by the other end).
// We simply stop the videoSource from emitting anything while the other end says it's
// not sending
if (call.videoSource)
call.videoSource->restartSource();
if (call.getVideoSource()) {
call.getVideoSource()->restartSource();
}
}
call.state = static_cast<TOXAV_FRIEND_CALL_STATE>(state);
call.setState(static_cast<TOXAV_FRIEND_CALL_STATE>(state));
}
self->threadSwitchLock.clear(std::memory_order_release);
}
@ -784,31 +816,38 @@ void CoreAV::audioFrameCallback(ToxAV*, uint32_t friendNum, const int16_t* pcm,
uint8_t channels, uint32_t samplingRate, void* vSelf)
{
CoreAV* self = static_cast<CoreAV*>(vSelf);
if (self->calls.find(friendNum) == self->calls.end())
if (self->calls.find(friendNum) == self->calls.end()) {
return;
}
ToxCall& call = self->calls[friendNum];
ToxFriendCall& call = self->calls[friendNum];
if (call.muteVol)
if (call.getMuteVol()) {
return;
}
Audio& audio = Audio::getInstance();
if (!call.alSource)
audio.subscribeOutput(call.alSource);
if (!call.getAlSource()) {
quint32 sourceId;
audio.subscribeOutput(sourceId);
call.setAlSource(sourceId);
}
audio.playAudioBuffer(call.alSource, pcm, sampleCount, channels, samplingRate);
audio.playAudioBuffer(call.getAlSource(), pcm, sampleCount, channels, samplingRate);
}
void CoreAV::videoFrameCallback(ToxAV*, uint32_t friendNum, uint16_t w, uint16_t h,
const uint8_t* y, const uint8_t* u, const uint8_t* v,
int32_t ystride, int32_t ustride, int32_t vstride, void*)
{
if (calls.find(friendNum) == calls.end())
if (calls.find(friendNum) == calls.end()) {
return;
}
ToxFriendCall& call = calls[friendNum];
if (!call.videoSource)
CoreVideoSource* videoSource = calls[friendNum].getVideoSource();
if (!videoSource) {
return;
}
vpx_image frame;
frame.d_h = h;
@ -820,5 +859,5 @@ void CoreAV::videoFrameCallback(ToxAV*, uint32_t friendNum, uint16_t w, uint16_t
frame.stride[1] = ustride;
frame.stride[2] = vstride;
call.videoSource->pushFrame(&frame);
videoSource->pushFrame(&frame);
}

View File

@ -30,57 +30,79 @@
using namespace std;
ToxCall::ToxCall(uint32_t CallId)
: alSource{0}
, inactive{true}
ToxCall::ToxCall()
: active{false}
, muteMic{false}
, muteVol{false}
{
Audio& audio = Audio::getInstance();
audio.subscribeInput();
audio.subscribeOutput(alSource);
}
ToxCall::ToxCall(ToxCall&& other) noexcept : audioInConn{other.audioInConn},
alSource{other.alSource},
inactive{other.inactive},
active{other.active},
muteMic{other.muteMic},
muteVol{other.muteVol}
{
other.audioInConn = QMetaObject::Connection();
other.alSource = 0;
// required -> ownership of audio input is moved to new instance
Audio& audio = Audio::getInstance();
audio.subscribeInput();
// invalidate object, all resources are moved
other.valid = false;
}
ToxCall::~ToxCall()
{
Audio& audio = Audio::getInstance();
QObject::disconnect(audioInConn);
audio.unsubscribeInput();
audio.unsubscribeOutput(alSource);
// only free resources if they weren't moved
if(valid) {
QObject::disconnect(audioInConn);
audio.unsubscribeInput();
}
}
ToxCall& ToxCall::operator=(ToxCall&& other) noexcept
{
audioInConn = other.audioInConn;
other.audioInConn = QMetaObject::Connection();
inactive = other.inactive;
active = other.active;
muteMic = other.muteMic;
muteVol = other.muteVol;
alSource = other.alSource;
other.alSource = 0;
// required -> ownership of audio input is moved to new instance
Audio& audio = Audio::getInstance();
audio.subscribeInput();
// invalidate object, all resources are moved
other.valid = false;
return *this;
}
bool ToxCall::isActive() const
{
return active;
}
void ToxCall::setActive(bool value)
{
active = value;
}
bool ToxCall::getMuteVol() const
{
return muteVol;
}
void ToxCall::setMuteVol(bool value)
{
muteVol = value;
}
bool ToxCall::getMuteMic() const
{
return muteMic;
}
void ToxCall::setMuteMic(bool value)
{
muteMic = value;
}
void ToxFriendCall::startTimeout(uint32_t callId)
{
if (!timeoutTimer) {
@ -105,8 +127,53 @@ void ToxFriendCall::stopTimeout()
timeoutTimer = nullptr;
}
ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
: ToxCall(FriendNum)
bool ToxFriendCall::getVideoEnabled() const
{
return videoEnabled;
}
void ToxFriendCall::setVideoEnabled(bool value)
{
videoEnabled = value;
}
bool ToxFriendCall::getNullVideoBitrate() const
{
return nullVideoBitrate;
}
void ToxFriendCall::setNullVideoBitrate(bool value)
{
nullVideoBitrate = value;
}
CoreVideoSource *ToxFriendCall::getVideoSource() const
{
return videoSource;
}
TOXAV_FRIEND_CALL_STATE ToxFriendCall::getState() const
{
return state;
}
void ToxFriendCall::setState(const TOXAV_FRIEND_CALL_STATE &value)
{
state = value;
}
quint32 ToxFriendCall::getAlSource() const
{
return alSource;
}
void ToxFriendCall::setAlSource(const quint32 &value)
{
alSource = value;
}
ToxFriendCall::ToxFriendCall(uint32_t friendId, bool VideoEnabled, CoreAV& av)
: ToxCall()
, videoEnabled{VideoEnabled}
, nullVideoBitrate{false}
, videoSource{nullptr}
@ -114,15 +181,19 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
, av{&av}
, timeoutTimer{nullptr}
{
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
[&av, FriendNum](const int16_t* pcm, size_t samples,
Audio& audio = Audio::getInstance();
audioInConn = QObject::connect(&audio, &Audio::frameAvailable,
[&av, friendId](const int16_t* pcm, size_t samples,
uint8_t chans, uint32_t rate) {
av.sendCallAudio(FriendNum, pcm, samples, chans, rate);
av.sendCallAudio(friendId, pcm, samples, chans, rate);
});
if(!audioInConn) {
qDebug() << "Audio connection not working";
}
// subscribe audio output
audio.subscribeOutput(alSource);
if (videoEnabled) {
videoSource = new CoreVideoSource;
CameraSource& source = CameraSource::getInstance();
@ -131,14 +202,15 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
source.setupDefault();
source.subscribe();
QObject::connect(&source, &VideoSource::frameAvailable,
[FriendNum, &av](shared_ptr<VideoFrame> frame) {
av.sendCallVideo(FriendNum, frame);
[friendId, &av](shared_ptr<VideoFrame> frame) {
av.sendCallVideo(friendId, frame);
});
}
}
ToxFriendCall::ToxFriendCall(ToxFriendCall&& other) noexcept
: ToxCall(move(other)),
alSource{other.alSource},
videoEnabled{other.videoEnabled},
nullVideoBitrate{other.nullVideoBitrate},
videoSource{other.videoSource},
@ -149,6 +221,8 @@ ToxFriendCall::ToxFriendCall(ToxFriendCall&& other) noexcept
other.videoEnabled = false;
other.videoSource = nullptr;
other.timeoutTimer = nullptr;
// TODO: wrong, because "0" could be a valid source id
other.alSource = 0;
}
ToxFriendCall::~ToxFriendCall()
@ -168,6 +242,9 @@ ToxFriendCall::~ToxFriendCall()
videoSource = nullptr;
}
}
if(valid) {
Audio::getInstance().unsubscribeOutput(alSource);
}
}
ToxFriendCall& ToxFriendCall::operator=(ToxFriendCall&& other) noexcept
@ -182,12 +259,15 @@ ToxFriendCall& ToxFriendCall::operator=(ToxFriendCall&& other) noexcept
other.timeoutTimer = nullptr;
av = other.av;
nullVideoBitrate = other.nullVideoBitrate;
alSource = other.alSource;
// TODO: wrong, because "0" could be a valid source id
other.alSource = 0;
return *this;
}
ToxGroupCall::ToxGroupCall(int GroupNum, CoreAV& av)
: ToxCall(static_cast<uint32_t>(GroupNum))
: ToxCall()
{
static_assert(
numeric_limits<uint32_t>::max() >= numeric_limits<decltype(GroupNum)>::max(),
@ -201,7 +281,10 @@ ToxGroupCall::ToxGroupCall(int GroupNum, CoreAV& av)
}
ToxGroupCall::ToxGroupCall(ToxGroupCall&& other) noexcept : ToxCall(move(other))
, peers{other.peers}
{
// all peers were moved, this ensures audio output is unsubscribed only once
other.peers.clear();
}
ToxGroupCall::~ToxGroupCall()
@ -216,6 +299,18 @@ ToxGroupCall::~ToxGroupCall()
ToxGroupCall& ToxGroupCall::operator=(ToxGroupCall&& other) noexcept
{
ToxCall::operator=(move(other));
peers = other.peers;
other.peers.clear();
return *this;
}
void ToxGroupCall::removePeer(int peerId)
{
peers.remove(peerId);
}
QMap<int, quint32> ToxGroupCall::getPeers() const
{
return peers;
}

View File

@ -13,11 +13,10 @@ class AudioFilterer;
class CoreVideoSource;
class CoreAV;
struct ToxCall
class ToxCall
{
protected:
ToxCall() = default;
explicit ToxCall(uint32_t CallId);
explicit ToxCall();
~ToxCall();
public:
@ -27,33 +26,58 @@ public:
ToxCall& operator=(const ToxCall& other) = delete;
ToxCall& operator=(ToxCall&& other) noexcept;
bool isInactive() const;
bool isActive() const;
void setActive(bool value);
bool getMuteVol() const;
void setMuteVol(bool value);
bool getMuteMic() const;
void setMuteMic(bool value);
protected:
QMetaObject::Connection audioInConn;
public:
quint32 alSource;
bool inactive;
bool active;
bool muteMic;
bool muteVol;
bool valid = true;
};
struct ToxFriendCall : public ToxCall
class ToxFriendCall : public ToxCall
{
public:
ToxFriendCall() = default;
ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av);
ToxFriendCall(uint32_t friendId, bool VideoEnabled, CoreAV& av);
ToxFriendCall(ToxFriendCall&& other) noexcept;
~ToxFriendCall();
ToxFriendCall& operator=(ToxFriendCall&& other) noexcept;
void startTimeout(uint32_t callId);
void stopTimeout();
bool getVideoEnabled() const;
void setVideoEnabled(bool value);
bool getNullVideoBitrate() const;
void setNullVideoBitrate(bool value);
CoreVideoSource *getVideoSource() const;
TOXAV_FRIEND_CALL_STATE getState() const;
void setState(const TOXAV_FRIEND_CALL_STATE &value);
quint32 getAlSource() const;
void setAlSource(const quint32 &value);
private:
quint32 alSource;
bool videoEnabled;
bool nullVideoBitrate;
CoreVideoSource* videoSource;
TOXAV_FRIEND_CALL_STATE state;
void startTimeout(uint32_t callId);
void stopTimeout();
protected:
CoreAV* av;
QTimer* timeoutTimer;
@ -62,8 +86,9 @@ private:
static constexpr int CALL_TIMEOUT = 45000;
};
struct ToxGroupCall : public ToxCall
class ToxGroupCall : public ToxCall
{
public:
ToxGroupCall() = default;
ToxGroupCall(int GroupNum, CoreAV& av);
ToxGroupCall(ToxGroupCall&& other) noexcept;
@ -71,6 +96,11 @@ struct ToxGroupCall : public ToxCall
ToxGroupCall& operator=(ToxGroupCall&& other) noexcept;
void removePeer(int peerId);
QMap<int, quint32> getPeers() const;
private:
QMap<int, quint32> peers;
// If you add something here, don't forget to override the ctors and move operators!