From ade92c03444d0079dd072a07ea0bff45fb3eeb24 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 17 Oct 2018 23:27:12 +0200 Subject: [PATCH] New updates --- .../talk/controllers/CallController.java | 25 ++++++++----------- .../json/signaling/NCMessagePayload.java | 3 +++ .../json/signaling/NCSignalingMessage.java | 3 ++- .../webrtc/MagicPeerConnectionWrapper.java | 9 ++----- .../talk/webrtc/MagicWebSocketInstance.java | 8 +++--- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index 316fdcd2e..bc4f14128 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -1219,9 +1219,6 @@ public class CallController extends BaseController { case "signalingMessage": processMessage((NCSignalingMessage) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId")))); break; - case "peerConnectionReady": - webSocketClient.requestOfferForSessionIdWithType(webSocketCommunicationEvent.getHashMap().get("sessionId"), "video"); - break; } } @@ -1267,12 +1264,10 @@ public class CallController extends BaseController { private void processMessage(NCSignalingMessage ncSignalingMessage) { if (ncSignalingMessage.getRoomType().equals("video")) { - MagicPeerConnectionWrapper magicPeerConnectionWrapper = alwaysGetPeerConnectionWrapperForSessionId - (ncSignalingMessage.getFrom(), false); + MagicPeerConnectionWrapper magicPeerConnectionWrapper = alwaysGetPeerConnectionWrapperForSessionId(ncSignalingMessage.getFrom(), false); String type = null; - if (ncSignalingMessage.getPayload() != null && ncSignalingMessage.getPayload().getType() != - null) { + if (ncSignalingMessage.getPayload() != null && ncSignalingMessage.getPayload().getType() != null) { type = ncSignalingMessage.getPayload().getType(); } else if (ncSignalingMessage.getType() != null) { type = ncSignalingMessage.getType(); @@ -1490,7 +1485,11 @@ public class CallController extends BaseController { } for (String sessionId : newSessions) { - alwaysGetPeerConnectionWrapperForSessionId(sessionId, false); + if (!hasMCU) { + alwaysGetPeerConnectionWrapperForSessionId(sessionId, false); + } else { + webSocketClient.requestOfferForSessionIdWithType(sessionId, "video"); + } } for (String sessionId : oldSesssions) { @@ -1542,19 +1541,15 @@ public class CallController extends BaseController { } else { hasMCU = webSocketClient != null && webSocketClient.hasMCU(); - if (sessionId == null) { - Log.d("MARIO", "ISNULL"); - } - if (hasMCU && publisher) { magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory, - iceServers, sdpConstraintsForMCU, sessionId, callSession, localMediaStream, true, true); + iceServers, sdpConstraintsForMCU, sessionId, callSession, localMediaStream, true); } else if (hasMCU) { magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory, - iceServers, sdpConstraints, sessionId, callSession, null, false, true); + iceServers, sdpConstraints, sessionId, callSession, null, false); } else { magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory, - iceServers, sdpConstraints, sessionId, callSession, localMediaStream, false, false); + iceServers, sdpConstraints, sessionId, callSession, localMediaStream, false); } magicPeerConnectionWrapperList.add(magicPeerConnectionWrapper); diff --git a/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCMessagePayload.java b/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCMessagePayload.java index f2c5c70bd..b940d261e 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCMessagePayload.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCMessagePayload.java @@ -42,4 +42,7 @@ public class NCMessagePayload { @JsonField(name = "candidate") NCIceCandidate iceCandidate; + + @JsonField(name = "name") + String name; } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCSignalingMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCSignalingMessage.java index 5ce06379f..2aed2a6d1 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCSignalingMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/signaling/NCSignalingMessage.java @@ -43,5 +43,6 @@ public class NCSignalingMessage { String roomType; @JsonField(name = "sid") String sid; - + @JsonField(name = "prefix") + String prefix; } 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 d187a63d5..4a8f2f1d0 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java @@ -77,7 +77,7 @@ public class MagicPeerConnectionWrapper { List iceServerList, MediaConstraints mediaConstraints, String sessionId, String localSession, @Nullable MediaStream mediaStream, - boolean isMCUPublisher, boolean hasMCU) { + boolean isMCUPublisher) { this.localMediaStream = mediaStream; @@ -95,18 +95,13 @@ public class MagicPeerConnectionWrapper { peerConnection.addStream(localMediaStream); } - if (hasMCU || hasInitiated) { + if (isMCUPublisher || hasInitiated) { DataChannel.Init init = new DataChannel.Init(); init.negotiated = false; magicDataChannel = peerConnection.createDataChannel("status", init); magicDataChannel.registerObserver(new MagicDataChannelObserver()); if (isMCUPublisher) { peerConnection.createOffer(magicSdpObserver, mediaConstraints); - } else if (hasMCU) { - HashMap peerConnectionReadyMap = new HashMap<>(); - peerConnectionReadyMap.put("sessionId", sessionId); - EventBus.getDefault().post(new WebSocketCommunicationEvent("peerConnectionReady", peerConnectionReadyMap)); - } } } diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java index cfe64b456..6a3e9d6a0 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java @@ -164,9 +164,11 @@ public class MagicWebSocketInstance extends WebSocketListener { break; case "message": CallOverallWebSocketMessage callOverallWebSocketMessage = LoganSquare.parse(text, CallOverallWebSocketMessage.class); - HashMap messageHashMap = new HashMap<>(); - messageHashMap.put("jobId", Integer.toString(magicMap.add(callOverallWebSocketMessage.getCallWebSocketMessage().getNcSignalingMessage()))); - eventBus.post(new WebSocketCommunicationEvent("signalingMessage", messageHashMap)); + if (callOverallWebSocketMessage.getCallWebSocketMessage().getNcSignalingMessage().getPrefix() == null) { + HashMap messageHashMap = new HashMap<>(); + messageHashMap.put("jobId", Integer.toString(magicMap.add(callOverallWebSocketMessage.getCallWebSocketMessage().getNcSignalingMessage()))); + eventBus.post(new WebSocketCommunicationEvent("signalingMessage", messageHashMap)); + } break; default: break;