Start and end connections based on "inCall" flags changes

Until now the connections were started when a participant joined with
audio and/or video (or, if there was no HPB, if the self participant had
audio and/or video), and ended when a participant left the call. If a
participant starts or stops publishing while being in the call, either
because the user now selected a microphone or camera or because the
participant was granted permissions, the participant force reconnected
to the call (leave and join it again), which ensured that all other
participants started or ended the connections as needed. To avoid having
to force reconnect and have a smoother call experience now the clients
are expected to keep track of the "inCall" flags and start and end the
connections as needed with the existing session.

Note that if the client is used against an older Talk version everything
would still work as before; as the other participant leaves and joins
the call again with a different session when needed the call flags would
not be updated for the previous session (other than to leave it), so the
new code to handle the updated call flags should have no effect (and,
even if it does, the connection would be established as needed against
the new session once the participant joins again).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-12-04 13:45:48 +01:00
parent a87f2fb102
commit 215dbf502f

View file

@ -1903,6 +1903,31 @@ public class CallActivity extends CallBaseActivity {
setCallState(CallStatus.IN_CONVERSATION);
}
for (Participant participant : updated) {
String sessionId = participant.getSessionId();
if (sessionId.equals(currentSessionId)) {
continue;
}
boolean participantHasAudioOrVideo = participantInCallFlagsHaveAudioOrVideo(participant);
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(sessionId, "video");
if (hasMCU) {
if (participantHasAudioOrVideo && peerConnectionWrapper == null) {
getOrCreatePeerConnectionWrapperForSessionIdAndType(sessionId, "video", false);
} else if (!participantHasAudioOrVideo && peerConnectionWrapper != null) {
endPeerConnection(sessionId, "video");
}
} else {
if ((participantHasAudioOrVideo || selfParticipantHasAudioOrVideo) && peerConnectionWrapper == null) {
getOrCreatePeerConnectionWrapperForSessionIdAndType(sessionId, "video", false);
} else if (!participantHasAudioOrVideo && !selfParticipantHasAudioOrVideo && peerConnectionWrapper != null) {
endPeerConnection(sessionId, "video");
}
}
}
for (Participant participant : left) {
String sessionId = participant.getSessionId();
Log.d(TAG, " oldSession that will be removed is: " + sessionId);