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"
}
},
"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",

View File

@ -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;
};
}

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)
const baseOpts = {
fallbackICEServerAllowed: fallbackICEServerAllowed,
localSfuUserId: Config.get().temp_sfu?.user_id,
localSfuDeviceId: Config.get().temp_sfu?.device_id,
} as ICreateClientOpts;
if (indexedDB && localStorage) {

View File

@ -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,