From c2ef651ce3110259991fc711aa7540464159188e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Sep 2022 00:09:41 +0200 Subject: [PATCH] Store whether a participant is connected or not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- .../talk/activities/CallActivity.java | 25 +++++++++++++++++-- .../talk/adapters/ParticipantDisplayItem.java | 12 ++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index be0d6ac1b..0c0a2c469 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -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, diff --git a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.java b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.java index aefb742d8..adc75a338 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantDisplayItem.java @@ -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; }