From 3d90366af2d5472a40cfe29055f8c7d9fc05ec47 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 12 Feb 2023 06:36:36 -0700 Subject: [PATCH] Fix Webui Default Stream (#5455) * Pass restream enabled * Use livemode for birdseye as well --- web/src/routes/Birdseye.jsx | 18 +++++++++++++++++- web/src/routes/Camera.jsx | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/web/src/routes/Birdseye.jsx b/web/src/routes/Birdseye.jsx index feaf6ff0e..91c97fcb9 100644 --- a/web/src/routes/Birdseye.jsx +++ b/web/src/routes/Birdseye.jsx @@ -10,7 +10,10 @@ import useSWR from 'swr'; export default function Birdseye() { const { data: config } = useSWR('config'); - const [viewSource, setViewSource, sourceIsLoaded] = usePersistence('birdseye-source', 'mse'); + const [viewSource, setViewSource, sourceIsLoaded] = usePersistence( + 'birdseye-source', + getDefaultLiveMode(config) + ); const sourceValues = ['mse', 'webrtc', 'jsmpeg']; if (!config || !sourceIsLoaded) { @@ -80,3 +83,16 @@ export default function Birdseye() { ); } + + +function getDefaultLiveMode(config) { + if (config) { + if (config.birdseye.restream) { + return config.ui.live_mode; + } + + return 'jsmpeg'; + } + + return undefined; +} diff --git a/web/src/routes/Camera.jsx b/web/src/routes/Camera.jsx index e99aa7db5..7a50d530a 100644 --- a/web/src/routes/Camera.jsx +++ b/web/src/routes/Camera.jsx @@ -32,7 +32,7 @@ export default function Camera({ camera }) { : 0; const [viewSource, setViewSource, sourceIsLoaded] = usePersistence( `${camera}-source`, - getDefaultLiveMode(config, cameraConfig) + getDefaultLiveMode(config, cameraConfig, restreamEnabled) ); const sourceValues = restreamEnabled ? ['mse', 'webrtc', 'jsmpeg'] : ['jsmpeg']; const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);