浏览代码

Fix frozen video when screen is shared

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 <danxuliu@gmail.com>
Daniel Calviño Sánchez 4 年之前
父节点
当前提交
1321cb21a0
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java

+ 4 - 2
app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java

@@ -109,11 +109,13 @@ public class MagicPeerConnectionWrapper {
                 magicDataChannel.registerObserver(new MagicDataChannelObserver());
                 magicDataChannel.registerObserver(new MagicDataChannelObserver());
                 if (isMCUPublisher) {
                 if (isMCUPublisher) {
                     peerConnection.createOffer(magicSdpObserver, sdpConstraints);
                     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<String, String> hashMap = new HashMap<>();
                     HashMap<String, String> hashMap = new HashMap<>();
                     hashMap.put("sessionId", sessionId);
                     hashMap.put("sessionId", sessionId);
                     EventBus.getDefault().post(new WebSocketCommunicationEvent("peerReadyForRequestingOffer", hashMap));
                     EventBus.getDefault().post(new WebSocketCommunicationEvent("peerReadyForRequestingOffer", hashMap));
-                } else if (hasInitiated) {
+                } else if (!hasMCU && hasInitiated) {
                     peerConnection.createOffer(magicSdpObserver, sdpConstraints);
                     peerConnection.createOffer(magicSdpObserver, sdpConstraints);
 
 
                 }
                 }