From 8cbbdaa239e449848e8874f041ef1879c1956696 Mon Sep 17 00:00:00 2001 From: Enrico Schwendig Date: Thu, 2 Mar 2023 19:55:09 +0100 Subject: [PATCH] groupCall: make no media call param optional (#3186) - ensure group call backwards-compatibility and move `allowCallWithoutVideoAndAudio`to the end of the `CroupCall` constructor --- spec/unit/webrtc/groupCall.spec.ts | 9 +++------ src/client.ts | 2 +- src/webrtc/groupCall.ts | 4 +++- src/webrtc/groupCallEventHandler.ts | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/spec/unit/webrtc/groupCall.spec.ts b/spec/unit/webrtc/groupCall.spec.ts index 02e3a18b4..9743b332e 100644 --- a/spec/unit/webrtc/groupCall.spec.ts +++ b/spec/unit/webrtc/groupCall.spec.ts @@ -109,7 +109,7 @@ const mockGetStateEvents = (type: EventType, userId?: string): MatrixEvent[] | M const ONE_HOUR = 1000 * 60 * 60; const createAndEnterGroupCall = async (cli: MatrixClient, room: Room): Promise => { - const groupCall = new GroupCall(cli, room, GroupCallType.Video, false, GroupCallIntent.Prompt, false, FAKE_CONF_ID); + const groupCall = new GroupCall(cli, room, GroupCallType.Video, false, GroupCallIntent.Prompt, FAKE_CONF_ID); await groupCall.create(); await groupCall.enter(); @@ -135,7 +135,7 @@ describe("Group Call", function () { mockClient = typedMockClient as unknown as MatrixClient; room = new Room(FAKE_ROOM_ID, mockClient, FAKE_USER_ID_1); - groupCall = new GroupCall(mockClient, room, GroupCallType.Video, false, GroupCallIntent.Prompt, false); + groupCall = new GroupCall(mockClient, room, GroupCallType.Video, false, GroupCallIntent.Prompt); room.currentState.members[FAKE_USER_ID_1] = { userId: FAKE_USER_ID_1, membership: "join", @@ -484,7 +484,7 @@ describe("Group Call", function () { describe("PTT calls", () => { beforeEach(async () => { // replace groupcall with a PTT one - groupCall = new GroupCall(mockClient, room, GroupCallType.Video, true, GroupCallIntent.Prompt, false); + groupCall = new GroupCall(mockClient, room, GroupCallType.Video, true, GroupCallIntent.Prompt); await groupCall.create(); @@ -647,7 +647,6 @@ describe("Group Call", function () { GroupCallType.Video, false, GroupCallIntent.Prompt, - false, FAKE_CONF_ID, ); @@ -657,7 +656,6 @@ describe("Group Call", function () { GroupCallType.Video, false, GroupCallIntent.Prompt, - false, FAKE_CONF_ID, ); }); @@ -1483,7 +1481,6 @@ describe("Group Call", function () { GroupCallType.Video, false, GroupCallIntent.Prompt, - false, FAKE_CONF_ID, ); await groupCall.create(); diff --git a/src/client.ts b/src/client.ts index 963c244b6..8f861892a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1897,10 +1897,10 @@ export class MatrixClient extends TypedEventEmitter>(); // user_id -> device_id -> MatrixCall private callHandlers = new Map>(); // user_id -> device_id -> ICallHandlers @@ -216,10 +217,10 @@ export class GroupCall extends TypedEventEmitter< public type: GroupCallType, public isPtt: boolean, public intent: GroupCallIntent, - public readonly allowCallWithoutVideoAndAudio: boolean, groupCallId?: string, private dataChannelsEnabled?: boolean, private dataChannelOptions?: IGroupCallDataChannelOptions, + isCallWithoutVideoAndAudio?: boolean, ) { super(); this.reEmitter = new ReEmitter(this); @@ -232,6 +233,7 @@ export class GroupCall extends TypedEventEmitter< this.on(GroupCallEvent.ParticipantsChanged, this.onParticipantsChanged); this.on(GroupCallEvent.GroupCallStateChanged, this.onStateChanged); this.on(GroupCallEvent.LocalScreenshareStateChanged, this.onLocalFeedsChanged); + this.allowCallWithoutVideoAndAudio = !!isCallWithoutVideoAndAudio; } public async create(): Promise { diff --git a/src/webrtc/groupCallEventHandler.ts b/src/webrtc/groupCallEventHandler.ts index 7392a75ad..7be977714 100644 --- a/src/webrtc/groupCallEventHandler.ts +++ b/src/webrtc/groupCallEventHandler.ts @@ -183,12 +183,12 @@ export class GroupCallEventHandler { callType, isPtt, callIntent, - this.client.isVoipWithNoMediaAllowed, groupCallId, // Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a // no media WebRTC connection anyway. content?.dataChannelsEnabled || this.client.isVoipWithNoMediaAllowed, dataChannelOptions, + this.client.isVoipWithNoMediaAllowed, ); this.groupCalls.set(room.roomId, groupCall);