mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(core): Add error parsing for Toxav_Err_Call
This commit is contained in:
parent
47a20f6061
commit
47a05c7592
|
@ -292,9 +292,12 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
|
|||
}
|
||||
|
||||
uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
|
||||
if (!toxav_call(toxav.get(), friendNum, audioSettings.getAudioBitrate(), videoBitrate,
|
||||
nullptr))
|
||||
Toxav_Err_Call err;
|
||||
toxav_call(toxav.get(), friendNum, audioSettings.getAudioBitrate(), videoBitrate,
|
||||
&err);
|
||||
if (!PARSE_ERR(err)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Audio backend must be set before making a call
|
||||
assert(audio != nullptr);
|
||||
|
|
|
@ -56,4 +56,5 @@ namespace ToxcoreErrorParser {
|
|||
bool parseErr(Tox_Err_File_Send error, int line);
|
||||
bool parseErr(Tox_Err_File_Send_Chunk error, int line);
|
||||
bool parseErr(Toxav_Err_Call_Control error, int line);
|
||||
bool parseErr(Toxav_Err_Call error, int line);
|
||||
} // namespace ToxcoreErrorParser
|
||||
|
|
|
@ -569,3 +569,37 @@ bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line)
|
|||
qCritical() << line << "Unknown Toxav_Err_Call_Control error code:" << error;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxcoreErrorParser::parseErr(Toxav_Err_Call error, int line)
|
||||
{
|
||||
switch (error) {
|
||||
case TOXAV_ERR_CALL_OK:
|
||||
return true;
|
||||
|
||||
case TOXAV_ERR_CALL_MALLOC:
|
||||
qCritical() << line << ": A resource allocation error occurred.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_SYNC:
|
||||
qCritical() << line << ": Synchronization error occurred.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_FRIEND_NOT_FOUND:
|
||||
qCritical() << line << ": The friend number did not designate a valid friend.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED:
|
||||
qCritical() << line << ": The friend was valid, but not currently connected.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL:
|
||||
qCritical() << line << ": Attempted to call a friend while already in a call with them.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_INVALID_BIT_RATE:
|
||||
qCritical() << line << ": Audio or video bit rate is invalid.";
|
||||
return false;
|
||||
}
|
||||
qCritical() << line << "Unknown Toxav_Err_Call error code:" << error;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user