mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(toxcall): move alSource into ToxFriendCall
This commit is contained in:
parent
ae350a6483
commit
811998b8df
|
@ -34,7 +34,6 @@ ToxCall::ToxCall(uint32_t CallId, bool VideoEnabled, CoreAV& av)
|
||||||
{
|
{
|
||||||
Audio& audio = Audio::getInstance();
|
Audio& audio = Audio::getInstance();
|
||||||
audio.subscribeInput();
|
audio.subscribeInput();
|
||||||
audio.subscribeOutput(alSource);
|
|
||||||
|
|
||||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||||
[&av, CallId](const int16_t* pcm, size_t samples, uint8_t chans,
|
[&av, CallId](const int16_t* pcm, size_t samples, uint8_t chans,
|
||||||
|
@ -73,7 +72,6 @@ ToxCall::ToxCall(ToxCall&& other) noexcept : active{other.active},
|
||||||
audioInConn{other.audioInConn},
|
audioInConn{other.audioInConn},
|
||||||
muteMic{other.muteMic},
|
muteMic{other.muteMic},
|
||||||
muteVol{other.muteVol},
|
muteVol{other.muteVol},
|
||||||
alSource{other.alSource},
|
|
||||||
videoSource{other.videoSource},
|
videoSource{other.videoSource},
|
||||||
videoInConn{other.videoInConn},
|
videoInConn{other.videoInConn},
|
||||||
videoEnabled{other.videoEnabled},
|
videoEnabled{other.videoEnabled},
|
||||||
|
@ -82,7 +80,6 @@ ToxCall::ToxCall(ToxCall&& other) noexcept : active{other.active},
|
||||||
Audio& audio = Audio::getInstance();
|
Audio& audio = Audio::getInstance();
|
||||||
audio.subscribeInput();
|
audio.subscribeInput();
|
||||||
other.audioInConn = QMetaObject::Connection();
|
other.audioInConn = QMetaObject::Connection();
|
||||||
other.alSource = 0;
|
|
||||||
other.videoInConn = QMetaObject::Connection();
|
other.videoInConn = QMetaObject::Connection();
|
||||||
other.videoEnabled = false; // we don't need to subscribe video because other won't unsubscribe
|
other.videoEnabled = false; // we don't need to subscribe video because other won't unsubscribe
|
||||||
other.videoSource = nullptr;
|
other.videoSource = nullptr;
|
||||||
|
@ -95,7 +92,6 @@ ToxCall::~ToxCall()
|
||||||
|
|
||||||
QObject::disconnect(audioInConn);
|
QObject::disconnect(audioInConn);
|
||||||
audio.unsubscribeInput();
|
audio.unsubscribeInput();
|
||||||
audio.unsubscribeOutput(alSource);
|
|
||||||
if (videoEnabled) {
|
if (videoEnabled) {
|
||||||
QObject::disconnect(videoInConn);
|
QObject::disconnect(videoInConn);
|
||||||
CameraSource::getInstance().unsubscribe();
|
CameraSource::getInstance().unsubscribe();
|
||||||
|
@ -117,9 +113,6 @@ ToxCall& ToxCall::operator=(ToxCall&& other) noexcept
|
||||||
muteMic = other.muteMic;
|
muteMic = other.muteMic;
|
||||||
muteVol = other.muteVol;
|
muteVol = other.muteVol;
|
||||||
|
|
||||||
alSource = other.alSource;
|
|
||||||
other.alSource = 0;
|
|
||||||
|
|
||||||
Audio::getInstance().subscribeInput();
|
Audio::getInstance().subscribeInput();
|
||||||
|
|
||||||
videoInConn = other.videoInConn;
|
videoInConn = other.videoInConn;
|
||||||
|
@ -190,12 +183,12 @@ CoreVideoSource* ToxCall::getVideoSource() const
|
||||||
return videoSource;
|
return videoSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 ToxCall::getAlSource() const
|
quint32 ToxFriendCall::getAlSource() const
|
||||||
{
|
{
|
||||||
return alSource;
|
return alSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToxCall::setAlSource(const quint32& value)
|
void ToxFriendCall::setAlSource(const quint32& value)
|
||||||
{
|
{
|
||||||
alSource = value;
|
alSource = value;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +196,30 @@ void ToxCall::setAlSource(const quint32& value)
|
||||||
ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
|
ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av)
|
||||||
: ToxCall(FriendNum, VideoEnabled, av)
|
: ToxCall(FriendNum, VideoEnabled, av)
|
||||||
{
|
{
|
||||||
|
Audio& audio = Audio::getInstance();
|
||||||
|
audio.subscribeOutput(alSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
ToxFriendCall::ToxFriendCall(ToxFriendCall &&other) noexcept
|
||||||
|
: ToxCall(std::move(other))
|
||||||
|
, alSource{other.alSource}
|
||||||
|
{
|
||||||
|
other.alSource = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToxFriendCall& ToxFriendCall::operator=(ToxFriendCall &&other) noexcept
|
||||||
|
{
|
||||||
|
ToxCall::operator=(std::move(other));
|
||||||
|
alSource = other.alSource;
|
||||||
|
other.alSource = 0;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToxFriendCall::~ToxFriendCall()
|
||||||
|
{
|
||||||
|
auto& audio = Audio::getInstance();
|
||||||
|
audio.unsubscribeOutput(alSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToxFriendCall::startTimeout(uint32_t callId)
|
void ToxFriendCall::startTimeout(uint32_t callId)
|
||||||
|
@ -243,7 +260,8 @@ ToxGroupCall::ToxGroupCall(int GroupNum, CoreAV& av)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxGroupCall::ToxGroupCall(ToxGroupCall&& other) noexcept : ToxCall(std::move(other)), peers{other.peers}
|
ToxGroupCall::ToxGroupCall(ToxGroupCall&& other) noexcept
|
||||||
|
: ToxCall(std::move(other)), peers{other.peers}
|
||||||
{
|
{
|
||||||
// all peers were moved, this ensures audio output is unsubscribed only once
|
// all peers were moved, this ensures audio output is unsubscribed only once
|
||||||
other.peers.clear();
|
other.peers.clear();
|
||||||
|
|
|
@ -45,9 +45,6 @@ public:
|
||||||
|
|
||||||
CoreVideoSource* getVideoSource() const;
|
CoreVideoSource* getVideoSource() const;
|
||||||
|
|
||||||
quint32 getAlSource() const;
|
|
||||||
void setAlSource(const quint32& value);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool active{false};
|
bool active{false};
|
||||||
CoreAV* av{nullptr};
|
CoreAV* av{nullptr};
|
||||||
|
@ -55,7 +52,6 @@ protected:
|
||||||
QMetaObject::Connection audioInConn;
|
QMetaObject::Connection audioInConn;
|
||||||
bool muteMic{false};
|
bool muteMic{false};
|
||||||
bool muteVol{false};
|
bool muteVol{false};
|
||||||
quint32 alSource{0};
|
|
||||||
// video
|
// video
|
||||||
CoreVideoSource* videoSource{nullptr};
|
CoreVideoSource* videoSource{nullptr};
|
||||||
QMetaObject::Connection videoInConn;
|
QMetaObject::Connection videoInConn;
|
||||||
|
@ -68,8 +64,9 @@ class ToxFriendCall : public ToxCall
|
||||||
public:
|
public:
|
||||||
ToxFriendCall() = delete;
|
ToxFriendCall() = delete;
|
||||||
ToxFriendCall(uint32_t friendId, bool VideoEnabled, CoreAV& av);
|
ToxFriendCall(uint32_t friendId, bool VideoEnabled, CoreAV& av);
|
||||||
ToxFriendCall(ToxFriendCall&& other) noexcept = default;
|
ToxFriendCall(ToxFriendCall&& other) noexcept;
|
||||||
ToxFriendCall& operator=(ToxFriendCall&& other) noexcept = default;
|
ToxFriendCall& operator=(ToxFriendCall&& other) noexcept;
|
||||||
|
~ToxFriendCall();
|
||||||
|
|
||||||
void startTimeout(uint32_t callId);
|
void startTimeout(uint32_t callId);
|
||||||
void stopTimeout();
|
void stopTimeout();
|
||||||
|
@ -77,12 +74,16 @@ public:
|
||||||
TOXAV_FRIEND_CALL_STATE getState() const;
|
TOXAV_FRIEND_CALL_STATE getState() const;
|
||||||
void setState(const TOXAV_FRIEND_CALL_STATE& value);
|
void setState(const TOXAV_FRIEND_CALL_STATE& value);
|
||||||
|
|
||||||
|
quint32 getAlSource() const;
|
||||||
|
void setAlSource(const quint32& value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QTimer> timeoutTimer;
|
std::unique_ptr<QTimer> timeoutTimer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TOXAV_FRIEND_CALL_STATE state{TOXAV_FRIEND_CALL_STATE_NONE};
|
TOXAV_FRIEND_CALL_STATE state{TOXAV_FRIEND_CALL_STATE_NONE};
|
||||||
static constexpr int CALL_TIMEOUT = 45000;
|
static constexpr int CALL_TIMEOUT = 45000;
|
||||||
|
quint32 alSource{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
class ToxGroupCall : public ToxCall
|
class ToxGroupCall : public ToxCall
|
||||||
|
|
Loading…
Reference in New Issue
Block a user