From 4d03aa9053be821345ae78456ad9b144c9bd1d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Thu, 8 Aug 2024 22:49:13 +0200 Subject: [PATCH] Keep peerName on recreation of peerConnectionWrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCCallController.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/NextcloudTalk/NCCallController.m b/NextcloudTalk/NCCallController.m index 12a09cff6..b87340d61 100644 --- a/NextcloudTalk/NCCallController.m +++ b/NextcloudTalk/NCCallController.m @@ -1311,16 +1311,26 @@ - (void)processSignalingMessage:(NCSignalingMessage *)signalingMessage // If there is already a peer connection but a new offer is received with a different sid the existing // peer connection is stale, so it needs to be removed and a new one created instead. NCPeerConnection *peerConnectionWrapper = [self getPeerConnectionWrapperForSessionId:signalingMessage.from ofType:signalingMessage.roomType forOwnScreenshare:isAnswerToOwnScreenshare]; + NSString *peerName; if (signalingMessage.messageType == kNCSignalingMessageTypeOffer && peerConnectionWrapper && signalingMessage.sid.length > 0 && ![signalingMessage.sid isEqualToString:peerConnectionWrapper.sid]) { + + // Remember the peerName for the new connectionWrapper + peerName = peerConnectionWrapper.peerName; [self cleanPeerConnectionForSessionId:signalingMessage.from ofType:signalingMessage.roomType forOwnScreenshare:isAnswerToOwnScreenshare]; } peerConnectionWrapper = [self getOrCreatePeerConnectionWrapperForSessionId:signalingMessage.from withSid:signalingMessage.sid ofType:signalingMessage.roomType forOwnScreenshare:isAnswerToOwnScreenshare]; NCSessionDescriptionMessage *sdpMessage = (NCSessionDescriptionMessage *)signalingMessage; RTCSessionDescription *sessionDescription = sdpMessage.sessionDescription; - [peerConnectionWrapper setPeerName:sdpMessage.nick]; [peerConnectionWrapper setRemoteDescription:sessionDescription]; + + if (sdpMessage.nick && ![sdpMessage.nick isEqualToString:@""]) { + [peerConnectionWrapper setPeerName:sdpMessage.nick]; + } else if (peerName) { + [peerConnectionWrapper setPeerName:peerName]; + } + break; } case kNCSignalingMessageTypeCandidate: