From 1321cb21a05ca78e69807a3c405cfad64e08539b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 2 Oct 2020 02:45:33 +0200 Subject: [PATCH] Fix frozen video when screen is shared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When another participant shared the screen a new offer was requested. However, the offer was requested for the video instead of for the screen, which caused the HPB to stop the previous video connection and replace it with a new one. As receiving new offers for an existing connection is not properly handled the offer was applied to the existing peer connection, which caused the new offer to be ignored and the old peer connection to be kept (but frozen due to the HPB not sending more data for that connection). Requesting offers are not needed when the peer connection is a screen, as the HPB will automatically send the offers itself. Therefore, now offers are requested only when the connection is of "video" type. Signed-off-by: Daniel Calviño Sánchez --- .../nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java index a63e92695..7663096ce 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java @@ -109,11 +109,13 @@ public class MagicPeerConnectionWrapper { magicDataChannel.registerObserver(new MagicDataChannelObserver()); if (isMCUPublisher) { peerConnection.createOffer(magicSdpObserver, sdpConstraints); - } else if (hasMCU) { + } else if (hasMCU && this.videoStreamType.equals("video")) { + // If the connection type is "screen" the client sharing the screen will send an + // offer; offers should be requested only for videos. HashMap hashMap = new HashMap<>(); hashMap.put("sessionId", sessionId); EventBus.getDefault().post(new WebSocketCommunicationEvent("peerReadyForRequestingOffer", hashMap)); - } else if (hasInitiated) { + } else if (!hasMCU && hasInitiated) { peerConnection.createOffer(magicSdpObserver, sdpConstraints); }