fallback to webrtc if enabled before jsmpeg

This commit is contained in:
Josh Hawkins 2024-08-15 05:41:16 -05:00
parent af4bc9b466
commit 8f44cc3725
3 changed files with 33 additions and 10 deletions

View File

@ -139,6 +139,13 @@ function MSEPlayer({
}
}, [bufferTimeout]);
const handlePause = useCallback(() => {
// don't let the user pause the live stream
if (isPlaying && playbackEnabled) {
videoRef.current?.play();
}
}, [isPlaying, playbackEnabled]);
const onOpen = () => {
setWsState(WebSocket.OPEN);
@ -402,7 +409,7 @@ function MSEPlayer({
lastJumpTimeRef.current = Date.now();
}}
muted={!audioEnabled}
onPause={() => videoRef.current?.play()}
onPause={handlePause}
onProgress={() => {
const bufferTime = getBufferedTime(videoRef.current);

View File

@ -298,7 +298,12 @@ export interface FrigateConfig {
retry_interval: number;
};
go2rtc: Record<string, unknown>;
go2rtc: {
streams: string[];
webrtc: {
candidates: string[];
};
};
camera_groups: { [groupName: string]: CameraGroupConfig };

View File

@ -286,14 +286,25 @@ export default function LiveCameraView({
}
}, [fullscreen, isPortrait, cameraAspectRatio, containerAspectRatio]);
const handleError = useCallback((e: LivePlayerError) => {
if (e == "mse-decode") {
setWebRTC(true);
} else {
setWebRTC(false);
setLowBandwidth(true);
}
}, []);
const handleError = useCallback(
(e: LivePlayerError) => {
if (e) {
if (
!webRTC &&
config &&
config.go2rtc?.webrtc?.candidates?.length > 0
) {
// console.log(camera.name, "switching to webrtc");
setWebRTC(true);
} else {
// console.log(camera.name, "switching to jsmpeg");
setWebRTC(false);
setLowBandwidth(true);
}
}
},
[config, webRTC],
);
return (
<TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>