mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 04:05: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 connect = useCallback(async (ws, aPc) => {
|
||||||
const pc = await PeerConnection('video+audio');
|
const pc = await aPc;
|
||||||
|
|
||||||
ws.addEventListener('open', () => {
|
ws.addEventListener('open', () => {
|
||||||
pc.addEventListener('icecandidate', (ev) => {
|
pc.addEventListener('icecandidate', (ev) => {
|
||||||
@ -82,21 +82,18 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
|||||||
pc.setRemoteDescription({ type: 'answer', sdp: msg.value });
|
pc.setRemoteDescription({ type: 'answer', sdp: msg.value });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, []);
|
||||||
ws.addEventListener('close', () => {
|
|
||||||
pc.close();
|
|
||||||
})
|
|
||||||
}, [PeerConnection]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const url = `${baseUrl.replace(/^http/, 'ws')}live/webrtc/api/ws?src=${camera}`;
|
const url = `${baseUrl.replace(/^http/, 'ws')}live/webrtc/api/ws?src=${camera}`;
|
||||||
const ws = new WebSocket(url);
|
const ws = new WebSocket(url);
|
||||||
connect(ws);
|
const aPc = PeerConnection('video+audio');
|
||||||
|
connect(ws, aPc);
|
||||||
|
|
||||||
return () => {
|
return async () => {
|
||||||
ws.close();
|
(await aPc).close();
|
||||||
}
|
}
|
||||||
}, [camera, connect]);
|
}, [camera, connect, PeerConnection]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user