Try webrtc when mse fails with decoding error (#11745)

* Try webrtc if enabled and mse fails with decoding error

* default to jsmpeg if webrtc times out

* check for mic first
This commit is contained in:
Josh Hawkins
2024-06-04 10:11:32 -05:00
committed by GitHub
parent 2875e84cb5
commit 3f0a954856
5 changed files with 73 additions and 22 deletions

View File

@@ -190,6 +190,7 @@ export default function LiveCameraView({
const [audio, setAudio] = useState(false);
const [mic, setMic] = useState(false);
const [webRTC, setWebRTC] = useState(false);
const [pip, setPip] = useState(false);
const [lowBandwidth, setLowBandwidth] = useState(false);
@@ -203,12 +204,20 @@ export default function LiveCameraView({
return "webrtc";
}
if (webRTC && isRestreamed) {
return "webrtc";
}
if (webRTC && !isRestreamed) {
return "jsmpeg";
}
if (lowBandwidth) {
return "jsmpeg";
}
return "mse";
}, [lowBandwidth, mic]);
}, [lowBandwidth, mic, webRTC, isRestreamed]);
// layout state
@@ -426,7 +435,14 @@ export default function LiveCameraView({
pip={pip}
setFullResolution={setFullResolution}
containerRef={containerRef}
onError={() => setLowBandwidth(true)}
onError={(e) => {
if (e == "mse-decode") {
setWebRTC(true);
} else {
setWebRTC(false);
setLowBandwidth(true);
}
}}
/>
</div>
{camera.onvif.host != "" && (