mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
apply streaming settings in camera groups
This commit is contained in:
parent
a6cf755529
commit
3d2d51860d
@ -58,6 +58,7 @@ export default function BirdseyeLivePlayer({
|
|||||||
height={birdseyeConfig.height}
|
height={birdseyeConfig.height}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
playbackEnabled={true}
|
playbackEnabled={true}
|
||||||
|
useWebGL={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ type JSMpegPlayerProps = {
|
|||||||
height: number;
|
height: number;
|
||||||
containerRef: React.MutableRefObject<HTMLDivElement | null>;
|
containerRef: React.MutableRefObject<HTMLDivElement | null>;
|
||||||
playbackEnabled: boolean;
|
playbackEnabled: boolean;
|
||||||
|
useWebGL: boolean;
|
||||||
onPlaying?: () => void;
|
onPlaying?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ export default function JSMpegPlayer({
|
|||||||
className,
|
className,
|
||||||
containerRef,
|
containerRef,
|
||||||
playbackEnabled,
|
playbackEnabled,
|
||||||
|
useWebGL = false,
|
||||||
onPlaying,
|
onPlaying,
|
||||||
}: JSMpegPlayerProps) {
|
}: JSMpegPlayerProps) {
|
||||||
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
||||||
@ -123,8 +125,8 @@ export default function JSMpegPlayer({
|
|||||||
{
|
{
|
||||||
protocols: [],
|
protocols: [],
|
||||||
audio: false,
|
audio: false,
|
||||||
disableGl: camera != "birdseye",
|
disableGl: !useWebGL,
|
||||||
disableWebAssembly: camera != "birdseye",
|
disableWebAssembly: !useWebGL,
|
||||||
videoBufferSize: 1024 * 1024 * 4,
|
videoBufferSize: 1024 * 1024 * 4,
|
||||||
onVideoDecode: () => {
|
onVideoDecode: () => {
|
||||||
if (!hasDataRef.current) {
|
if (!hasDataRef.current) {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ type LivePlayerProps = {
|
|||||||
streamName: string;
|
streamName: string;
|
||||||
preferredLiveMode: LivePlayerMode;
|
preferredLiveMode: LivePlayerMode;
|
||||||
showStillWithoutActivity?: boolean;
|
showStillWithoutActivity?: boolean;
|
||||||
|
useWebGL: boolean;
|
||||||
windowVisible?: boolean;
|
windowVisible?: boolean;
|
||||||
playAudio?: boolean;
|
playAudio?: boolean;
|
||||||
micEnabled?: boolean; // only webrtc supports mic
|
micEnabled?: boolean; // only webrtc supports mic
|
||||||
@ -49,6 +50,7 @@ export default function LivePlayer({
|
|||||||
streamName,
|
streamName,
|
||||||
preferredLiveMode,
|
preferredLiveMode,
|
||||||
showStillWithoutActivity = true,
|
showStillWithoutActivity = true,
|
||||||
|
useWebGL = false,
|
||||||
windowVisible = true,
|
windowVisible = true,
|
||||||
playAudio = false,
|
playAudio = false,
|
||||||
micEnabled = false,
|
micEnabled = false,
|
||||||
@ -219,6 +221,7 @@ export default function LivePlayer({
|
|||||||
playbackEnabled={
|
playbackEnabled={
|
||||||
cameraActive || !showStillWithoutActivity || liveReady
|
cameraActive || !showStillWithoutActivity || liveReady
|
||||||
}
|
}
|
||||||
|
useWebGL={useWebGL}
|
||||||
containerRef={containerRef ?? internalContainerRef}
|
containerRef={containerRef ?? internalContainerRef}
|
||||||
onPlaying={playerIsPlaying}
|
onPlaying={playerIsPlaying}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -21,7 +21,8 @@ import { Label } from "@/components/ui/label";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
FrigateConfig,
|
FrigateConfig,
|
||||||
GroupStreamingSettingsType,
|
GroupStreamingSettings,
|
||||||
|
StreamType,
|
||||||
} from "@/types/frigateConfig";
|
} from "@/types/frigateConfig";
|
||||||
import ActivityIndicator from "../indicators/activity-indicator";
|
import ActivityIndicator from "../indicators/activity-indicator";
|
||||||
import { LuSettings } from "react-icons/lu";
|
import { LuSettings } from "react-icons/lu";
|
||||||
@ -30,9 +31,9 @@ type CameraStreamingDialogProps = {
|
|||||||
camera: string;
|
camera: string;
|
||||||
selectedCameras: string[];
|
selectedCameras: string[];
|
||||||
config?: FrigateConfig;
|
config?: FrigateConfig;
|
||||||
groupStreamingSettings: GroupStreamingSettingsType;
|
groupStreamingSettings: GroupStreamingSettings;
|
||||||
setGroupStreamingSettings: React.Dispatch<
|
setGroupStreamingSettings: React.Dispatch<
|
||||||
React.SetStateAction<GroupStreamingSettingsType>
|
React.SetStateAction<GroupStreamingSettings>
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ export function CameraStreamingDialog({
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const [streamName, setStreamName] = useState("");
|
const [streamName, setStreamName] = useState("");
|
||||||
const [streamType, setStreamType] = useState("smart");
|
const [streamType, setStreamType] = useState<StreamType>("smart");
|
||||||
const [compatibilityMode, setCompatibilityMode] = useState(false);
|
const [compatibilityMode, setCompatibilityMode] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -154,7 +155,10 @@ export function CameraStreamingDialog({
|
|||||||
<Label htmlFor="streaming-method" className="text-right">
|
<Label htmlFor="streaming-method" className="text-right">
|
||||||
Streaming Method
|
Streaming Method
|
||||||
</Label>
|
</Label>
|
||||||
<Select value={streamType} onValueChange={setStreamType}>
|
<Select
|
||||||
|
value={streamType}
|
||||||
|
onValueChange={(value) => setStreamType(value as StreamType)}
|
||||||
|
>
|
||||||
<SelectTrigger className="">
|
<SelectTrigger className="">
|
||||||
<SelectValue placeholder="Choose a streaming option" />
|
<SelectValue placeholder="Choose a streaming option" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|||||||
@ -229,9 +229,11 @@ export type CameraGroupConfig = {
|
|||||||
order: number;
|
order: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type StreamType = "no-streaming" | "smart" | "continuous";
|
||||||
|
|
||||||
export type CameraStreamingSettings = {
|
export type CameraStreamingSettings = {
|
||||||
streamName: string;
|
streamName: string;
|
||||||
streamType: string;
|
streamType: StreamType;
|
||||||
compatibilityMode: boolean;
|
compatibilityMode: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@ type DraggableGridLayoutProps = {
|
|||||||
setIsEditMode: React.Dispatch<React.SetStateAction<boolean>>;
|
setIsEditMode: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
fullscreen: boolean;
|
fullscreen: boolean;
|
||||||
toggleFullscreen: () => void;
|
toggleFullscreen: () => void;
|
||||||
|
allGroupsStreamingSettings: AllGroupsStreamingSettings;
|
||||||
setAllGroupsStreamingSettings: React.Dispatch<
|
setAllGroupsStreamingSettings: React.Dispatch<
|
||||||
React.SetStateAction<AllGroupsStreamingSettings>
|
React.SetStateAction<AllGroupsStreamingSettings>
|
||||||
>;
|
>;
|
||||||
@ -74,6 +75,7 @@ export default function DraggableGridLayout({
|
|||||||
setIsEditMode,
|
setIsEditMode,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
toggleFullscreen,
|
toggleFullscreen,
|
||||||
|
allGroupsStreamingSettings,
|
||||||
setAllGroupsStreamingSettings,
|
setAllGroupsStreamingSettings,
|
||||||
}: DraggableGridLayoutProps) {
|
}: DraggableGridLayoutProps) {
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
@ -84,6 +86,16 @@ export default function DraggableGridLayout({
|
|||||||
const { preferredLiveModes, setPreferredLiveModes, resetPreferredLiveMode } =
|
const { preferredLiveModes, setPreferredLiveModes, resetPreferredLiveMode } =
|
||||||
useCameraLiveMode(cameras, windowVisible);
|
useCameraLiveMode(cameras, windowVisible);
|
||||||
|
|
||||||
|
const [globalAutoLive] = usePersistence("autoLiveView", true);
|
||||||
|
|
||||||
|
const currentGroupStreamingSettings = useMemo(() => {
|
||||||
|
if (cameraGroup && cameraGroup != "default" && allGroupsStreamingSettings) {
|
||||||
|
return allGroupsStreamingSettings[cameraGroup];
|
||||||
|
}
|
||||||
|
}, [allGroupsStreamingSettings, cameraGroup]);
|
||||||
|
|
||||||
|
// grid layout
|
||||||
|
|
||||||
const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);
|
const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);
|
||||||
|
|
||||||
const [gridLayout, setGridLayout, isGridLayoutLoaded] = usePersistence<
|
const [gridLayout, setGridLayout, isGridLayoutLoaded] = usePersistence<
|
||||||
@ -426,9 +438,25 @@ export default function DraggableGridLayout({
|
|||||||
} else {
|
} else {
|
||||||
grow = "aspect-video";
|
grow = "aspect-video";
|
||||||
}
|
}
|
||||||
|
const streamName =
|
||||||
|
currentGroupStreamingSettings?.[camera.name]?.streamName ||
|
||||||
|
Object.values(camera.live.streams)[0];
|
||||||
|
const autoLive =
|
||||||
|
currentGroupStreamingSettings?.[camera.name]?.streamType !==
|
||||||
|
"no-streaming";
|
||||||
|
const showStillWithoutActivity =
|
||||||
|
currentGroupStreamingSettings?.[camera.name]?.streamType !==
|
||||||
|
"continuous";
|
||||||
|
const useWebGL =
|
||||||
|
currentGroupStreamingSettings?.[camera.name]
|
||||||
|
?.compatibilityMode || false;
|
||||||
return (
|
return (
|
||||||
<LivePlayerGridItem
|
<LivePlayerGridItem
|
||||||
key={camera.name}
|
key={camera.name}
|
||||||
|
streamName={streamName}
|
||||||
|
autoLive={autoLive ?? globalAutoLive}
|
||||||
|
showStillWithoutActivity={showStillWithoutActivity ?? true}
|
||||||
|
useWebGL={useWebGL}
|
||||||
cameraRef={cameraRef}
|
cameraRef={cameraRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-lg bg-black md:rounded-2xl",
|
"rounded-lg bg-black md:rounded-2xl",
|
||||||
@ -616,6 +644,10 @@ type LivePlayerGridItemProps = {
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
onError: (e: LivePlayerError) => void;
|
onError: (e: LivePlayerError) => void;
|
||||||
onResetLiveMode: () => void;
|
onResetLiveMode: () => void;
|
||||||
|
streamName: string;
|
||||||
|
autoLive: boolean;
|
||||||
|
showStillWithoutActivity: boolean;
|
||||||
|
useWebGL: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const LivePlayerGridItem = React.forwardRef<
|
const LivePlayerGridItem = React.forwardRef<
|
||||||
@ -637,6 +669,10 @@ const LivePlayerGridItem = React.forwardRef<
|
|||||||
onClick,
|
onClick,
|
||||||
onError,
|
onError,
|
||||||
onResetLiveMode,
|
onResetLiveMode,
|
||||||
|
autoLive,
|
||||||
|
showStillWithoutActivity,
|
||||||
|
streamName,
|
||||||
|
useWebGL,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
@ -656,11 +692,14 @@ const LivePlayerGridItem = React.forwardRef<
|
|||||||
windowVisible={windowVisible}
|
windowVisible={windowVisible}
|
||||||
cameraConfig={cameraConfig}
|
cameraConfig={cameraConfig}
|
||||||
preferredLiveMode={preferredLiveMode}
|
preferredLiveMode={preferredLiveMode}
|
||||||
streamName={Object.values(cameraConfig.live.streams)[0]}
|
streamName={streamName}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onError={onError}
|
onError={onError}
|
||||||
onResetLiveMode={onResetLiveMode}
|
onResetLiveMode={onResetLiveMode}
|
||||||
containerRef={ref as React.RefObject<HTMLDivElement>}
|
containerRef={ref as React.RefObject<HTMLDivElement>}
|
||||||
|
autoLive={autoLive}
|
||||||
|
showStillWithoutActivity={showStillWithoutActivity}
|
||||||
|
useWebGL={useWebGL}
|
||||||
/>
|
/>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -197,22 +197,12 @@ export default function LiveDashboardView({
|
|||||||
const [persistedStreamingSettings, _, isStreamingSettingsLoaded] =
|
const [persistedStreamingSettings, _, isStreamingSettingsLoaded] =
|
||||||
usePersistence<AllGroupsStreamingSettings>("streaming-settings");
|
usePersistence<AllGroupsStreamingSettings>("streaming-settings");
|
||||||
|
|
||||||
const currentGroupStreamingSettings = useMemo(() => {
|
|
||||||
if (cameraGroup && cameraGroup != "default" && allGroupsStreamingSettings) {
|
|
||||||
return allGroupsStreamingSettings[cameraGroup];
|
|
||||||
}
|
|
||||||
}, [allGroupsStreamingSettings, cameraGroup]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isStreamingSettingsLoaded) {
|
if (isStreamingSettingsLoaded) {
|
||||||
setAllGroupsStreamingSettings(persistedStreamingSettings ?? {});
|
setAllGroupsStreamingSettings(persistedStreamingSettings ?? {});
|
||||||
}
|
}
|
||||||
}, [isStreamingSettingsLoaded, persistedStreamingSettings]);
|
}, [isStreamingSettingsLoaded, persistedStreamingSettings]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// console.log("group settings", cameraGroup, currentGroupStreamingSettings);
|
|
||||||
}, [currentGroupStreamingSettings, cameraGroup]);
|
|
||||||
|
|
||||||
const cameraRef = useCallback(
|
const cameraRef = useCallback(
|
||||||
(node: HTMLElement | null) => {
|
(node: HTMLElement | null) => {
|
||||||
if (!visibleCameraObserver.current) {
|
if (!visibleCameraObserver.current) {
|
||||||
@ -384,6 +374,7 @@ export default function LiveDashboardView({
|
|||||||
cameraConfig={camera}
|
cameraConfig={camera}
|
||||||
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
|
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
|
||||||
autoLive={autoLiveView}
|
autoLive={autoLiveView}
|
||||||
|
useWebGL={false}
|
||||||
streamName={Object.values(camera.live.streams)[0]}
|
streamName={Object.values(camera.live.streams)[0]}
|
||||||
onClick={() => onSelectCamera(camera.name)}
|
onClick={() => onSelectCamera(camera.name)}
|
||||||
onError={(e) => handleError(camera.name, e)}
|
onError={(e) => handleError(camera.name, e)}
|
||||||
@ -436,6 +427,7 @@ export default function LiveDashboardView({
|
|||||||
setIsEditMode={setIsEditMode}
|
setIsEditMode={setIsEditMode}
|
||||||
fullscreen={fullscreen}
|
fullscreen={fullscreen}
|
||||||
toggleFullscreen={toggleFullscreen}
|
toggleFullscreen={toggleFullscreen}
|
||||||
|
allGroupsStreamingSettings={allGroupsStreamingSettings}
|
||||||
setAllGroupsStreamingSettings={setAllGroupsStreamingSettings}
|
setAllGroupsStreamingSettings={setAllGroupsStreamingSettings}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user