Skip to content

Commit

Permalink
fix aestab glitch when re-connecting for video
Browse files Browse the repository at this point in the history
  • Loading branch information
z-dule committed Aug 5, 2024
1 parent cd23911 commit 9006474
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion include/avs_userlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
21 changes: 13 additions & 8 deletions src/ccall/ccall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/userlist/userlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit 9006474

Please sign in to comment.