/* Copyright 2022-2024 New Vector Ltd. SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { type ChangeEvent, type FC, type ReactNode, useCallback, useEffect, useMemo, useId, useState, } from "react"; import { useTranslation } from "react-i18next"; import { UNSTABLE_MSC4354_STICKY_EVENTS, type MatrixClient, } from "matrix-js-sdk"; import { logger } from "matrix-js-sdk/lib/logger"; import { EditInPlace, ErrorMessage, Root as Form, Heading, HelpMessage, InlineField, Label, RadioControl, Separator, } from "@vector-im/compound-web"; import { type Room as LivekitRoom } from "livekit-client"; import { FieldRow, InputField } from "../input/Input"; import { Config } from "../config/Config"; import { type Setting, useSetting, duplicateTiles as duplicateTilesSetting, debugTileLayout as debugTileLayoutSetting, showConnectionStats as showConnectionStatsSetting, muteAllAudio as muteAllAudioSetting, alwaysShowIphoneEarpiece as alwaysShowIphoneEarpieceSetting, matrixRTCMode as matrixRTCModeSetting, customLivekitUrl as customLivekitUrlSetting, advancedScreenShare as advancedScreenShareSetting, screenShareResolution as screenShareResolutionSetting, screenShareFramerate as screenShareFramerateSetting, screenShareBitrate as screenShareBitrateSetting, screenShareCodec as screenShareCodecSetting, advancedCamera as advancedCameraSetting, cameraResolution as cameraResolutionSetting, cameraFramerate as cameraFramerateSetting, cameraBitrate as cameraBitrateSetting, cameraCodec as cameraCodecSetting, echoCancellationSetting, noiseSuppressionSetting, autoGainControlSetting, type VideoCodec, enableExtendedLivekitLogs as enableExtendedLivekitLogsSetting, } from "./settings"; import { MatrixRTCMode } from "../config/ConfigOptions"; import styles from "./DeveloperSettingsTab.module.css"; import settingsStyles from "./SettingsModal.module.css"; import { Slider } from "../Slider"; import { useUrlParams } from "../UrlParams"; import { type CallViewModel } from "../state/CallViewModel/CallViewModel.ts"; import { getSFUConfigWithOpenID } from "../livekit/openIDSFU"; import { useBehavior } from "../useBehavior"; /** * Shows whether the call is large enough that MatrixRTC has stopped rotating the media key. */ const KeyRotationStatus: FC<{ vm: CallViewModel }> = ({ vm }) => { const suppressed = useBehavior(vm.keyRotationSuppressed$); const participantCount = useBehavior(vm.participantCount$); return (
Media key rotation:{" "} {suppressed ? `suppressed, participant limit reached (${participantCount} participants)` : `active (${participantCount} participants)`}
); }; interface Props { client: MatrixClient; roomId?: string; livekitRooms?: { room: LivekitRoom; url: string; isLocal?: boolean; livekitAlias?: string; }[]; env: ImportMetaEnv; /** Only available while in a call. */ vm?: CallViewModel; } export const DeveloperSettingsTab: FC{t( "settings.audio_processing_description", "Changes apply on next call join.", )}
{t("developer_mode.hostname", { hostname: window.location.hostname || "unknown", })}
{t("version", { productName: import.meta.env.VITE_PRODUCT_NAME || "Element Call", version: import.meta.env.VITE_APP_VERSION || "dev", })}
{t("developer_mode.crypto_version", { version: client.getCrypto()?.getVersion() || "unknown", })}
{t("developer_mode.matrix_id", { id: client.getUserId() || "unknown", })}
{t("developer_mode.device_id", { id: client.getDeviceId() || "unknown", })}
{vm &&Your deployment overrides the mode.
} {livekitRooms?.map((livekitRoom) => (LivekitAlias: {livekitRoom.livekitAlias}
connectionState (wont hot reload): {livekitRoom.room.state}
{livekitRoom.isLocal &&ws-url: {localSfuUrl?.href}
}{t("developer_mode.livekit_server_info")}( {livekitRoom.isLocal ? "local" : "remote"})
{livekitRoom.room.serverInfo
? JSON.stringify(livekitRoom.room.serverInfo, null, 2)
: "undefined"}
{livekitRoom.room.metadata}
Local Participant
{livekitRoom.room.localParticipant.identity}
Remote Participants
{t("developer_mode.environment_variables")}
{JSON.stringify(env, null, 2)}
{t("developer_mode.url_params")}
{JSON.stringify(urlParams, null, 2)}
>
);
};