Fix processing of participant list on reconnections

When the HPB is used the signaling messages can be received even when
the local participant is not currently in the call (for example, when
starting the call timed out without other participant joining, or when
reconnecting due to the publisher connection failing). Therefore if the
local participant is not in the call it should not try to establish a
connection with the other participants and disconnect them instead.

Moreover, if the connection is tried to be established when not
in the call the HPB will prevent that, and the PeerConnectionWrapper
will stay in a limbo state waiting for an offer to be sent. If the local
participant then joins the call the PeerConnectionWrapper will already
exist for the other participants, so no new connections will be created,
but those previous connections will never be finally established.

Additionally, as the signaling messages can be received before the join
call response the participant list could be received while the call
state is "RECONNECTING" or "PUBLISHER_FAILED". In those cases, as long
as the local participant is already in the call, the participant list
should be processed as if the call state was already "JOINED" (otherwise
the connections were not established either).

For simplicity the participant list is now ignored only when the call
state is "LEAVING"; this means that the participant list would be also
processed in the "CONNECTION_TIMEOUT" state, but the signaling message
should not be received anyway in that case.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-11-20 01:51:29 +01:00 committed by Marcel Hibbe (Rebase PR Action)
parent 8cdcc63687
commit 331bf49f73

View file

@ -1853,6 +1853,8 @@ public class CallActivity extends CallBaseActivity {
Log.d(TAG, " currentSessionId is " + currentSessionId);
boolean isSelfInCall = false;
for (HashMap<String, Object> participant : users) {
long inCallFlag = (long) participant.get("inCall");
if (!participant.get("sessionId").equals(currentSessionId)) {
@ -1876,6 +1878,7 @@ public class CallActivity extends CallBaseActivity {
userIdsBySessionId.put(participant.get("sessionId").toString(), userId);
} else {
Log.d(TAG, " inCallFlag of currentSessionId: " + inCallFlag);
isSelfInCall = inCallFlag != 0;
if (inCallFlag == 0 && currentCallStatus != CallStatus.LEAVING && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) {
Log.d(TAG, "Most probably a moderator ended the call for all.");
hangup(true);
@ -1891,6 +1894,17 @@ public class CallActivity extends CallBaseActivity {
}
}
if (!isSelfInCall) {
Log.d(TAG, "Self not in call, disconnecting from all other sessions");
for (String sessionId : oldSessions) {
Log.d(TAG, " oldSession that will be removed is: " + sessionId);
endPeerConnection(sessionId, false);
}
return;
}
// Calculate sessions that left the call
List<String> disconnectedSessions = new ArrayList<>(oldSessions);
disconnectedSessions.removeAll(newSessions);
@ -1898,7 +1912,7 @@ public class CallActivity extends CallBaseActivity {
// Calculate sessions that join the call
newSessions.removeAll(oldSessions);
if (!isConnectionEstablished() && currentCallStatus != CallStatus.CONNECTING) {
if (currentCallStatus == CallStatus.LEAVING) {
return;
}