1
0
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_Bit_Rate_Set

This commit is contained in:
Anthony Bilinski 2022-03-18 00:38:52 -07:00
parent 47a05c7592
commit a5660fb6e3
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 37 additions and 2 deletions

View File

@ -407,7 +407,11 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
if (call.getNullVideoBitrate()) { if (call.getNullVideoBitrate()) {
qDebug() << "Restarting video stream to friend" << callId; qDebug() << "Restarting video stream to friend" << callId;
QMutexLocker coreLocker{&coreLock}; QMutexLocker coreLocker{&coreLock};
toxav_video_set_bit_rate(toxav.get(), callId, VIDEO_DEFAULT_BITRATE, nullptr); Toxav_Err_Bit_Rate_Set err;
toxav_video_set_bit_rate(toxav.get(), callId, VIDEO_DEFAULT_BITRATE, &err);
if (!PARSE_ERR(err)) {
return;
}
call.setNullVideoBitrate(false); call.setNullVideoBitrate(false);
} }
@ -724,7 +728,11 @@ void CoreAV::sendNoVideo()
qDebug() << "CoreAV: Signaling end of video sending"; qDebug() << "CoreAV: Signaling end of video sending";
for (auto& kv : calls) { for (auto& kv : calls) {
ToxFriendCall& call = *kv.second; ToxFriendCall& call = *kv.second;
toxav_video_set_bit_rate(toxav.get(), kv.first, 0, nullptr); Toxav_Err_Bit_Rate_Set err;
toxav_video_set_bit_rate(toxav.get(), kv.first, 0, &err);
if (!PARSE_ERR(err)) {
continue;
}
call.setNullVideoBitrate(true); call.setNullVideoBitrate(true);
} }
} }

View File

@ -55,6 +55,7 @@ namespace ToxcoreErrorParser {
bool parseErr(Tox_Err_File_Get error, int line); bool parseErr(Tox_Err_File_Get error, int line);
bool parseErr(Tox_Err_File_Send error, int line); bool parseErr(Tox_Err_File_Send error, int line);
bool parseErr(Tox_Err_File_Send_Chunk error, int line); bool parseErr(Tox_Err_File_Send_Chunk error, int line);
bool parseErr(Toxav_Err_Bit_Rate_Set error, int line);
bool parseErr(Toxav_Err_Call_Control error, int line); bool parseErr(Toxav_Err_Call_Control error, int line);
bool parseErr(Toxav_Err_Call error, int line); bool parseErr(Toxav_Err_Call error, int line);
} // namespace ToxcoreErrorParser } // namespace ToxcoreErrorParser

View File

@ -544,6 +544,32 @@ bool ToxcoreErrorParser::parseErr(Tox_Err_File_Send_Chunk error, int line)
return false; return false;
} }
bool ToxcoreErrorParser::parseErr(Toxav_Err_Bit_Rate_Set error, int line)
{
switch (error) {
case TOXAV_ERR_BIT_RATE_SET_OK:
return true;
case TOXAV_ERR_BIT_RATE_SET_SYNC:
qCritical() << line << ": Synchronization error occurred.";
return false;
case TOXAV_ERR_BIT_RATE_SET_INVALID_BIT_RATE:
qCritical() << line << ": The bit rate passed was not one of the supported values.";
return false;
case TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND:
qCritical() << line << ": The friend_number passed did not designate a valid friend.";
return false;
case TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL:
qCritical() << line << ": This client is currently not in a call with the friend.";
return false;
}
qCritical() << line << "Unknown Toxav_Err_Bit_Rate_Set error code:" << error;
return false;
}
bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line) bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line)
{ {
switch (error) { switch (error) {