You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
groupCall: make no media call param optional (#3186)
- ensure group call backwards-compatibility and move `allowCallWithoutVideoAndAudio`to the end of the `CroupCall` constructor
This commit is contained in:
@@ -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<GroupCall> => {
|
||||
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();
|
||||
|
||||
@@ -1897,10 +1897,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
type,
|
||||
isPtt,
|
||||
intent,
|
||||
this.isVoipWithNoMediaAllowed,
|
||||
undefined,
|
||||
dataChannelsEnabled || this.isVoipWithNoMediaAllowed,
|
||||
dataChannelOptions,
|
||||
this.isVoipWithNoMediaAllowed,
|
||||
).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ export class GroupCall extends TypedEventEmitter<
|
||||
public readonly userMediaFeeds: CallFeed[] = [];
|
||||
public readonly screenshareFeeds: CallFeed[] = [];
|
||||
public groupCallId: string;
|
||||
public readonly allowCallWithoutVideoAndAudio: boolean;
|
||||
|
||||
private readonly calls = new Map<string, Map<string, MatrixCall>>(); // user_id -> device_id -> MatrixCall
|
||||
private callHandlers = new Map<string, Map<string, ICallHandlers>>(); // 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<GroupCall> {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user