mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix crash if call failed to start
This commit is contained in:
parent
38da22dded
commit
7b70fd0008
|
@ -185,6 +185,7 @@ signals:
|
||||||
void avRequestTimeout(int friendId, int callIndex);
|
void avRequestTimeout(int friendId, int callIndex);
|
||||||
void avPeerTimeout(int friendId, int callIndex);
|
void avPeerTimeout(int friendId, int callIndex);
|
||||||
void avMediaChange(int friendId, int callIndex, bool videoEnabled);
|
void avMediaChange(int friendId, int callIndex, bool videoEnabled);
|
||||||
|
void avCallFailed(int friendId);
|
||||||
|
|
||||||
void videoFrameReceived(vpx_image* frame);
|
void videoFrameReceived(vpx_image* frame);
|
||||||
|
|
||||||
|
|
|
@ -142,15 +142,32 @@ void Core::startCall(int friendId, bool video)
|
||||||
{
|
{
|
||||||
qDebug() << QString("Core: Starting new call with %1 with video").arg(friendId);
|
qDebug() << QString("Core: Starting new call with %1 with video").arg(friendId);
|
||||||
cSettings.call_type = TypeVideo;
|
cSettings.call_type = TypeVideo;
|
||||||
toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME);
|
if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0)
|
||||||
calls[callId].videoEnabled=true;
|
{
|
||||||
|
calls[callId].videoEnabled=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << QString("Core: Failed to start new video call with %1").arg(friendId);
|
||||||
|
emit avCallFailed(friendId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << QString("Core: Starting new call with %1 without video").arg(friendId);
|
qDebug() << QString("Core: Starting new call with %1 without video").arg(friendId);
|
||||||
cSettings.call_type = TypeAudio;
|
cSettings.call_type = TypeAudio;
|
||||||
toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME);
|
if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0)
|
||||||
calls[callId].videoEnabled=false;
|
{
|
||||||
|
calls[callId].videoEnabled=false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << QString("Core: Failed to start new audio call with %1").arg(friendId);
|
||||||
|
emit avCallFailed(friendId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,6 +459,18 @@ void ChatForm::onVideoCallTriggered()
|
||||||
emit startVideoCall(f->friendId, true);
|
emit startVideoCall(f->friendId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatForm::onAvCallFailed(int FriendId)
|
||||||
|
{
|
||||||
|
if (FriendId != f->friendId)
|
||||||
|
return;
|
||||||
|
|
||||||
|
audioInputFlag = false;
|
||||||
|
callButton->disconnect();
|
||||||
|
videoButton->disconnect();
|
||||||
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
||||||
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::onCancelCallTriggered()
|
void ChatForm::onCancelCallTriggered()
|
||||||
{
|
{
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
|
|
|
@ -55,6 +55,7 @@ public slots:
|
||||||
void onAvRequestTimeout(int FriendId, int CallId);
|
void onAvRequestTimeout(int FriendId, int CallId);
|
||||||
void onAvPeerTimeout(int FriendId, int CallId);
|
void onAvPeerTimeout(int FriendId, int CallId);
|
||||||
void onAvMediaChange(int FriendId, int CallId, bool video);
|
void onAvMediaChange(int FriendId, int CallId, bool video);
|
||||||
|
void onAvCallFailed(int FriendId);
|
||||||
void onMicMuteToggle();
|
void onMicMuteToggle();
|
||||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||||
void onAvatarRemoved(int FriendId);
|
void onAvatarRemoved(int FriendId);
|
||||||
|
|
|
@ -620,6 +620,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
||||||
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
||||||
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
||||||
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
|
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
|
||||||
|
connect(core, &Core::avCallFailed, newfriend->chatForm, &ChatForm::onAvCallFailed);
|
||||||
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
|
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
|
||||||
connect(core, &Core::friendAvatarChanged, newfriend->widget, &FriendWidget::onAvatarChange);
|
connect(core, &Core::friendAvatarChanged, newfriend->widget, &FriendWidget::onAvatarChange);
|
||||||
connect(core, &Core::friendAvatarRemoved, newfriend->chatForm, &ChatForm::onAvatarRemoved);
|
connect(core, &Core::friendAvatarRemoved, newfriend->chatForm, &ChatForm::onAvatarRemoved);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user