Make LiveKit configurable

This commit is contained in:
Daniel Abramov 2023-06-07 20:16:24 +02:00
parent dc98960d8d
commit e032edbfad
4 changed files with 12 additions and 14 deletions

View File

@ -5,9 +5,9 @@
"server_name": "call.ems.host" "server_name": "call.ems.host"
} }
}, },
"temp_sfu": { "livekit": {
"user_id": "@sfu:call.ems.host", "server_url": "wss://ec-test-t5xo1uoy.livekit.cloud",
"device_id": "YNZDLSEQMP" "jwt_service_url": "https://voip-sip-poc.element.io/lk/jwt_service"
}, },
"posthog": { "posthog": {
"api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU", "api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU",

View File

@ -45,13 +45,12 @@ export interface ConfigOptions {
}; };
}; };
/** // Describes the LiveKit configuration to be used.
* Sets the client's preferred SFU livekit?: {
* TEMPORARY: Will be removed in favour of getting SFUs from the homeserver // The LiveKit server URL to connect to.
*/ server_url: string;
temp_sfu?: { // The link to the service that generates JWT tokens to join LiveKit rooms.
user_id: string; jwt_service_url: string;
device_id: string;
}; };
} }

View File

@ -95,8 +95,6 @@ export async function initClient(
// options we always pass to the client (stuff that we need in order to work) // options we always pass to the client (stuff that we need in order to work)
const baseOpts = { const baseOpts = {
fallbackICEServerAllowed: fallbackICEServerAllowed, fallbackICEServerAllowed: fallbackICEServerAllowed,
localSfuUserId: Config.get().temp_sfu?.user_id,
localSfuDeviceId: Config.get().temp_sfu?.device_id,
} as ICreateClientOpts; } as ICreateClientOpts;
if (indexedDB && localStorage) { if (indexedDB && localStorage) {

View File

@ -73,6 +73,7 @@ import { MatrixInfo } from "./VideoPreview";
import { useJoinRule } from "./useJoinRule"; import { useJoinRule } from "./useJoinRule";
import { ParticipantInfo } from "./useGroupCall"; import { ParticipantInfo } from "./useGroupCall";
import { TileContent } from "../video-grid/VideoTile"; import { TileContent } from "../video-grid/VideoTile";
import { Config } from "../config/Config";
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
// There is currently a bug in Safari our our code with cloning and sending MediaStreams // 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] [matrixInfo.userName, userId, deviceId]
); );
const token = useToken( const token = useToken(
"http://localhost:8080/token", `${Config.get().livekit.jwt_service_url}/token`,
matrixInfo.roomName, matrixInfo.roomName,
options 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). // Uses a hook to connect to the LiveKit room (on unmount the room will be left) and publish local media tracks (default).
useLiveKitRoom({ useLiveKitRoom({
token, token,
serverUrl: "ws://localhost:7880", serverUrl: Config.get().livekit.server_url,
room: livekitRoom, room: livekitRoom,
audio: true, audio: true,
video: true, video: true,