mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix crash on video calls lowered to audio calls
Toxcore would incorrectly report the call as a video call in the call settings, and then crash while trying to send a video frame in the audio call. We workaround that by using another API that correctly reports the type of the call
This commit is contained in:
parent
b44725adda
commit
bb5f2e066d
|
@ -91,9 +91,10 @@ void Core::prepareCall(uint32_t friendId, int32_t callId, ToxAv* toxav, bool vid
|
||||||
|
|
||||||
void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
|
void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
|
||||||
{
|
{
|
||||||
ToxAvCSettings settings;
|
|
||||||
int friendId;
|
int friendId;
|
||||||
if (toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &settings) < 0)
|
int cap = toxav_capability_supported((ToxAv*)toxav, callId,
|
||||||
|
(ToxAvCapabilities)(av_VideoEncoding|av_VideoDecoding));
|
||||||
|
if (!cap)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
friendId = toxav_get_peer_id((ToxAv*)toxav, callId, 0);
|
friendId = toxav_get_peer_id((ToxAv*)toxav, callId, 0);
|
||||||
|
@ -102,20 +103,21 @@ void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
|
||||||
|
|
||||||
qDebug() << "Core: Received media change from friend "<<friendId;
|
qDebug() << "Core: Received media change from friend "<<friendId;
|
||||||
|
|
||||||
if (settings.call_type == av_TypeAudio)
|
if (cap == (av_VideoEncoding|av_VideoDecoding)) // Video call
|
||||||
{
|
|
||||||
calls[callId].videoEnabled = false;
|
|
||||||
calls[callId].sendVideoTimer->stop();
|
|
||||||
Camera::getInstance()->unsubscribe();
|
|
||||||
emit ((Core*)core)->avMediaChange(friendId, callId, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Camera::getInstance()->subscribe();
|
Camera::getInstance()->subscribe();
|
||||||
calls[callId].videoEnabled = true;
|
calls[callId].videoEnabled = true;
|
||||||
calls[callId].sendVideoTimer->start();
|
calls[callId].sendVideoTimer->start();
|
||||||
emit ((Core*)core)->avMediaChange(friendId, callId, true);
|
emit ((Core*)core)->avMediaChange(friendId, callId, true);
|
||||||
}
|
}
|
||||||
|
else // Audio call
|
||||||
|
{
|
||||||
|
calls[callId].videoEnabled = false;
|
||||||
|
calls[callId].sendVideoTimer->stop();
|
||||||
|
Camera::getInstance()->unsubscribe();
|
||||||
|
emit ((Core*)core)->avMediaChange(friendId, callId, false);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fail: // Centralized error handling
|
fail: // Centralized error handling
|
||||||
|
|
Loading…
Reference in New Issue
Block a user