Store whether a participant is connected or not

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-09-16 00:09:41 +02:00
parent 719797b1d1
commit c2ef651ce3
2 changed files with 34 additions and 3 deletions

View file

@ -2050,6 +2050,18 @@ public class CallActivity extends CallBaseActivity {
String sessionId = peerConnectionEvent.getSessionId();
if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED) {
if (participantDisplayItems.get(sessionId) != null) {
participantDisplayItems.get(sessionId).setConnected(true);
participantsAdapter.notifyDataSetChanged();
}
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED) {
if (participantDisplayItems.get(sessionId) != null) {
participantDisplayItems.get(sessionId).setConnected(false);
participantsAdapter.notifyDataSetChanged();
}
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_CLOSED) {
endPeerConnection(sessionId, VIDEO_STREAM_TYPE_SCREEN.equals(peerConnectionEvent.getVideoStreamType()));
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
@ -2239,12 +2251,20 @@ public class CallActivity extends CallBaseActivity {
String session,
boolean videoStreamEnabled,
String videoStreamType) {
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
videoStreamType);
boolean connected = false;
if (peerConnectionWrapper != null) {
PeerConnection.IceConnectionState iceConnectionState = peerConnectionWrapper.getPeerConnection().iceConnectionState();
connected = iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
}
String nick;
if (hasExternalSignalingServer) {
nick = webSocketClient.getDisplayNameForSession(session);
} else {
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
videoStreamType);
nick = peerConnectionWrapper != null ? peerConnectionWrapper.getNick() : "";
}
@ -2268,6 +2288,7 @@ public class CallActivity extends CallBaseActivity {
ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(userId,
session,
connected,
nick,
urlForAvatar,
mediaStream,

View file

@ -6,6 +6,7 @@ import org.webrtc.MediaStream;
public class ParticipantDisplayItem {
private String userId;
private String session;
private boolean connected;
private String nick;
private String urlForAvatar;
private MediaStream mediaStream;
@ -14,9 +15,10 @@ public class ParticipantDisplayItem {
private EglBase rootEglBase;
private boolean isAudioEnabled;
public ParticipantDisplayItem(String userId, String session, String nick, String urlForAvatar, MediaStream mediaStream, String streamType, boolean streamEnabled, EglBase rootEglBase) {
public ParticipantDisplayItem(String userId, String session, boolean connected, String nick, String urlForAvatar, MediaStream mediaStream, String streamType, boolean streamEnabled, EglBase rootEglBase) {
this.userId = userId;
this.session = session;
this.connected = connected;
this.nick = nick;
this.urlForAvatar = urlForAvatar;
this.mediaStream = mediaStream;
@ -41,6 +43,14 @@ public class ParticipantDisplayItem {
this.session = session;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public String getNick() {
return nick;
}