From 8271665e13709de69ee0ea557eaf398e0926986b Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 31 Oct 2022 09:41:51 -0600 Subject: [PATCH] Remove unused callback --- web/src/components/WebRtcPlayer.jsx | 40 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/web/src/components/WebRtcPlayer.jsx b/web/src/components/WebRtcPlayer.jsx index 5397717d8..051259589 100644 --- a/web/src/components/WebRtcPlayer.jsx +++ b/web/src/components/WebRtcPlayer.jsx @@ -8,39 +8,37 @@ export default function WebRtcPlayer({ camera, width, height }) { useEffect(() => { const ws = new WebSocket(url); ws.onopen = () => { - pc.createOffer().then(offer => { + pc.createOffer().then((offer) => { pc.setLocalDescription(offer).then(() => { - const msg = {type: 'webrtc/offer', value: pc.localDescription.sdp}; + const msg = { type: 'webrtc/offer', value: pc.localDescription.sdp }; ws.send(JSON.stringify(msg)); }); }); - } - ws.onmessage = ev => { + }; + ws.onmessage = (ev) => { const msg = JSON.parse(ev.data); if (msg.type === 'webrtc/candidate') { - pc.addIceCandidate({candidate: msg.value, sdpMid: ''}); + pc.addIceCandidate({ candidate: msg.value, sdpMid: '' }); } else if (msg.type === 'webrtc/answer') { - pc.setRemoteDescription({type: 'answer', sdp: msg.value}); - pc.getTransceivers().forEach(t => { - if (t.receiver.track.kind === 'audio') { - t.currentDirection - } - }) + pc.setRemoteDescription({ type: 'answer', sdp: msg.value }); } - } + }; const pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }], }); - pc.onicecandidate = ev => { + pc.onicecandidate = (ev) => { if (ev.candidate !== null) { - ws.send(JSON.stringify({ - type: 'webrtc/candidate', value: ev.candidate.toJSON().candidate, - })); + ws.send( + JSON.stringify({ + type: 'webrtc/candidate', + value: ev.candidate.toJSON().candidate, + }) + ); } - } - pc.ontrack = ev => { + }; + pc.ontrack = (ev) => { const video = document.getElementById('video'); // when audio track not exist in Chrome @@ -51,7 +49,7 @@ export default function WebRtcPlayer({ camera, width, height }) { if (video.srcObject !== null) return; video.srcObject = ev.streams[0]; - } + }; // Safari don't support "offerToReceiveVideo" // so need to create transeivers manually @@ -68,7 +66,7 @@ export default function WebRtcPlayer({ camera, width, height }) { return (
-
); -} \ No newline at end of file +}