From ca4f0cdeae5c5e479cd9cb106fa27d81c0344a92 Mon Sep 17 00:00:00 2001 From: "Timo K." Date: Mon, 5 Oct 2026 15:06:06 +0200 Subject: [PATCH] fixup docs --- sdk/SdkArchitecture.md | 12 ++++++------ sdk/src/media-backend/api.ts | 9 +++++++-- sdk/src/media-backend/livekit/Publisher.ts | 12 +++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/sdk/SdkArchitecture.md b/sdk/SdkArchitecture.md index bc745de93..ad7fb3e8f 100644 --- a/sdk/SdkArchitecture.md +++ b/sdk/SdkArchitecture.md @@ -33,18 +33,18 @@ therefore `Element Call → sdk`, never the reverse. The migration from today's │ per track MediaTrack { source kind muted$ encrypted$ stats$ attach() }│ │ │ │ ┌───────────────────────────┐ MediaBackend ┌───────────────────────────┐ │ -│ │ session: MatrixRTC │ backend/api.ts │ media backend │ │ -│ │ │ │ backend/livekit/ today, │ │ -│ │ js-sdk MatrixRTCSession, │ │ or options.backend │ │ +│ │ session: MatrixRTC │ media-backend/ │ media backend │ │ +│ │ │ api.ts │ media-backend/livekit/ │ │ +│ │ js-sdk MatrixRTCSession, │ │ today, or options.backend │ │ │ │ later the rust-rtc │ prepareLocal │ │ │ │ │ crate behind a bridge │ Transport ───▶│ token service: │ │ │ │ memberships from room │ delegateDelayed │ OpenID → JWT, │ │ │ │ state and sticky events │ Leave ───────▶│ delegation probe │ │ │ │ own membership, delayed │ │ ConnectionManager: │ │ │ │ leave, retries │ mediaKeys$ ────▶│ one LiveKit room per │ │ -│ │ discovery of the local │ │ transport url, local │ │ -│ │ transport (homeserver) │ mediaFor$ ─────▶│ published, remote │ │ -│ │ join state machine │ ◀────── media$ │ subscribed │ │ +│ │ discovery of the local │ mediaFor$ ─────▶│ transport url, local │ │ +│ │ transport (homeserver) │ ◀─ tracks$, │ published, remote │ │ +│ │ join state machine │ encryptionError$│ subscribed │ │ │ │ (LocalMember) │ local.publish, │ Publisher: local tracks, │ │ │ │ transport registry │ setPublishing▶│ upstream paused until │ │ │ │ (TransportMetadata) │ ◀─ connections$ │ joined │ │ diff --git a/sdk/src/media-backend/api.ts b/sdk/src/media-backend/api.ts index 9d7f854e6..336db8f09 100644 --- a/sdk/src/media-backend/api.ts +++ b/sdk/src/media-backend/api.ts @@ -9,7 +9,7 @@ Please see LICENSE in the repository root for full details. * The seam between the session and whatever carries its media. The session * speaks MatrixRTC: memberships, transports as they appear in them, the * delayed leave. A backend speaks one media protocol and hands back the - * media of each member. `backend/livekit/` is the one backend today. + * media of each member. `media-backend/livekit/` is the one backend today. */ import { type Logger } from "matrix-js-sdk/lib/logger"; @@ -157,7 +157,12 @@ export interface MediaBackend { /** Every connection the backend holds. For debugging and devtool purposes.*/ readonly connections$: Behavior; - /** Plays the members' audio on this device, on the connections of now and later. */ + /** + * Plays the members' audio on this device: on the local transport's + * connection, whether it is connected yet or not, and on every connection + * created from then on. A connection to a remote transport that already + * exists keeps the device it was created with. + */ setAudioOutputDeviceId(deviceId: string): Promise; /** diff --git a/sdk/src/media-backend/livekit/Publisher.ts b/sdk/src/media-backend/livekit/Publisher.ts index 64ea877eb..00681644b 100644 --- a/sdk/src/media-backend/livekit/Publisher.ts +++ b/sdk/src/media-backend/livekit/Publisher.ts @@ -6,7 +6,6 @@ Please see LICENSE in the repository root for full details. */ import { - ConnectionState as LivekitConnectionState, type LocalTrackPublication, ParticipantEvent, type Room as LivekitRoom, @@ -207,13 +206,12 @@ export class Publisher { return [...this.room.localParticipant.trackPublications.values()]; } - /** A room that is not connected yet takes the device from its options instead. */ + /** + * Works on a room that is still connecting too: LiveKit keeps the device + * in the room's options and gives it to every participant that arrives. + */ public async setAudioOutputDevice(deviceId: string): Promise { - if ( - this.room.state !== LivekitConnectionState.Connected || - this.room.getActiveDevice("audiooutput") === deviceId - ) - return; + if (this.room.getActiveDevice("audiooutput") === deviceId) return; await this.room.switchActiveDevice("audiooutput", deviceId); } }