From 29553c11512c125be763db99cb8661ee8225fa9d Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 4 Jul 2023 19:21:35 +0100 Subject: [PATCH 1/3] Revert "Support for getting SFU config using OIDC" --- config/element_io_preview.json | 3 +- src/config/ConfigOptions.ts | 6 ++- src/livekit/OpenIDLoader.tsx | 96 ---------------------------------- src/livekit/openIDSFU.ts | 54 ------------------- src/livekit/useLiveKit.ts | 28 ++++++++-- src/room/GroupCallView.tsx | 36 ++++--------- src/room/InCallView.tsx | 17 +++--- 7 files changed, 51 insertions(+), 189 deletions(-) delete mode 100644 src/livekit/OpenIDLoader.tsx delete mode 100644 src/livekit/openIDSFU.ts diff --git a/config/element_io_preview.json b/config/element_io_preview.json index cb6fc088..30c2cc80 100644 --- a/config/element_io_preview.json +++ b/config/element_io_preview.json @@ -6,7 +6,8 @@ } }, "livekit": { - "livekit_service_url": "https://lk-jwt-service.lab.element.dev" + "server_url": "wss://sfu.call.element.dev", + "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 f878ec5e..1cee00fa 100644 --- a/src/config/ConfigOptions.ts +++ b/src/config/ConfigOptions.ts @@ -55,8 +55,10 @@ export interface ConfigOptions { // Describes the LiveKit configuration to be used. livekit?: { - // The link to the service that returns a livekit url and token to use it - livekit_service_url: string; + // 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/livekit/OpenIDLoader.tsx b/src/livekit/OpenIDLoader.tsx deleted file mode 100644 index 9e68d311..00000000 --- a/src/livekit/OpenIDLoader.tsx +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2023 New Vector Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import { - ReactNode, - createContext, - useContext, - useEffect, - useState, -} from "react"; -import { logger } from "matrix-js-sdk/src/logger"; - -import { - OpenIDClientParts, - SFUConfig, - getSFUConfigWithOpenID, -} from "./openIDSFU"; -import { ErrorView, LoadingView } from "../FullScreenView"; - -interface Props { - client: OpenIDClientParts; - livekitServiceURL: string; - roomName: string; - children: ReactNode; -} - -const SFUConfigContext = createContext(undefined); - -export const useSFUConfig = () => useContext(SFUConfigContext); - -export function OpenIDLoader({ - client, - livekitServiceURL, - roomName, - children, -}: Props) { - const [state, setState] = useState< - SFUConfigLoading | SFUConfigLoaded | SFUConfigFailed - >({ kind: "loading" }); - - useEffect(() => { - (async () => { - try { - const result = await getSFUConfigWithOpenID( - client, - livekitServiceURL, - roomName - ); - setState({ kind: "loaded", sfuConfig: result }); - } catch (e) { - logger.error("Failed to fetch SFU config: ", e); - setState({ kind: "failed", error: e }); - } - })(); - }, [client, livekitServiceURL, roomName]); - - switch (state.kind) { - case "loading": - return ; - case "failed": - return ; - case "loaded": - return ( - - {children} - - ); - } -} - -type SFUConfigLoading = { - kind: "loading"; -}; - -type SFUConfigLoaded = { - kind: "loaded"; - sfuConfig: SFUConfig; -}; - -type SFUConfigFailed = { - kind: "failed"; - error: Error; -}; diff --git a/src/livekit/openIDSFU.ts b/src/livekit/openIDSFU.ts deleted file mode 100644 index 89a5d4f3..00000000 --- a/src/livekit/openIDSFU.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2023 New Vector Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import { MatrixClient } from "matrix-js-sdk"; -import { logger } from "matrix-js-sdk/src/logger"; - -export interface SFUConfig { - url: string; - jwt: string; -} - -// The bits we need from MatrixClient -export type OpenIDClientParts = Pick< - MatrixClient, - "getOpenIdToken" | "getDeviceId" ->; - -export async function getSFUConfigWithOpenID( - client: OpenIDClientParts, - livekitServiceURL: string, - roomName: string -): Promise { - const openIdToken = await client.getOpenIdToken(); - logger.debug("Got openID token", openIdToken); - - const res = await fetch(livekitServiceURL + "/sfu/get", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - room: roomName, - openid_token: openIdToken, - device_id: client.getDeviceId(), - }), - }); - if (!res.ok) { - throw new Error("SFO Config fetch failed with status code " + res.status); - } - return await res.json(); -} diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index c35f4f46..22767405 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -1,9 +1,8 @@ import { Room, RoomOptions } from "livekit-client"; -import { useLiveKitRoom } from "@livekit/components-react"; +import { useLiveKitRoom, useToken } from "@livekit/components-react"; import { useMemo } from "react"; import { defaultLiveKitOptions } from "./options"; -import { SFUConfig } from "./openIDSFU"; export type UserChoices = { audio?: DeviceChoices; @@ -15,10 +14,29 @@ export type DeviceChoices = { enabled: boolean; }; +export type LiveKitConfig = { + sfuUrl: string; + jwtUrl: string; + roomName: string; + userDisplayName: string; + userIdentity: string; +}; + export function useLiveKit( userChoices: UserChoices, - sfuConfig: SFUConfig + config: LiveKitConfig ): Room | undefined { + const tokenOptions = useMemo( + () => ({ + userInfo: { + name: config.userDisplayName, + identity: config.userIdentity, + }, + }), + [config.userDisplayName, config.userIdentity] + ); + const token = useToken(config.jwtUrl, config.roomName, tokenOptions); + const roomOptions = useMemo((): RoomOptions => { const options = defaultLiveKitOptions; options.videoCaptureDefaults = { @@ -33,8 +51,8 @@ export function useLiveKit( }, [userChoices.video, userChoices.audio]); const { room } = useLiveKitRoom({ - token: sfuConfig.jwt, - serverUrl: sfuConfig.url, + token, + serverUrl: config.sfuUrl, audio: userChoices.audio?.enabled ?? false, video: userChoices.video?.enabled ?? false, options: roomOptions, diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 3532d737..76a4c414 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -28,15 +28,13 @@ import { useGroupCall } from "./useGroupCall"; import { ErrorView, FullScreenView } from "../FullScreenView"; import { LobbyView } from "./LobbyView"; import { MatrixInfo } from "./VideoPreview"; +import { ActiveCall } from "./InCallView"; import { CallEndedView } from "./CallEndedView"; import { useSentryGroupCallHandler } from "./useSentryGroupCallHandler"; import { PosthogAnalytics } from "../analytics/PosthogAnalytics"; import { useProfile } from "../profile/useProfile"; import { UserChoices } from "../livekit/useLiveKit"; import { findDeviceByName } from "../media-utils"; -import { OpenIDLoader } from "../livekit/OpenIDLoader"; -import { ActiveCall } from "./InCallView"; -import { Config } from "../config/Config"; declare global { interface Window { @@ -220,33 +218,21 @@ export function GroupCallView({ undefined ); - const lkServiceURL = Config.get().livekit?.livekit_service_url; - - if (!lkServiceURL) { - return ; - } - if (error) { return ; } else if (state === GroupCallState.Entered && userChoices) { return ( - - - + participants={participants} + onLeave={onLeave} + unencryptedEventsFromUsers={unencryptedEventsFromUsers} + hideHeader={hideHeader} + matrixInfo={matrixInfo} + userChoices={userChoices} + otelGroupCallMembership={otelGroupCallMembership} + /> ); } else if (left) { // The call ended view is shown for two reasons: prompting guests to create diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 98a3a63b..e3c7e94f 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -72,6 +72,7 @@ import { MatrixInfo } from "./VideoPreview"; import { useJoinRule } from "./useJoinRule"; import { ParticipantInfo } from "./useGroupCall"; import { ItemData, TileContent } from "../video-grid/VideoTile"; +import { Config } from "../config/Config"; import { NewVideoGrid } from "../video-grid/NewVideoGrid"; import { OTelGroupCallMembership } from "../otel/OTelGroupCallMembership"; import { SettingsModal } from "../settings/SettingsModal"; @@ -83,7 +84,6 @@ import { UserChoices, useLiveKit } from "../livekit/useLiveKit"; import { useMediaDevices } from "../livekit/useMediaDevices"; import { useFullscreen } from "./useFullscreen"; import { useLayoutStates } from "../video-grid/Layout"; -import { useSFUConfig } from "../livekit/OpenIDLoader"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -91,13 +91,18 @@ const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // For now we can disable screensharing in Safari. const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); -export interface ActiveCallProps extends Omit { +interface ActiveCallProps extends Omit { userChoices: UserChoices; } export function ActiveCall(props: ActiveCallProps) { - const sfuConfig = useSFUConfig(); - const livekitRoom = useLiveKit(props.userChoices, sfuConfig); + const livekitRoom = useLiveKit(props.userChoices, { + sfuUrl: Config.get().livekit!.server_url, + jwtUrl: `${Config.get().livekit!.jwt_service_url}/token`, + roomName: props.matrixInfo.roomName, + userDisplayName: props.matrixInfo.displayName, + userIdentity: `${props.client.getUserId()}:${props.client.getDeviceId()}`, + }); return ( livekitRoom && ( @@ -108,7 +113,7 @@ export function ActiveCall(props: ActiveCallProps) { ); } -export interface InCallViewProps { +interface Props { client: MatrixClient; groupCall: GroupCall; livekitRoom: Room; @@ -130,7 +135,7 @@ export function InCallView({ hideHeader, matrixInfo, otelGroupCallMembership, -}: InCallViewProps) { +}: Props) { const { t } = useTranslation(); usePreventScroll(); From fe96c4a4551d9a9a3dbf743432a5f5fa42ad73a9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 4 Jul 2023 20:25:51 +0100 Subject: [PATCH 2/3] Update the livekit branch name in more places Fixes the CI to get the config from the right place. Also removes reference to an env that's already been deleted. --- .github/workflows/netlify-livekit.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/netlify-livekit.yaml b/.github/workflows/netlify-livekit.yaml index f4463f91..3f66637b 100644 --- a/.github/workflows/netlify-livekit.yaml +++ b/.github/workflows/netlify-livekit.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest permissions: deployments: write - # Important: the 'branches' filter above will match the 'livekit-experiment' branch on forks, + # Important: the 'branches' filter above will match the 'livekit' branch on forks, # so we need to check the head repo too in order to not run on PRs from forks # We check the branch name again too just for completeness # (Is there a nicer way to see if a PR is from a fork?) @@ -24,7 +24,6 @@ jobs: with: step: start token: ${{ secrets.GITHUB_TOKEN }} - env: livekit-experiment-branch-cd ref: ${{ github.event.workflow_run.head_sha }} - name: "Download artifact" @@ -53,10 +52,10 @@ jobs: - name: Add redirects file # We fetch from github directly as we don't bother checking out the repo - run: curl -s https://raw.githubusercontent.com/vector-im/element-call/livekit-experiment/config/netlify_redirects > dist/_redirects + run: curl -s https://raw.githubusercontent.com/vector-im/element-call/livekit/config/netlify_redirects > dist/_redirects - name: Add config file - run: curl -s https://raw.githubusercontent.com/vector-im/element-call/livekit-experiment/config/element_io_preview.json > dist/config.json + run: curl -s https://raw.githubusercontent.com/vector-im/element-call/livekit/config/element_io_preview.json > dist/config.json - name: Deploy to Netlify id: netlify From 130b70756aafec0c2e4e6ef62c9dc8ea9d50b76d Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 5 Jul 2023 13:12:37 +0100 Subject: [PATCH 3/3] Revert "Revert "Support for getting SFU config using OIDC"" --- config/element_io_preview.json | 3 +- src/config/ConfigOptions.ts | 6 +-- src/livekit/OpenIDLoader.tsx | 96 ++++++++++++++++++++++++++++++++++ src/livekit/openIDSFU.ts | 54 +++++++++++++++++++ src/livekit/useLiveKit.ts | 28 ++-------- src/room/GroupCallView.tsx | 36 +++++++++---- src/room/InCallView.tsx | 17 +++--- 7 files changed, 189 insertions(+), 51 deletions(-) create mode 100644 src/livekit/OpenIDLoader.tsx create mode 100644 src/livekit/openIDSFU.ts diff --git a/config/element_io_preview.json b/config/element_io_preview.json index 30c2cc80..cb6fc088 100644 --- a/config/element_io_preview.json +++ b/config/element_io_preview.json @@ -6,8 +6,7 @@ } }, "livekit": { - "server_url": "wss://sfu.call.element.dev", - "jwt_service_url": "https://voip-sip-poc.element.io/lk/jwt_service" + "livekit_service_url": "https://lk-jwt-service.lab.element.dev" }, "posthog": { "api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU", diff --git a/src/config/ConfigOptions.ts b/src/config/ConfigOptions.ts index 1cee00fa..f878ec5e 100644 --- a/src/config/ConfigOptions.ts +++ b/src/config/ConfigOptions.ts @@ -55,10 +55,8 @@ export interface ConfigOptions { // 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; + // The link to the service that returns a livekit url and token to use it + livekit_service_url: string; }; /** diff --git a/src/livekit/OpenIDLoader.tsx b/src/livekit/OpenIDLoader.tsx new file mode 100644 index 00000000..9e68d311 --- /dev/null +++ b/src/livekit/OpenIDLoader.tsx @@ -0,0 +1,96 @@ +/* +Copyright 2023 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { + ReactNode, + createContext, + useContext, + useEffect, + useState, +} from "react"; +import { logger } from "matrix-js-sdk/src/logger"; + +import { + OpenIDClientParts, + SFUConfig, + getSFUConfigWithOpenID, +} from "./openIDSFU"; +import { ErrorView, LoadingView } from "../FullScreenView"; + +interface Props { + client: OpenIDClientParts; + livekitServiceURL: string; + roomName: string; + children: ReactNode; +} + +const SFUConfigContext = createContext(undefined); + +export const useSFUConfig = () => useContext(SFUConfigContext); + +export function OpenIDLoader({ + client, + livekitServiceURL, + roomName, + children, +}: Props) { + const [state, setState] = useState< + SFUConfigLoading | SFUConfigLoaded | SFUConfigFailed + >({ kind: "loading" }); + + useEffect(() => { + (async () => { + try { + const result = await getSFUConfigWithOpenID( + client, + livekitServiceURL, + roomName + ); + setState({ kind: "loaded", sfuConfig: result }); + } catch (e) { + logger.error("Failed to fetch SFU config: ", e); + setState({ kind: "failed", error: e }); + } + })(); + }, [client, livekitServiceURL, roomName]); + + switch (state.kind) { + case "loading": + return ; + case "failed": + return ; + case "loaded": + return ( + + {children} + + ); + } +} + +type SFUConfigLoading = { + kind: "loading"; +}; + +type SFUConfigLoaded = { + kind: "loaded"; + sfuConfig: SFUConfig; +}; + +type SFUConfigFailed = { + kind: "failed"; + error: Error; +}; diff --git a/src/livekit/openIDSFU.ts b/src/livekit/openIDSFU.ts new file mode 100644 index 00000000..89a5d4f3 --- /dev/null +++ b/src/livekit/openIDSFU.ts @@ -0,0 +1,54 @@ +/* +Copyright 2023 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { MatrixClient } from "matrix-js-sdk"; +import { logger } from "matrix-js-sdk/src/logger"; + +export interface SFUConfig { + url: string; + jwt: string; +} + +// The bits we need from MatrixClient +export type OpenIDClientParts = Pick< + MatrixClient, + "getOpenIdToken" | "getDeviceId" +>; + +export async function getSFUConfigWithOpenID( + client: OpenIDClientParts, + livekitServiceURL: string, + roomName: string +): Promise { + const openIdToken = await client.getOpenIdToken(); + logger.debug("Got openID token", openIdToken); + + const res = await fetch(livekitServiceURL + "/sfu/get", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + room: roomName, + openid_token: openIdToken, + device_id: client.getDeviceId(), + }), + }); + if (!res.ok) { + throw new Error("SFO Config fetch failed with status code " + res.status); + } + return await res.json(); +} diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index 22767405..c35f4f46 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -1,8 +1,9 @@ import { Room, RoomOptions } from "livekit-client"; -import { useLiveKitRoom, useToken } from "@livekit/components-react"; +import { useLiveKitRoom } from "@livekit/components-react"; import { useMemo } from "react"; import { defaultLiveKitOptions } from "./options"; +import { SFUConfig } from "./openIDSFU"; export type UserChoices = { audio?: DeviceChoices; @@ -14,29 +15,10 @@ export type DeviceChoices = { enabled: boolean; }; -export type LiveKitConfig = { - sfuUrl: string; - jwtUrl: string; - roomName: string; - userDisplayName: string; - userIdentity: string; -}; - export function useLiveKit( userChoices: UserChoices, - config: LiveKitConfig + sfuConfig: SFUConfig ): Room | undefined { - const tokenOptions = useMemo( - () => ({ - userInfo: { - name: config.userDisplayName, - identity: config.userIdentity, - }, - }), - [config.userDisplayName, config.userIdentity] - ); - const token = useToken(config.jwtUrl, config.roomName, tokenOptions); - const roomOptions = useMemo((): RoomOptions => { const options = defaultLiveKitOptions; options.videoCaptureDefaults = { @@ -51,8 +33,8 @@ export function useLiveKit( }, [userChoices.video, userChoices.audio]); const { room } = useLiveKitRoom({ - token, - serverUrl: config.sfuUrl, + token: sfuConfig.jwt, + serverUrl: sfuConfig.url, audio: userChoices.audio?.enabled ?? false, video: userChoices.video?.enabled ?? false, options: roomOptions, diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 76a4c414..3532d737 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -28,13 +28,15 @@ import { useGroupCall } from "./useGroupCall"; import { ErrorView, FullScreenView } from "../FullScreenView"; import { LobbyView } from "./LobbyView"; import { MatrixInfo } from "./VideoPreview"; -import { ActiveCall } from "./InCallView"; import { CallEndedView } from "./CallEndedView"; import { useSentryGroupCallHandler } from "./useSentryGroupCallHandler"; import { PosthogAnalytics } from "../analytics/PosthogAnalytics"; import { useProfile } from "../profile/useProfile"; import { UserChoices } from "../livekit/useLiveKit"; import { findDeviceByName } from "../media-utils"; +import { OpenIDLoader } from "../livekit/OpenIDLoader"; +import { ActiveCall } from "./InCallView"; +import { Config } from "../config/Config"; declare global { interface Window { @@ -218,21 +220,33 @@ export function GroupCallView({ undefined ); + const lkServiceURL = Config.get().livekit?.livekit_service_url; + + if (!lkServiceURL) { + return ; + } + if (error) { return ; } else if (state === GroupCallState.Entered && userChoices) { return ( - + livekitServiceURL={lkServiceURL} + roomName={matrixInfo.roomName} + > + + ); } else if (left) { // The call ended view is shown for two reasons: prompting guests to create diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index e3c7e94f..98a3a63b 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -72,7 +72,6 @@ import { MatrixInfo } from "./VideoPreview"; import { useJoinRule } from "./useJoinRule"; import { ParticipantInfo } from "./useGroupCall"; import { ItemData, TileContent } from "../video-grid/VideoTile"; -import { Config } from "../config/Config"; import { NewVideoGrid } from "../video-grid/NewVideoGrid"; import { OTelGroupCallMembership } from "../otel/OTelGroupCallMembership"; import { SettingsModal } from "../settings/SettingsModal"; @@ -84,6 +83,7 @@ import { UserChoices, useLiveKit } from "../livekit/useLiveKit"; import { useMediaDevices } from "../livekit/useMediaDevices"; import { useFullscreen } from "./useFullscreen"; import { useLayoutStates } from "../video-grid/Layout"; +import { useSFUConfig } from "../livekit/OpenIDLoader"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -91,18 +91,13 @@ const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // For now we can disable screensharing in Safari. const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); -interface ActiveCallProps extends Omit { +export interface ActiveCallProps extends Omit { userChoices: UserChoices; } export function ActiveCall(props: ActiveCallProps) { - const livekitRoom = useLiveKit(props.userChoices, { - sfuUrl: Config.get().livekit!.server_url, - jwtUrl: `${Config.get().livekit!.jwt_service_url}/token`, - roomName: props.matrixInfo.roomName, - userDisplayName: props.matrixInfo.displayName, - userIdentity: `${props.client.getUserId()}:${props.client.getDeviceId()}`, - }); + const sfuConfig = useSFUConfig(); + const livekitRoom = useLiveKit(props.userChoices, sfuConfig); return ( livekitRoom && ( @@ -113,7 +108,7 @@ export function ActiveCall(props: ActiveCallProps) { ); } -interface Props { +export interface InCallViewProps { client: MatrixClient; groupCall: GroupCall; livekitRoom: Room; @@ -135,7 +130,7 @@ export function InCallView({ hideHeader, matrixInfo, otelGroupCallMembership, -}: Props) { +}: InCallViewProps) { const { t } = useTranslation(); usePreventScroll();