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.subscribeInput();
|
||||
audio.subscribeOutput(alSource);
|
||||
|
||||
audioInConn = QObject::connect(&Audio::getInstance(), &Audio::frameAvailable,
|
||||
[&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},
|
||||
muteMic{other.muteMic},
|
||||
muteVol{other.muteVol},
|
||||
alSource{other.alSource},
|
||||
videoSource{other.videoSource},
|
||||
videoInConn{other.videoInConn},
|
||||
videoEnabled{other.videoEnabled},
|
||||
|
@ -82,7 +80,6 @@ ToxCall::ToxCall(ToxCall&& other) noexcept : active{other.active},
|
|||
Audio& audio = Audio::getInstance();
|
||||
audio.subscribeInput();
|
||||
other.audioInConn = QMetaObject::Connection();
|
||||
other.alSource = 0;
|
||||
other.videoInConn = QMetaObject::Connection();
|
||||
other.videoEnabled = false; // we don't need to subscribe video because other won't unsubscribe
|
||||
other.videoSource = nullptr;
|
||||
|
@ -95,7 +92,6 @@ ToxCall::~ToxCall()
|
|||
|
||||
QObject::disconnect(audioInConn);
|
||||
audio.unsubscribeInput();
|
||||
audio.unsubscribeOutput(alSource);
|
||||
if (videoEnabled) {
|
||||
QObject::disconnect(videoInConn);
|
||||
CameraSource::getInstance().unsubscribe();
|
||||
|
@ -117,9 +113,6 @@ ToxCall& ToxCall::operator=(ToxCall&& other) noexcept
|
|||
muteMic = other.muteMic;
|
||||
muteVol = other.muteVol;
|
||||
|
||||
alSource = other.alSource;
|
||||
other.alSource = 0;
|
||||
|
||||
Audio::getInstance().subscribeInput();
|
||||
|
||||
videoInConn = other.videoInConn;
|
||||
|
@ -190,12 +183,12 @@ CoreVideoSource* ToxCall::getVideoSource() const
|
|||
return videoSource;
|
||||
}
|
||||
|
||||
quint32 ToxCall::getAlSource() const
|
||||
quint32 ToxFriendCall::getAlSource() const
|
||||
{
|
||||
return alSource;
|
||||
}
|
||||
|
||||
void ToxCall::setAlSource(const quint32& value)
|
||||
void ToxFriendCall::setAlSource(const quint32& value)
|
||||
{
|
||||
alSource = value;
|
||||
}
|
||||
|
@ -203,6 +196,30 @@ void ToxCall::setAlSource(const quint32& value)
|
|||
ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& 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)
|
||||
|
@ -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
|
||||
other.peers.clear();
|
||||
|
|
|
@ -45,9 +45,6 @@ public:
|
|||
|
||||
CoreVideoSource* getVideoSource() const;
|
||||
|
||||
quint32 getAlSource() const;
|
||||
void setAlSource(const quint32& value);
|
||||
|
||||
protected:
|
||||
bool active{false};
|
||||
CoreAV* av{nullptr};
|
||||
|
@ -55,7 +52,6 @@ protected:
|
|||
QMetaObject::Connection audioInConn;
|
||||
bool muteMic{false};
|
||||
bool muteVol{false};
|
||||
quint32 alSource{0};
|
||||
// video
|
||||
CoreVideoSource* videoSource{nullptr};
|
||||
QMetaObject::Connection videoInConn;
|
||||
|
@ -68,8 +64,9 @@ class ToxFriendCall : public ToxCall
|
|||
public:
|
||||
ToxFriendCall() = delete;
|
||||
ToxFriendCall(uint32_t friendId, bool VideoEnabled, CoreAV& av);
|
||||
ToxFriendCall(ToxFriendCall&& other) noexcept = default;
|
||||
ToxFriendCall& operator=(ToxFriendCall&& other) noexcept = default;
|
||||
ToxFriendCall(ToxFriendCall&& other) noexcept;
|
||||
ToxFriendCall& operator=(ToxFriendCall&& other) noexcept;
|
||||
~ToxFriendCall();
|
||||
|
||||
void startTimeout(uint32_t callId);
|
||||
void stopTimeout();
|
||||
|
@ -77,12 +74,16 @@ public:
|
|||
TOXAV_FRIEND_CALL_STATE getState() const;
|
||||
void setState(const TOXAV_FRIEND_CALL_STATE& value);
|
||||
|
||||
quint32 getAlSource() const;
|
||||
void setAlSource(const quint32& value);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<QTimer> timeoutTimer;
|
||||
|
||||
private:
|
||||
TOXAV_FRIEND_CALL_STATE state{TOXAV_FRIEND_CALL_STATE_NONE};
|
||||
static constexpr int CALL_TIMEOUT = 45000;
|
||||
quint32 alSource{0};
|
||||
};
|
||||
|
||||
class ToxGroupCall : public ToxCall
|
||||
|
|
Loading…
Reference in New Issue
Block a user