diff --git a/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts b/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts index 4884dc44d..935a83a9d 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts @@ -20,10 +20,6 @@ import { type UnstableLivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { type ObservableScope } from "../../ObservableScope.ts"; import { Connection } from "./Connection.ts"; -import type { - ClientOpenIDParts, - SFUConfig, -} from "../../../livekit/openIDSFU.ts"; import type { MediaDevices } from "../../MediaDevices.ts"; import type { Behavior } from "../../Behavior.ts"; import type { ProcessorState } from "../../../livekit/TrackProcessorContext.tsx"; @@ -39,6 +35,11 @@ import { noiseSuppressionSetting, autoGainControlSetting, } from "../../../settings/settings.ts"; +import { + type ClientGetTokenParts, + type ClientOpenIDParts, + type SFUConfig, +} from "../../../livekit/auth"; // TODO evaluate if this should be done like the Publisher Factory export interface ConnectionFactory { @@ -66,7 +67,7 @@ export class ECConnectionFactory implements ConnectionFactory { * @param livekitRoomFactory - Optional factory function (for testing) to create LivekitRoom instances. If not provided, a default factory is used. */ public constructor( - private client: ClientOpenIDParts, + private client: ClientGetTokenParts & ClientOpenIDParts, private readonly roomId: string, private devices: MediaDevices, private processorState$: Behavior, diff --git a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts index 25f462e5f..959e792db 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts @@ -59,7 +59,12 @@ export class ConnectionManagerData { private getKey(transport: UnstableLivekitTransport): string { // This is enough as a key because the ConnectionManager is already scoped by room. // We also do not need to consider the slotId at this point since each `MatrixRTCSession` is already scoped by `slotDescription: {id, application}`. - return transport.livekit_service_url; + return JSON.stringify([ + "url" in transport ? transport.url : undefined, + "livekit_service_url" in transport + ? transport.livekit_service_url + : undefined, + ]); } public getConnections(): Connection[] { diff --git a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts index 12753b283..a85cd8b39 100644 --- a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts +++ b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts @@ -171,7 +171,22 @@ export function areUnstableLivekitTransportsEqual< T extends UnstableLivekitTransport, >(t1: T | null, t2: T | null): boolean { if (t1 && t2) { - return t1.livekit_service_url === t2.livekit_service_url; + if ("url" in t1 !== "url" in t2) return false; + if ("livekit_service_url" in t1 !== "livekit_service_url" in t2) + return false; + if ( + "url" in t1 && + t1.url !== (t2 as UnstableLivekitTransport & { url: string }).url + ) + return false; + if ( + "livekit_service_url" in t1 && + t1.livekit_service_url !== + (t2 as UnstableLivekitTransport & { livekit_service_url: string }) + .livekit_service_url + ) + return false; + return true; } return !t1 && !t2; }