mirror of
https://github.com/vector-im/element-call.git
synced 2026-02-02 04:05:56 +00:00
refactor: use EnterRTCSessionOptions instead of unnamed bools
This commit is contained in:
@@ -15,6 +15,7 @@ import { mockConfig } from "./utils/test";
|
||||
import { ElementWidgetActions, widget } from "./widget";
|
||||
import { ErrorCode } from "./utils/errors.ts";
|
||||
|
||||
const USE_MUTI_SFU = false;
|
||||
const getUrlParams = vi.hoisted(() => vi.fn(() => ({})));
|
||||
vi.mock("./UrlParams", () => ({ getUrlParams }));
|
||||
|
||||
@@ -93,7 +94,10 @@ test("It joins the correct Session", async () => {
|
||||
livekit_service_url: "http://my-well-known-service-url.com",
|
||||
type: "livekit",
|
||||
},
|
||||
true,
|
||||
{
|
||||
encryptMedia: true,
|
||||
useMultiSfu: USE_MUTI_SFU,
|
||||
}
|
||||
);
|
||||
|
||||
expect(mockedSession.joinRoomSession).toHaveBeenLastCalledWith(
|
||||
@@ -123,12 +127,12 @@ test("It joins the correct Session", async () => {
|
||||
focus_selection: "oldest_membership",
|
||||
type: "livekit",
|
||||
},
|
||||
{
|
||||
expect.objectContaining({
|
||||
manageMediaKeys: false,
|
||||
useLegacyMemberEvents: false,
|
||||
useNewMembershipManager: true,
|
||||
useExperimentalToDeviceTransport: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -197,7 +201,10 @@ test("It fails with configuration error if no live kit url config is set in fall
|
||||
livekit_service_url: "http://my-well-known-service-url.com",
|
||||
type: "livekit",
|
||||
},
|
||||
true,
|
||||
{
|
||||
encryptMedia: true,
|
||||
useMultiSfu: USE_MUTI_SFU,
|
||||
}
|
||||
),
|
||||
).rejects.toThrowError(
|
||||
expect.objectContaining({ code: ErrorCode.MISSING_MATRIX_RTC_TRANSPORT }),
|
||||
@@ -240,6 +247,9 @@ test("It should not fail with configuration error if homeserver config has livek
|
||||
livekit_service_url: "http://my-well-known-service-url.com",
|
||||
type: "livekit",
|
||||
},
|
||||
true,
|
||||
{
|
||||
encryptMedia: true,
|
||||
useMultiSfu: USE_MUTI_SFU,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -97,14 +97,40 @@ export async function makeTransport(
|
||||
return transport;
|
||||
}
|
||||
|
||||
export interface EnterRTCSessionOptions {
|
||||
encryptMedia: boolean;
|
||||
// TODO: remove this flag, the new membership manager is stable enough
|
||||
useNewMembershipManager?: boolean;
|
||||
// TODO: remove this flag, to-device transport is stable enough now
|
||||
useExperimentalToDeviceTransport?: boolean;
|
||||
/** EXPERIMENTAL: If true, will use the multi-sfu codepath where each member connects to its SFU instead of everyone connecting to an elected on. */
|
||||
useMultiSfu?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO! document this function properly
|
||||
* @param rtcSession
|
||||
* @param transport
|
||||
* @param options
|
||||
*/
|
||||
export async function enterRTCSession(
|
||||
rtcSession: MatrixRTCSession,
|
||||
transport: LivekitTransport,
|
||||
encryptMedia: boolean,
|
||||
useNewMembershipManager = true,
|
||||
useExperimentalToDeviceTransport = false,
|
||||
useMultiSfu = true,
|
||||
options: EnterRTCSessionOptions = {
|
||||
encryptMedia: true,
|
||||
useNewMembershipManager: true,
|
||||
useExperimentalToDeviceTransport: false,
|
||||
useMultiSfu: true,
|
||||
},
|
||||
): Promise<void> {
|
||||
|
||||
const {
|
||||
encryptMedia,
|
||||
useNewMembershipManager = true,
|
||||
useExperimentalToDeviceTransport = false,
|
||||
useMultiSfu = true,
|
||||
} = options;
|
||||
|
||||
PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date());
|
||||
PosthogAnalytics.instance.eventCallStarted.track(rtcSession.room.roomId);
|
||||
|
||||
|
||||
@@ -2016,10 +2016,12 @@ export class CallViewModel extends ViewModel {
|
||||
await enterRTCSession(
|
||||
this.matrixRTCSession,
|
||||
localTransport.value,
|
||||
this.options.encryptionSystem.kind !== E2eeType.NONE,
|
||||
true,
|
||||
true,
|
||||
multiSfu.value$.value,
|
||||
{
|
||||
encryptMedia: this.options.encryptionSystem.kind !== E2eeType.NONE,
|
||||
useExperimentalToDeviceTransport: true,
|
||||
useNewMembershipManager: true,
|
||||
useMultiSfu: multiSfu.value$.value
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error("Error entering RTC session", e);
|
||||
|
||||
Reference in New Issue
Block a user