From f9b601504b11e27ad178643f2fd7acc2fc1883a6 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 22 Sep 2026 22:44:15 +0200 Subject: [PATCH] Stop sending livekit_alias in memberships It's been many versions since anything used the value. --- docs/matrix_rtc_modes.md | 2 +- package.json | 2 +- pnpm-lock.yaml | 20 +++---- src/state/CallViewModel/CallViewModel.ts | 4 +- .../localMember/LocalMember.test.ts | 9 ++-- .../CallViewModel/localMember/LocalMember.ts | 52 ++++++------------- .../localMember/LocalTransport.ts | 31 ++--------- .../RtcTransportAutoDiscovery.test.ts | 6 +-- .../localMember/RtcTransportAutoDiscovery.ts | 12 ++--- .../remoteMembers/Connection.test.ts | 16 ++---- .../CallViewModel/remoteMembers/Connection.ts | 6 +-- .../remoteMembers/ConnectionFactory.ts | 6 +-- .../remoteMembers/ConnectionManager.test.ts | 14 ++--- .../remoteMembers/ConnectionManager.ts | 14 ++--- .../MatrixLivekitMembers.test.ts | 2 - .../remoteMembers/MatrixLivekitMembers.ts | 6 +-- .../remoteMembers/integration.test.ts | 8 +-- src/state/SessionBehaviors.ts | 16 +++--- src/utils/test.ts | 1 - 19 files changed, 88 insertions(+), 139 deletions(-) diff --git a/docs/matrix_rtc_modes.md b/docs/matrix_rtc_modes.md index a30248ba0..4f2e864c4 100644 --- a/docs/matrix_rtc_modes.md +++ b/docs/matrix_rtc_modes.md @@ -24,7 +24,7 @@ homeserver does not support sticky events. This is the default. MSC4354 and all clients on v0.17.0 or later. The local membership requests its token from the Matrix 2.0 JWT endpoint of the [MatrixRTC Authorization Service](https://github.com/element-hq/lk-jwt-service) -and identifies the room by a hashed identity instead of a `livekit_alias`. +and identifies the room by a hashed identity instead of the Matrix `room_id`. (Remote memberships always try the new endpoint first and fall back to the legacy one, so remote participants can be on either.) diff --git a/package.json b/package.json index c7642f57a..93d7715a6 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "livekit-client": "^2.18.1", "lodash-es": "^4.17.21", "loglevel": "^1.9.1", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#robin/remove-livekit-alias", "matrix-widget-api": "^1.18.0", "node-stdlib-browser": "^1.3.1", "normalize.css": "^8.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be07cd290..4b51b8b17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -191,8 +191,8 @@ importers: specifier: ^1.9.1 version: 1.9.2 matrix-js-sdk: - specifier: github:matrix-org/matrix-js-sdk#develop - version: https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24929be0e741be6a5d0a7226f1c682e245263b8a + specifier: github:matrix-org/matrix-js-sdk#robin/remove-livekit-alias + version: https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24eacbcef2efaa5f4a89857ed028047332d2a70c matrix-widget-api: specifier: ^1.18.0 version: 1.19.0 @@ -1194,8 +1194,8 @@ packages: '@types/dom-mediacapture-transform': ^0.1.9 livekit-client: ^1.12.0 || ^2.1.0 - '@matrix-org/matrix-sdk-crypto-wasm@18.5.0': - resolution: {integrity: sha512-E826Hy1rG26LanPjtSsOiVRcVoHfSgPgj2r2Xsb5RPScpaKi9XJADQ0u3dNjRCitZPX4oyLNl1FDd5AfDlmIwQ==} + '@matrix-org/matrix-sdk-crypto-wasm@18.9.0': + resolution: {integrity: sha512-NtLzNDTEfNASBjNCTGZHuk7N0jrQhS6Zx2CM857rCHZYYh/rpbKGQNrJ7azktm4S1P5Jy3WU3nwJTGohGw26qQ==} engines: {node: '>= 18'} '@mdx-js/react@3.1.1': @@ -4680,9 +4680,9 @@ packages: matrix-events-sdk@0.0.1: resolution: {integrity: sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA==} - matrix-js-sdk@https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24929be0e741be6a5d0a7226f1c682e245263b8a: - resolution: {gitHosted: true, integrity: sha512-0EGwbXzvG88sBOxq4ZlCRwT4VpQj2xkizfyy0A3bTSK0ysb6/gXJ/o1WPFoqCjRGMDgPq4gAsk92xGtHA7EhPg==, tarball: https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24929be0e741be6a5d0a7226f1c682e245263b8a} - version: 42.2.0 + matrix-js-sdk@https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24eacbcef2efaa5f4a89857ed028047332d2a70c: + resolution: {gitHosted: true, integrity: sha512-lQeZIDw2OXZeRy0WvjMkT6ZfKWIpsuzCzU9MsfU4h/gTe6jdYRGjf6BRhg9/BOJ0S12lsvcEYslxzcB+usBILA==, tarball: https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24eacbcef2efaa5f4a89857ed028047332d2a70c} + version: 42.3.0 engines: {node: '>=22.0.0'} matrix-widget-api@1.19.0: @@ -7101,7 +7101,7 @@ snapshots: '@types/dom-mediacapture-transform': 0.1.11 livekit-client: 2.22.3(@types/dom-mediacapture-record@1.0.22) - '@matrix-org/matrix-sdk-crypto-wasm@18.5.0': {} + '@matrix-org/matrix-sdk-crypto-wasm@18.9.0': {} '@mdx-js/react@3.1.1(@types/react@19.2.18)(react@19.2.8)': dependencies: @@ -10249,10 +10249,10 @@ snapshots: matrix-events-sdk@0.0.1: {} - matrix-js-sdk@https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24929be0e741be6a5d0a7226f1c682e245263b8a: + matrix-js-sdk@https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/24eacbcef2efaa5f4a89857ed028047332d2a70c: dependencies: '@babel/runtime': 8.0.0 - '@matrix-org/matrix-sdk-crypto-wasm': 18.5.0 + '@matrix-org/matrix-sdk-crypto-wasm': 18.9.0 another-json: 0.2.0 bs58: 6.0.0 content-type: 3.0.0 diff --git a/src/state/CallViewModel/CallViewModel.ts b/src/state/CallViewModel/CallViewModel.ts index 1ab4ea134..ea7f3cc78 100644 --- a/src/state/CallViewModel/CallViewModel.ts +++ b/src/state/CallViewModel/CallViewModel.ts @@ -43,7 +43,7 @@ import { import { type Logger, logger as rootLogger } from "matrix-js-sdk/lib/logger"; import { MembershipManagerEvent, - type LivekitTransportConfig, + type LivekitTransport, type MatrixRTCSession, type RTCCallIntent, type RTCNotificationType, @@ -624,7 +624,7 @@ export function createCallViewModel$( ), muteStates, joinMatrixRTC: ( - transport: LivekitTransportConfig, + transport: LivekitTransport, delayedLeaveTimings: ResolvedDelayedLeaveTimings, ) => { return enterRTCSession( diff --git a/src/state/CallViewModel/localMember/LocalMember.test.ts b/src/state/CallViewModel/localMember/LocalMember.test.ts index 973c3f6c0..d17cac33b 100644 --- a/src/state/CallViewModel/localMember/LocalMember.test.ts +++ b/src/state/CallViewModel/localMember/LocalMember.test.ts @@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details. import { Status as RTCMemberStatus, - type LivekitTransportConfig, + type LivekitTransport, type MatrixRTCSession, } from "matrix-js-sdk/lib/matrixrtc"; import { @@ -121,8 +121,7 @@ const mockedClient = { }; describe("enterRTCSession", () => { - const transport: LivekitTransportConfig = { - livekit_alias: "roomId", + const transport: LivekitTransport = { livekit_service_url: "http://my-livekit-service-url.com", type: "livekit", }; @@ -256,7 +255,7 @@ describe("LocalMembership", () => { it("throws error on missing RTC config error", () => { withTestScheduler(({ scope, hot, expectObservable }) => { - const localTransport$ = scope.behavior( + const localTransport$ = scope.behavior( hot("1ms #", {}, new MatrixRTCTransportMissingError("domain.com")), null, ); @@ -321,7 +320,7 @@ describe("LocalMembership", () => { const mockTransportConfig = { livekit_service_url: "a", - } as LivekitTransportConfig; + } as LivekitTransport; const mockTransport = { transport: mockTransportConfig, diff --git a/src/state/CallViewModel/localMember/LocalMember.ts b/src/state/CallViewModel/localMember/LocalMember.ts index 27a631d98..ad9abb786 100644 --- a/src/state/CallViewModel/localMember/LocalMember.ts +++ b/src/state/CallViewModel/localMember/LocalMember.ts @@ -19,7 +19,6 @@ import { type MatrixClient } from "matrix-js-sdk"; import { Status as RTCSessionStatus, type LivekitTransport, - type LivekitTransportConfig, type MatrixRTCSession, type RTCCallIntent, type RTCNotificationType, @@ -144,7 +143,7 @@ interface Props { connectionManager: IConnectionManager; createPublisherFactory: (connection: Connection) => Publisher; joinMatrixRTC: ( - transport: LivekitTransportConfig, + transport: LivekitTransport, delayedLeaveTimings: ResolvedDelayedLeaveTimings, ) => void; homeserverConnected: HomeserverConnected; @@ -966,7 +965,7 @@ interface EnterRTCSessionOptions { export function enterRTCSession( rtcSession: MatrixRTCSession, ownMembershipIdentity: CallMembershipIdentityParts, - transport: LivekitTransportConfig, + transport: LivekitTransport, { encryptMedia, matrixRTCMode, @@ -988,18 +987,6 @@ export function enterRTCSession( } = Config.get(); const retryInterval = sessionConfig.network_error_retry_ms; - // For backwards compatibility with Element Call versions that do not do Matrix 2.0, - // we add the livekit alias to the transport. - let backwardCompatibleTransport: LivekitTransport | LivekitTransportConfig; - if (matrixRTCMode === MatrixRTCMode.Matrix_2_0) { - backwardCompatibleTransport = transport; - } else { - backwardCompatibleTransport = { - livekit_alias: rtcSession.room.roomId, - ...transport, - }; - } - // Set maximumNetworkErrorRetryCount such that we will consider the client // disconnected as soon as either it fails to sync for longer than the grace // period, or it is likely that a delayed leave event has been sent. @@ -1011,24 +998,19 @@ export function enterRTCSession( // Multi-sfu does not need a preferred foci list. just the focus that is actually used. // TODO where/how do we track errors originating from the ongoing rtcSession? - rtcSession.joinRTCSession( - ownMembershipIdentity, - [], - backwardCompatibleTransport, - { - notificationType, - callIntent, - manageMediaKeys: encryptMedia, - delayedLeaveEventRestartMs: delayedLeaveTimings.restart_ms, - delayedLeaveEventDelayMs: delayedLeaveTimings.delay_ms, - delayedLeaveEventRestartLocalTimeoutMs: - delayedLeaveTimings.restart_timeout_ms, - networkErrorRetryMs: sessionConfig.network_error_retry_ms, - makeKeyDelay: sessionConfig.wait_for_key_rotation_ms, - membershipEventExpiryMs: sessionConfig.membership_event_expiry_ms, - keyRotationParticipantLimit: sessionConfig.key_rotation_participant_limit, - unstableSendStickyEvents: matrixRTCMode === MatrixRTCMode.Matrix_2_0, - maximumNetworkErrorRetryCount: maximumNetworkErrorRetryCount, - }, - ); + rtcSession.joinRTCSession(ownMembershipIdentity, [], transport, { + notificationType, + callIntent, + manageMediaKeys: encryptMedia, + delayedLeaveEventRestartMs: delayedLeaveTimings.restart_ms, + delayedLeaveEventDelayMs: delayedLeaveTimings.delay_ms, + delayedLeaveEventRestartLocalTimeoutMs: + delayedLeaveTimings.restart_timeout_ms, + networkErrorRetryMs: sessionConfig.network_error_retry_ms, + makeKeyDelay: sessionConfig.wait_for_key_rotation_ms, + membershipEventExpiryMs: sessionConfig.membership_event_expiry_ms, + keyRotationParticipantLimit: sessionConfig.key_rotation_participant_limit, + unstableSendStickyEvents: matrixRTCMode === MatrixRTCMode.Matrix_2_0, + maximumNetworkErrorRetryCount: maximumNetworkErrorRetryCount, + }); } diff --git a/src/state/CallViewModel/localMember/LocalTransport.ts b/src/state/CallViewModel/localMember/LocalTransport.ts index 0aa150d5d..3534b3fec 100644 --- a/src/state/CallViewModel/localMember/LocalTransport.ts +++ b/src/state/CallViewModel/localMember/LocalTransport.ts @@ -5,7 +5,7 @@ SPDX-License-IdFentifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixClient } from "matrix-js-sdk"; import { logger as rootLogger, type Logger } from "matrix-js-sdk/lib/logger"; import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager"; @@ -34,34 +34,13 @@ interface Props { matrixRTCMode: MatrixRTCMode; } -// TODO livekit_alias-cleanup -// 1. We need to move away from transports map to connections!!! -// -// 2. We need to stop sending livekit_alias all together -// -// -// 1. -// Transports are just the jwt service adress but do not contain the information which room on this transport to use. -// That requires slot and roomId. -// -// We need one connection per room on the transport. -// -// We need an object that contains: -// transport -// roomId -// slotId -// -// To map to the connections. Prosposal: `ConnectionIdentifier` -// -// 2. -// We need to make sure we do not sent livekit_alias in sticky events and that we drop all code for sending state events! export interface LocalTransport { - transport: LivekitTransportConfig; + transport: LivekitTransport; sfuConfig: SFUConfig; } export function isLocalTransport( - obj: LivekitTransportConfig | LocalTransport, + obj: LivekitTransport | LocalTransport, ): obj is LocalTransport { return "transport" in obj && "sfuConfig" in obj; } @@ -90,7 +69,7 @@ export async function getLocalTransport({ const customUrl = customLivekitUrl.value$.value; // Respect the user's custom URL, if set - const transport: LivekitTransportConfig | null = customUrl + const transport: LivekitTransport | null = customUrl ? { type: "livekit", livekit_service_url: customUrl } : await discovery.discoverPreferredTransport(); @@ -131,7 +110,7 @@ export async function getLocalTransport({ * @throws FailToGetOpenIdToken, NoMatrix2AuthorizationService */ async function doOpenIdAndJWTFromUrl( - transport: LivekitTransportConfig, + transport: LivekitTransport, matrixRTCMode: MatrixRTCMode, membership: CallMembershipIdentityParts, roomId: string, diff --git a/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.test.ts b/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.test.ts index f81223deb..61df88a73 100644 --- a/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.test.ts +++ b/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.test.ts @@ -16,7 +16,7 @@ import { import { MatrixError } from "matrix-js-sdk"; import { logger as rootLogger } from "matrix-js-sdk/lib/logger"; import { - type LivekitTransportConfig, + type LivekitTransport, type Transport, } from "matrix-js-sdk/lib/matrixrtc"; @@ -28,12 +28,12 @@ import { type DiscoveryClient = RtcTransportAutoDiscoveryProps["client"]; -const backendTransport: LivekitTransportConfig = { +const backendTransport: LivekitTransport = { type: "livekit", livekit_service_url: "https://backend.example.org", }; -const configTransport: LivekitTransportConfig = { +const configTransport: LivekitTransport = { type: "livekit", livekit_service_url: "https://config.example.org", }; diff --git a/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.ts b/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.ts index 1f295649f..aeb6b051a 100644 --- a/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.ts +++ b/src/state/CallViewModel/localMember/RtcTransportAutoDiscovery.ts @@ -5,8 +5,8 @@ SPDX-License-IdFentifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { - isLivekitTransportConfig, - type LivekitTransportConfig, + isLivekitTransport, + type LivekitTransport, } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixClient } from "matrix-js-sdk"; import { type Logger } from "matrix-js-sdk/lib/logger"; @@ -40,7 +40,7 @@ export class RtcTransportAutoDiscovery { this.logger = logger.getChild("[RtcTransportAutoDiscovery]"); } - public async discoverPreferredTransport(): Promise { + public async discoverPreferredTransport(): Promise { // 1) backend transports const backendTransport = await this.tryBackendTransports(); if (backendTransport) { @@ -67,7 +67,7 @@ export class RtcTransportAutoDiscovery { * This will not throw errors, but instead just log them and return null if the expected config is not found or malformed. * @private */ - private async tryBackendTransports(): Promise { + private async tryBackendTransports(): Promise { const client = this.client; // MSC4143: Attempt to fetch transports from backend. this.logger.info("First try to use getRTCTransports end point ..."); @@ -75,7 +75,7 @@ export class RtcTransportAutoDiscovery { const transportList = await doNetworkOperationWithRetry(async () => client._unstable_getRTCTransports(), ); - const first = transportList.find(isLivekitTransportConfig); + const first = transportList.find(isLivekitTransport); if (first) { return first; } else { @@ -90,7 +90,7 @@ export class RtcTransportAutoDiscovery { return null; } - private tryConfigTransport(): LivekitTransportConfig | null { + private tryConfigTransport(): LivekitTransport | null { const url = this.resolvedConfig.livekit?.livekit_service_url; if (url) { return { diff --git a/src/state/CallViewModel/remoteMembers/Connection.test.ts b/src/state/CallViewModel/remoteMembers/Connection.test.ts index f226b7789..62dc17a31 100644 --- a/src/state/CallViewModel/remoteMembers/Connection.test.ts +++ b/src/state/CallViewModel/remoteMembers/Connection.test.ts @@ -30,7 +30,7 @@ import fetchMock from "fetch-mock"; import EventEmitter from "events"; import { type IOpenIDToken } from "matrix-js-sdk"; import { logger, type Logger } from "matrix-js-sdk/lib/logger"; -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { Connection, @@ -57,7 +57,7 @@ let fakeLocalParticipant: MockedObject; const ROOM_ID = "!roomID:example.org"; -const livekitFocus: LivekitTransportConfig = { +const livekitFocus: LivekitTransport = { livekit_service_url: "https://matrix-rtc.example.org/livekit/jwt", type: "livekit", }; @@ -228,9 +228,7 @@ describe("Start connection states", () => { capturedState = capturedStates.pop(); if (capturedState instanceof Error) { expect(capturedState.message).toEqual("Something went wrong"); - expect(connection.transport.livekit_alias).toEqual( - livekitFocus.livekit_alias, - ); + expect(connection.transport).toEqual(livekitFocus); } else { expect.fail("Expected FailedToStart state but got " + capturedState); } @@ -290,9 +288,7 @@ describe("Start connection states", () => { expect(capturedState.cause.message).toContain( "Failed to look up user info from homeserver", ); - expect(connection.transport.livekit_alias).toEqual( - livekitFocus.livekit_alias, - ); + expect(connection.transport).toEqual(livekitFocus); } else { expect.fail("Expected FailedToStart state but got " + capturedState); } @@ -357,9 +353,7 @@ describe("Start connection states", () => { expect(capturedState.cause.message).toContain( "Failed to connect to livekit", ); - expect(connection.transport.livekit_alias).toEqual( - livekitFocus.livekit_alias, - ); + expect(connection.transport).toEqual(livekitFocus); } else { expect.fail( "Expected FailedToStart state but got " + JSON.stringify(capturedState), diff --git a/src/state/CallViewModel/remoteMembers/Connection.ts b/src/state/CallViewModel/remoteMembers/Connection.ts index 7889f9004..cc84142d9 100644 --- a/src/state/CallViewModel/remoteMembers/Connection.ts +++ b/src/state/CallViewModel/remoteMembers/Connection.ts @@ -22,7 +22,7 @@ import { type Track, type TrackPublication, } from "livekit-client"; -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { BehaviorSubject, map } from "rxjs"; import { type Logger } from "matrix-js-sdk/lib/logger"; import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager"; @@ -52,7 +52,7 @@ export interface ConnectionOpts { /** The identity parts to use on this connection */ ownMembershipIdentity: CallMembershipIdentityParts; /** The media transport to connect to. */ - transport: LivekitTransportConfig; + transport: LivekitTransport; /** The Matrix client to use for OpenID and SFU config requests. */ client: OpenIDClientParts; /** The room ID this connection is associated with. */ @@ -107,7 +107,7 @@ export class Connection { /** * The media transport to connect to. */ - public readonly transport: LivekitTransportConfig; + public readonly transport: LivekitTransport; public readonly livekitRoom: LivekitRoom; diff --git a/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts b/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts index 30ff37f3e..96a28d5ad 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionFactory.ts @@ -16,7 +16,7 @@ import { logger, type Logger } from "matrix-js-sdk/lib/logger"; // imported as inline to support worker when loaded from a cdn (cross domain) import E2EEWorker from "livekit-client/e2ee-worker?worker&inline"; import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager"; -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { type ObservableScope } from "../../ObservableScope.ts"; import { Connection } from "./Connection.ts"; @@ -44,7 +44,7 @@ import { export interface ConnectionFactory { createConnection( scope: ObservableScope, - transport: LivekitTransportConfig, + transport: LivekitTransport, ownMembershipIdentity: CallMembershipIdentityParts, logger: Logger, sfuConfig?: SFUConfig, @@ -103,7 +103,7 @@ export class ECConnectionFactory implements ConnectionFactory { */ public createConnection( scope: ObservableScope, - transport: LivekitTransportConfig, + transport: LivekitTransport, ownMembershipIdentity: CallMembershipIdentityParts, logger: Logger, sfuConfig?: SFUConfig, diff --git a/src/state/CallViewModel/remoteMembers/ConnectionManager.test.ts b/src/state/CallViewModel/remoteMembers/ConnectionManager.test.ts index 0903702ff..e7d91c633 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionManager.test.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionManager.test.ts @@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details. import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; import { BehaviorSubject, NEVER } from "rxjs"; -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { type RemoteParticipant } from "livekit-client"; import { logger } from "matrix-js-sdk/lib/logger"; @@ -24,12 +24,12 @@ import { type Behavior } from "../../Behavior.ts"; // Some test constants -const TRANSPORT_1: LivekitTransportConfig = { +const TRANSPORT_1: LivekitTransport = { type: "livekit", livekit_service_url: "https://lk.example.org", }; -const TRANSPORT_2: LivekitTransportConfig = { +const TRANSPORT_2: LivekitTransport = { type: "livekit", livekit_service_url: "https://lk.sample.com", }; @@ -47,7 +47,7 @@ beforeEach(() => { vi.mocked(fakeConnectionFactory).createConnection = vi .fn() .mockImplementation( - (scope: ObservableScope, transport: LivekitTransportConfig) => { + (scope: ObservableScope, transport: LivekitTransport) => { const mockConnection = { transport, remoteParticipants$: new BehaviorSubject([]), @@ -225,7 +225,7 @@ describe("connectionManagerData$ stream", () => { // Used in test to control fake connections' remoteParticipants$ streams let fakeRemoteParticipantsStreams: Map>; - function keyForTransport(transport: LivekitTransportConfig): string { + function keyForTransport(transport: LivekitTransport): string { return `${transport.livekit_service_url}`; } @@ -233,7 +233,7 @@ describe("connectionManagerData$ stream", () => { fakeRemoteParticipantsStreams = new Map(); function getRemoteParticipantsFor( - transport: LivekitTransportConfig, + transport: LivekitTransport, ): Behavior { return ( fakeRemoteParticipantsStreams.get(keyForTransport(transport)) ?? @@ -245,7 +245,7 @@ describe("connectionManagerData$ stream", () => { vi.mocked(fakeConnectionFactory).createConnection = vi .fn() .mockImplementation( - (scope: ObservableScope, transport: LivekitTransportConfig) => { + (scope: ObservableScope, transport: LivekitTransport) => { const fakeRemoteParticipants$ = new BehaviorSubject< RemoteParticipant[] >([]); diff --git a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts index ea51c7ba0..18f54f021 100644 --- a/src/state/CallViewModel/remoteMembers/ConnectionManager.ts +++ b/src/state/CallViewModel/remoteMembers/ConnectionManager.ts @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { combineLatest, map, @@ -56,7 +56,7 @@ export class ConnectionManagerData { } } - private getKey(transport: LivekitTransportConfig): string { + private getKey(transport: LivekitTransport): 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; @@ -67,13 +67,13 @@ export class ConnectionManagerData { } public getConnectionForTransport( - transport: LivekitTransportConfig, + transport: LivekitTransport, ): Connection | null { return this.store.get(this.getKey(transport))?.connection ?? null; } public getParticipantsForTransport( - transport: LivekitTransportConfig, + transport: LivekitTransport, ): RemoteParticipant[] { const key = this.getKey(transport); const existing = this.store.get(key); @@ -88,7 +88,7 @@ interface Props { scope: ObservableScope; connectionFactory: ConnectionFactory; localTransport$: Observable; - remoteTransports$: Behavior>; + remoteTransports$: Behavior>; logger: Logger; ownMembershipIdentity: CallMembershipIdentityParts; @@ -147,7 +147,7 @@ export function createConnectionManager$({ * externally this is modified via `registerTransports()`. */ const localAndRemoteTransports$: Behavior< - Epoch<(LivekitTransportConfig | LocalTransport)[]> + Epoch<(LivekitTransport | LocalTransport)[]> > = scope.behavior( combineLatest([localTransportAsArray$, remoteTransports$]).pipe( // Combine local and remote transports into one transport array @@ -271,7 +271,7 @@ export function createConnectionManager$({ return { connectionManagerData$ }; } -function removeDuplicateTransports( +function removeDuplicateTransports( transports: T[], ): T[] { return transports.reduce((acc, transport) => { diff --git a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.test.ts b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.test.ts index fe7621121..c11d779e8 100644 --- a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.test.ts +++ b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.test.ts @@ -42,13 +42,11 @@ const fallbackMemberId = (userId: string, deviceId: string): string => const transportA: LivekitTransport = { type: "livekit", livekit_service_url: "https://lk.example.org", - livekit_alias: "!alias:example.org", }; const transportB: LivekitTransport = { type: "livekit", livekit_service_url: "https://lk.sample.com", - livekit_alias: "!alias:sample.com", }; const bobMembership = mockRtcMembership("@bob:example.org", "DEV000", { diff --git a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts index 76f4670ec..6c9fff026 100644 --- a/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts +++ b/src/state/CallViewModel/remoteMembers/MatrixLivekitMembers.ts @@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details. import { type LocalParticipant, type RemoteParticipant } from "livekit-client"; import { type CallMembership, - type LivekitTransportConfig, + type LivekitTransport, } from "matrix-js-sdk/lib/matrixrtc"; import { combineLatest, filter, map } from "rxjs"; import { logger } from "matrix-js-sdk/lib/logger"; @@ -60,7 +60,7 @@ export interface RemoteMatrixLivekitMember extends MatrixLivekitMember { interface Props { scope: ObservableScope; membershipsWithTransport$: Behavior< - Epoch<{ membership: CallMembership; transport?: LivekitTransportConfig }[]> + Epoch<{ membership: CallMembership; transport?: LivekitTransport }[]> >; connectionManager: IConnectionManager; localUser: { deviceId: string; userId: string }; @@ -165,7 +165,7 @@ export function createRemoteMatrixLivekitMembers$({ // TODO add back in the callviewmodel pauseWhen(this.pretendToBeDisconnected$) // TODO add this to the JS-SDK -export function areLivekitTransportsEqual( +export function areLivekitTransportsEqual( t1: T | null, t2: T | null, ): boolean { diff --git a/src/state/CallViewModel/remoteMembers/integration.test.ts b/src/state/CallViewModel/remoteMembers/integration.test.ts index 0db25c3b5..4c0f4fea7 100644 --- a/src/state/CallViewModel/remoteMembers/integration.test.ts +++ b/src/state/CallViewModel/remoteMembers/integration.test.ts @@ -10,7 +10,7 @@ import { BehaviorSubject, NEVER } from "rxjs"; import { type Room as LivekitRoom } from "livekit-client"; import EventEmitter from "events"; import fetchMock from "fetch-mock"; -import { type LivekitTransportConfig } from "matrix-js-sdk/lib/matrixrtc"; +import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc"; import { logger } from "matrix-js-sdk/lib/logger"; import { @@ -149,7 +149,7 @@ test("bob, carl, then bob joining no tracks yet", () => { a: expect.toSatisfy((co) => areLivekitTransportsEqual( co.transport, - bobMembership.transports[0]! as LivekitTransportConfig, + bobMembership.transports[0]! as LivekitTransport, ), ), }); @@ -186,7 +186,7 @@ test("bob, carl, then bob joining no tracks yet", () => { expect( areLivekitTransportsEqual( connection.transport, - carlMembership.transports[0]! as LivekitTransportConfig, + carlMembership.transports[0]! as LivekitTransport, ), ).toBe(true); return true; @@ -216,7 +216,7 @@ test("bob, carl, then bob joining no tracks yet", () => { expect( areLivekitTransportsEqual( connection.transport, - daveMembership.transports[0]! as LivekitTransportConfig, + daveMembership.transports[0]! as LivekitTransport, ), ).toBe(true); return true; diff --git a/src/state/SessionBehaviors.ts b/src/state/SessionBehaviors.ts index 8d3986b68..8a73ca711 100644 --- a/src/state/SessionBehaviors.ts +++ b/src/state/SessionBehaviors.ts @@ -7,10 +7,10 @@ Please see LICENSE in the repository root for full details. import { type CallMembership, - type LivekitTransportConfig, + type LivekitTransport, type MatrixRTCSession, MatrixRTCSessionEvent, - isLivekitTransportConfig, + isLivekitTransport, } from "matrix-js-sdk/lib/matrixrtc"; import { fromEvent } from "rxjs"; @@ -31,15 +31,15 @@ export const membershipsAndTransports$ = ( memberships$: Behavior>, ): { membershipsWithTransport$: Behavior< - Epoch<{ membership: CallMembership; transport?: LivekitTransportConfig }[]> + Epoch<{ membership: CallMembership; transport?: LivekitTransport }[]> >; - transports$: Behavior>; + transports$: Behavior>; } => { const membershipsWithTransport$: Behavior< Epoch< { membership: CallMembership; - transport: LivekitTransportConfig | undefined; + transport: LivekitTransport | undefined; }[] > > = scope.behavior( @@ -50,16 +50,14 @@ export const membershipsAndTransports$ = ( const transport = membership.getTransport(oldestMembership); return { membership, - transport: isLivekitTransportConfig(transport) - ? transport - : undefined, + transport: isLivekitTransport(transport) ? transport : undefined, }; }); }), ), ); - const transports$: Behavior> = scope.behavior( + const transports$: Behavior> = scope.behavior( membershipsWithTransport$.pipe( mapEpoch((mts) => mts.flatMap(({ transport: t }) => (t ? [t] : []))), ), diff --git a/src/utils/test.ts b/src/utils/test.ts index 405e5947b..1c49c0da4 100644 --- a/src/utils/test.ts +++ b/src/utils/test.ts @@ -212,7 +212,6 @@ export function mockEmitter(): EmitterMock { export const exampleTransport: LivekitTransport = { type: "livekit", livekit_service_url: "https://lk.example.org", - livekit_alias: "!alias:example.org", }; export const exampleSfuConfig: SFUConfig = {