import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer"; 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 ?? (config?.birdseye.enabled ? "birdseye" : "Select A Camera") ); const cameraConfig = useMemo(() => { return camera == "birdseye" ? undefined : 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(() => { if (!config) { return false; } if (camera == "birdseye") { return config.birdseye.restream; } return ( 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 || config?.ui.live_mode; } return "jsmpeg"; } return undefined; }, [cameraConfig, restreamEnabled]); const [viewSource, setViewSource, sourceIsLoaded] = usePersistence( `${camera}-source`, camera == "birdseye" ? "jsmpeg" : defaultLiveMode ); return (
Live
Select A Camera {config?.birdseye.enabled && ( Birdseye )} {sortedCameras.map((item) => ( {item.name.replaceAll("_", " ")} ))}
Select A Live Mode {restreamEnabled && ( Webrtc )} {restreamEnabled && ( MSE )} Jsmpeg {camera != "birdseye" && ( Debug )}
{config && camera == "birdseye" && sourceIsLoaded && ( )} {cameraConfig && sourceIsLoaded && ( )}
); } export default Live;