mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 19:55:26 +03:00
Only close pc
This commit is contained in:
parent
6866edef76
commit
96d07c6066
@ -56,8 +56,8 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
||||
}
|
||||
}
|
||||
|
||||
const connect = useCallback(async (ws) => {
|
||||
const pc = await PeerConnection('video+audio');
|
||||
const connect = useCallback(async (ws, aPc) => {
|
||||
const pc = await aPc;
|
||||
|
||||
ws.addEventListener('open', () => {
|
||||
pc.addEventListener('icecandidate', (ev) => {
|
||||
@ -82,21 +82,18 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
||||
pc.setRemoteDescription({ type: 'answer', sdp: msg.value });
|
||||
}
|
||||
});
|
||||
|
||||
ws.addEventListener('close', () => {
|
||||
pc.close();
|
||||
})
|
||||
}, [PeerConnection]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const url = `${baseUrl.replace(/^http/, 'ws')}live/webrtc/api/ws?src=${camera}`;
|
||||
const ws = new WebSocket(url);
|
||||
connect(ws);
|
||||
const aPc = PeerConnection('video+audio');
|
||||
connect(ws, aPc);
|
||||
|
||||
return () => {
|
||||
ws.close();
|
||||
return async () => {
|
||||
(await aPc).close();
|
||||
}
|
||||
}, [camera, connect]);
|
||||
}, [camera, connect, PeerConnection]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user