From d7706b608295629509080bee9e0e11a531de5177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 17 Oct 2022 12:25:03 +0200 Subject: [PATCH] Fix remote participants display with both video and screen share MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ParticipantDisplayItems are not associated to a full participant but to each of the single connections that the participant may have (video and screen). However, when they are added to the map only the session ID is used as key. Due to this when a participant starts a screen share the ParticipantDisplayItem for the screen share overwrites the item for the video, and once the screen share is stopped the old item is not restored. Moreover, if a participant is already sharing a screen when the local participant joins whether the video or the screen share is shown is undefined and depends on which connection is established first. To solve that the ParticipantDisplayItems are now associated with both the session ID and the video stream type ("video" or "screen"). Due to this both the video and the screen share of the remote participant are shown in the grid view; in the future it might be better to only show the screen share, or allow switching between screen share and video, or show the screen share in full screen and hide the grid... but for now, as a quick fix, this is good enough :-) Signed-off-by: Daniel Calviño Sánchez --- .../com/nextcloud/talk/activities/CallActivity.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 ecdefcfae..01e339d28 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -2087,8 +2087,9 @@ public class CallActivity extends CallBaseActivity { if (!(peerConnectionWrappers = getPeerConnectionWrapperListForSessionId(sessionId)).isEmpty()) { for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrappers) { if (peerConnectionWrapper.getSessionId().equals(sessionId)) { - if (VIDEO_STREAM_TYPE_SCREEN.equals(peerConnectionWrapper.getVideoStreamType()) || !justScreen) { - runOnUiThread(() -> removeMediaStream(sessionId)); + String videoStreamType = peerConnectionWrapper.getVideoStreamType(); + if (VIDEO_STREAM_TYPE_SCREEN.equals(videoStreamType) || !justScreen) { + runOnUiThread(() -> removeMediaStream(sessionId, videoStreamType)); deletePeerConnection(peerConnectionWrapper); } } @@ -2096,9 +2097,9 @@ public class CallActivity extends CallBaseActivity { } } - private void removeMediaStream(String sessionId) { + private void removeMediaStream(String sessionId, String videoStreamType) { Log.d(TAG, "removeMediaStream"); - participantDisplayItems.remove(sessionId); + participantDisplayItems.remove(sessionId + "-" + videoStreamType); if (!isDestroyed()) { initGridAdapter(); @@ -2409,7 +2410,7 @@ public class CallActivity extends CallBaseActivity { videoStreamType, videoStreamEnabled, rootEglBase); - participantDisplayItems.put(session, participantDisplayItem); + participantDisplayItems.put(session + "-" + videoStreamType, participantDisplayItem); initGridAdapter(); }