diff --git a/spec/unit/webrtc/groupCall.spec.ts b/spec/unit/webrtc/groupCall.spec.ts index 74563bda0ec..724778ce624 100644 --- a/spec/unit/webrtc/groupCall.spec.ts +++ b/spec/unit/webrtc/groupCall.spec.ts @@ -533,6 +533,7 @@ describe('Group Call', function() { let newCall: MatrixCall; while ( (newCall = groupCall1.getCallByUserId(client2.userId)) === undefined || + newCall.peerConn === undefined || newCall.callId == oldCall.callId ) { await flushPromises(); @@ -643,6 +644,7 @@ describe('Group Call', function() { groupCall.localCallFeed.setAudioVideoMuted = jest.fn(); const setAVMutedArray = groupCall.calls.map(call => { call.localUsermediaFeed.setAudioVideoMuted = jest.fn(); + call.localUsermediaFeed.isVideoMuted = jest.fn().mockReturnValue(true); return call.localUsermediaFeed.setAudioVideoMuted; }); const tracksArray = groupCall.calls.reduce((acc, call) => { diff --git a/src/webrtc/groupCall.ts b/src/webrtc/groupCall.ts index 104eacae0c4..b96ebed7c51 100644 --- a/src/webrtc/groupCall.ts +++ b/src/webrtc/groupCall.ts @@ -856,12 +856,22 @@ export class GroupCall extends TypedEventEmitter< }, ); + if (existingCall) { + logger.debug(`Replacing call ${existingCall.callId} to ${member.userId} with ${newCall.callId}`); + this.replaceCall(existingCall, newCall, CallErrorCode.NewSession); + } else { + logger.debug(`Adding call ${newCall.callId} to ${member.userId}`); + this.addCall(newCall); + } + newCall.isPtt = this.isPtt; const requestScreenshareFeed = opponentDevice.feeds.some( (feed) => feed.purpose === SDPStreamMetadataPurpose.Screenshare); - logger.log(`Placing call to ${member.userId}.`); + logger.debug( + `Placing call to ${member.userId}/${opponentDevice.device_id} session ID ${opponentDevice.session_id}.`, + ); try { await newCall.placeCallWithCallFeeds( @@ -881,18 +891,13 @@ export class GroupCall extends TypedEventEmitter< ), ); } + this.removeCall(newCall, CallErrorCode.SignallingFailed); return; } if (this.dataChannelsEnabled) { newCall.createDataChannel("datachannel", this.dataChannelOptions); } - - if (existingCall) { - this.replaceCall(existingCall, newCall, CallErrorCode.NewSession); - } else { - this.addCall(newCall); - } }; public getDeviceForMember(userId: string): IGroupCallRoomMemberDevice {