import LivePlayer from "@/components/player/LivePlayer"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import Heading from "@/components/ui/heading"; import { usePersistence } from "@/hooks/use-persistence"; import { FrigateConfig } from "@/types/frigateConfig"; import { useMemo, useState } from "react"; import { useParams } from "react-router-dom"; import useSWR from "swr"; function Live() { const { data: config } = useSWR("config"); const { camera: openedCamera } = useParams(); const [camera, setCamera] = useState( openedCamera ?? "Select A Camera" ); const cameraConfig = useMemo(() => { return config?.cameras[camera]; }, [camera, config]); const sortedCameras = useMemo(() => { if (!config) { return []; } return Object.values(config.cameras) .sort((aConf, bConf) => aConf.ui.order - bConf.ui.order); }, [config]); const restreamEnabled = useMemo(() => { return ( config && cameraConfig && Object.keys(config.go2rtc.streams || {}).includes( cameraConfig.live.stream_name ) ); }, [config, cameraConfig]); const defaultLiveMode = useMemo(() => { if (cameraConfig) { if (restreamEnabled) { return cameraConfig.ui.live_mode; } return "jsmpeg"; } return undefined; }, [cameraConfig, restreamEnabled]); const [viewSource, setViewSource, sourceIsLoaded] = usePersistence( `${camera}-source`, defaultLiveMode ); return (
Live
Select A Camera {(sortedCameras).map((item) => ( {item.name.replaceAll("_", " ")} ))} Select A Live Mode Webrtc MSE Jsmpeg Debug
{cameraConfig && sourceIsLoaded && ( )}
); } export default Live;