mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-12 22:25:24 +03:00
Try webrtc if enabled and mse fails with decoding error
This commit is contained in:
parent
e6d1ad0ac5
commit
1b9e539903
@ -8,6 +8,7 @@ import {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import { isIOS, isSafari } from "react-device-detect";
|
||||||
|
|
||||||
type MSEPlayerProps = {
|
type MSEPlayerProps = {
|
||||||
camera: string;
|
camera: string;
|
||||||
@ -311,8 +312,11 @@ function MSEPlayer({
|
|||||||
onPlaying?.();
|
onPlaying?.();
|
||||||
}}
|
}}
|
||||||
muted={!audioEnabled}
|
muted={!audioEnabled}
|
||||||
onProgress={
|
onProgress={() => {
|
||||||
onError != undefined
|
if (isSafari || isIOS) {
|
||||||
|
onPlaying?.();
|
||||||
|
}
|
||||||
|
return onError != undefined
|
||||||
? () => {
|
? () => {
|
||||||
if (videoRef.current?.paused) {
|
if (videoRef.current?.paused) {
|
||||||
return;
|
return;
|
||||||
@ -329,8 +333,8 @@ function MSEPlayer({
|
|||||||
}, 3000),
|
}, 3000),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined;
|
||||||
}
|
}}
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
if (
|
if (
|
||||||
// @ts-expect-error code does exist
|
// @ts-expect-error code does exist
|
||||||
@ -339,6 +343,14 @@ function MSEPlayer({
|
|||||||
onError?.("startup");
|
onError?.("startup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
// @ts-expect-error code does exist
|
||||||
|
e.target.error.code == MediaError.MEDIA_ERR_DECODE &&
|
||||||
|
(isSafari || isIOS)
|
||||||
|
) {
|
||||||
|
onError?.("mse-decode");
|
||||||
|
}
|
||||||
|
|
||||||
if (wsRef.current) {
|
if (wsRef.current) {
|
||||||
wsRef.current.close();
|
wsRef.current.close();
|
||||||
wsRef.current = null;
|
wsRef.current = null;
|
||||||
|
|||||||
@ -31,4 +31,4 @@ export type LiveStreamMetadata = {
|
|||||||
consumers: LiveConsumerMetadata[];
|
consumers: LiveConsumerMetadata[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LivePlayerError = "stalled" | "startup";
|
export type LivePlayerError = "stalled" | "startup" | "mse-decode";
|
||||||
|
|||||||
@ -190,6 +190,7 @@ export default function LiveCameraView({
|
|||||||
|
|
||||||
const [audio, setAudio] = useState(false);
|
const [audio, setAudio] = useState(false);
|
||||||
const [mic, setMic] = useState(false);
|
const [mic, setMic] = useState(false);
|
||||||
|
const [webRTC, setWebRTC] = useState(false);
|
||||||
const [pip, setPip] = useState(false);
|
const [pip, setPip] = useState(false);
|
||||||
const [lowBandwidth, setLowBandwidth] = useState(false);
|
const [lowBandwidth, setLowBandwidth] = useState(false);
|
||||||
|
|
||||||
@ -199,6 +200,14 @@ export default function LiveCameraView({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const preferredLiveMode = useMemo(() => {
|
const preferredLiveMode = useMemo(() => {
|
||||||
|
if (webRTC && isRestreamed) {
|
||||||
|
return "webrtc";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (webRTC && !isRestreamed) {
|
||||||
|
return "jsmpeg";
|
||||||
|
}
|
||||||
|
|
||||||
if (mic) {
|
if (mic) {
|
||||||
return "webrtc";
|
return "webrtc";
|
||||||
}
|
}
|
||||||
@ -208,7 +217,7 @@ export default function LiveCameraView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "mse";
|
return "mse";
|
||||||
}, [lowBandwidth, mic]);
|
}, [lowBandwidth, mic, webRTC, isRestreamed]);
|
||||||
|
|
||||||
// layout state
|
// layout state
|
||||||
|
|
||||||
@ -426,7 +435,14 @@ export default function LiveCameraView({
|
|||||||
pip={pip}
|
pip={pip}
|
||||||
setFullResolution={setFullResolution}
|
setFullResolution={setFullResolution}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
onError={() => setLowBandwidth(true)}
|
onError={(e) => {
|
||||||
|
if (e == "mse-decode") {
|
||||||
|
setWebRTC(true);
|
||||||
|
} else {
|
||||||
|
setWebRTC(false);
|
||||||
|
setLowBandwidth(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{camera.onvif.host != "" && (
|
{camera.onvif.host != "" && (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user