From 90064740e5b21fc160db73f60d515a95f7a4651b Mon Sep 17 00:00:00 2001 From: Dusan Stevanovic Date: Tue, 30 Jul 2024 12:51:02 +0200 Subject: [PATCH] fix aestab glitch when re-connecting for video --- include/avs_userlist.h | 3 ++- src/ccall/ccall.c | 21 +++++++++++++-------- src/userlist/userlist.c | 9 ++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/avs_userlist.h b/include/avs_userlist.h index 33ef02544..3917d3036 100644 --- a/include/avs_userlist.h +++ b/include/avs_userlist.h @@ -136,7 +136,8 @@ int userlist_set_latest_epoch_for_client(struct userlist *list, uint32_t userlist_get_key_index(struct userlist *list); void userlist_incall_clear(struct userlist *list, - bool force_decoder); + bool force_decoder, + bool again); uint32_t userlist_incall_count(struct userlist *list); diff --git a/src/ccall/ccall.c b/src/ccall/ccall.c index e92f7bafc..e46fadc5c 100644 --- a/src/ccall/ccall.c +++ b/src/ccall/ccall.c @@ -458,7 +458,8 @@ static void ccall_sync_vstate_timeout(void *arg) static void ccall_reconnect(struct ccall *ccall, uint32_t msg_time, - bool notify) + bool notify, + bool again) { bool decrypt_attempted = false; bool decrypt_successful = false; @@ -495,7 +496,8 @@ static void ccall_reconnect(struct ccall *ccall, ccall->metrics.reconnects_attempted++; } - userlist_incall_clear(ccall->userl, true); + userlist_incall_clear(ccall->userl, true, again); + set_state(ccall, CCALL_STATE_CONNSENT); if (ccall->sft_url) { sfti = ccall_get_sft_info(ccall, ccall->sft_url); @@ -539,7 +541,8 @@ static void ccall_decrypt_check_timeout(void *arg) info("ccall(%p): decrypt_check_timeout no confpart received, " "reconnecting\n", ccall); - ccall_reconnect(ccall, ECONN_MESSAGE_TIME_UNKNOWN, true); + ccall_reconnect(ccall, ECONN_MESSAGE_TIME_UNKNOWN, true, + false); return; } @@ -621,7 +624,7 @@ static void ccall_keepalive_timeout(void *arg) ecall_ping(ccall->ecall, false); ccall->expected_ping++; if (ccall->expected_ping > CCALL_MAX_MISSING_PINGS) { - ccall_reconnect(ccall, ECONN_MESSAGE_TIME_UNKNOWN, true); + ccall_reconnect(ccall, ECONN_MESSAGE_TIME_UNKNOWN, true, false); } else { tmr_start(&ccall->tmr_keepalive, CCALL_KEEPALIVE_TIMEOUT, @@ -927,7 +930,7 @@ static void ecall_media_estab_handler(struct icall *icall, const char *userid, if (CCALL_STATE_CONNSENT != ccall->state) { set_state(ccall, CCALL_STATE_ACTIVE); - userlist_incall_clear(ccall->userl, true); + userlist_incall_clear(ccall->userl, true, false); } else { info("ccall(%p): refusing to go to CCALL_STATE_ACTIVE " @@ -1015,11 +1018,13 @@ static void ecall_close_handler(struct icall *icall, ccall->expected_ping = 0; ccall->last_ping = 0; - ccall_reconnect(ccall, msg_time, err == ENOTCONN); + ccall_reconnect(ccall, msg_time, + err == ENOTCONN, + err == EAGAIN); return; } - userlist_incall_clear(ccall->userl, false); + userlist_incall_clear(ccall->userl, false, false); mem_deref(ecall); ccall->ecall = NULL; @@ -3816,7 +3821,7 @@ static void ccall_end_with_err(struct ccall *ccall, int err) break; } - userlist_incall_clear(ccall->userl, false); + userlist_incall_clear(ccall->userl, false, false); if (ccall->ecall) ecall_end(ccall->ecall); else diff --git a/src/userlist/userlist.c b/src/userlist/userlist.c index a7819521f..adbeb9656 100644 --- a/src/userlist/userlist.c +++ b/src/userlist/userlist.c @@ -688,7 +688,8 @@ uint32_t userlist_get_key_index(struct userlist *list) } void userlist_incall_clear(struct userlist *list, - bool force_decoder) + bool force_decoder, + bool again) { struct le *le; LIST_FOREACH(&list->users, le) { @@ -698,8 +699,10 @@ void userlist_incall_clear(struct userlist *list, u->incall_now = u->incall_now && force_decoder; u->force_decoder = u->incall_now; u->incall_prev = false; - u->ssrca = 0; - u->ssrcv = 0; + if (!again) { + u->ssrca = 0; + u->ssrcv = 0; + } } }