From e032edbfad333c37cdc9a6aa395f8c8c3ed639e9 Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Wed, 7 Jun 2023 20:16:24 +0200 Subject: [PATCH] Make LiveKit configurable --- config/element_io_preview.json | 6 +++--- src/config/ConfigOptions.ts | 13 ++++++------- src/matrix-utils.ts | 2 -- src/room/InCallView.tsx | 5 +++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/config/element_io_preview.json b/config/element_io_preview.json index 39ed7595..30065ab4 100644 --- a/config/element_io_preview.json +++ b/config/element_io_preview.json @@ -5,9 +5,9 @@ "server_name": "call.ems.host" } }, - "temp_sfu": { - "user_id": "@sfu:call.ems.host", - "device_id": "YNZDLSEQMP" + "livekit": { + "server_url": "wss://ec-test-t5xo1uoy.livekit.cloud", + "jwt_service_url": "https://voip-sip-poc.element.io/lk/jwt_service" }, "posthog": { "api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU", diff --git a/src/config/ConfigOptions.ts b/src/config/ConfigOptions.ts index 08924c08..eae33117 100644 --- a/src/config/ConfigOptions.ts +++ b/src/config/ConfigOptions.ts @@ -45,13 +45,12 @@ export interface ConfigOptions { }; }; - /** - * Sets the client's preferred SFU - * TEMPORARY: Will be removed in favour of getting SFUs from the homeserver - */ - temp_sfu?: { - user_id: string; - device_id: string; + // Describes the LiveKit configuration to be used. + livekit?: { + // The LiveKit server URL to connect to. + server_url: string; + // The link to the service that generates JWT tokens to join LiveKit rooms. + jwt_service_url: string; }; } diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index d3ea527b..7b9a2e19 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -95,8 +95,6 @@ export async function initClient( // options we always pass to the client (stuff that we need in order to work) const baseOpts = { fallbackICEServerAllowed: fallbackICEServerAllowed, - localSfuUserId: Config.get().temp_sfu?.user_id, - localSfuDeviceId: Config.get().temp_sfu?.device_id, } as ICreateClientOpts; if (indexedDB && localStorage) { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 1ce6341b..6382cb8f 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -73,6 +73,7 @@ import { MatrixInfo } from "./VideoPreview"; import { useJoinRule } from "./useJoinRule"; import { ParticipantInfo } from "./useGroupCall"; import { TileContent } from "../video-grid/VideoTile"; +import { Config } from "../config/Config"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -132,7 +133,7 @@ export function InCallView({ [matrixInfo.userName, userId, deviceId] ); const token = useToken( - "http://localhost:8080/token", + `${Config.get().livekit.jwt_service_url}/token`, matrixInfo.roomName, options ); @@ -140,7 +141,7 @@ export function InCallView({ // Uses a hook to connect to the LiveKit room (on unmount the room will be left) and publish local media tracks (default). useLiveKitRoom({ token, - serverUrl: "ws://localhost:7880", + serverUrl: Config.get().livekit.server_url, room: livekitRoom, audio: true, video: true,