From a5660fb6e350801dde68644a03381b481662cacd Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Fri, 18 Mar 2022 00:38:52 -0700 Subject: [PATCH] feat(core): Add error parsing for Toxav_Err_Bit_Rate_Set --- src/core/coreav.cpp | 12 ++++++++++-- util/include/util/toxcoreerrorparser.h | 1 + util/src/toxcoreerrorparser.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index 2280e08bc..0fc1cb176 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -407,7 +407,11 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr vframe) if (call.getNullVideoBitrate()) { qDebug() << "Restarting video stream to friend" << callId; 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); } @@ -724,7 +728,11 @@ void CoreAV::sendNoVideo() qDebug() << "CoreAV: Signaling end of video sending"; for (auto& kv : calls) { 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); } } diff --git a/util/include/util/toxcoreerrorparser.h b/util/include/util/toxcoreerrorparser.h index 3576a786f..fa101ac90 100644 --- a/util/include/util/toxcoreerrorparser.h +++ b/util/include/util/toxcoreerrorparser.h @@ -55,6 +55,7 @@ namespace ToxcoreErrorParser { bool parseErr(Tox_Err_File_Get error, int line); bool parseErr(Tox_Err_File_Send 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 error, int line); } // namespace ToxcoreErrorParser diff --git a/util/src/toxcoreerrorparser.cpp b/util/src/toxcoreerrorparser.cpp index f43ccf65f..ab772dce9 100644 --- a/util/src/toxcoreerrorparser.cpp +++ b/util/src/toxcoreerrorparser.cpp @@ -544,6 +544,32 @@ bool ToxcoreErrorParser::parseErr(Tox_Err_File_Send_Chunk error, int line) 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) { switch (error) {