mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Remove unused callback
This commit is contained in:
parent
b9b40d5ed5
commit
8271665e13
@ -8,39 +8,37 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ws = new WebSocket(url);
|
const ws = new WebSocket(url);
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
pc.createOffer().then(offer => {
|
pc.createOffer().then((offer) => {
|
||||||
pc.setLocalDescription(offer).then(() => {
|
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.send(JSON.stringify(msg));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
ws.onmessage = ev => {
|
ws.onmessage = (ev) => {
|
||||||
const msg = JSON.parse(ev.data);
|
const msg = JSON.parse(ev.data);
|
||||||
|
|
||||||
if (msg.type === 'webrtc/candidate') {
|
if (msg.type === 'webrtc/candidate') {
|
||||||
pc.addIceCandidate({candidate: msg.value, sdpMid: ''});
|
pc.addIceCandidate({ candidate: msg.value, sdpMid: '' });
|
||||||
} else if (msg.type === 'webrtc/answer') {
|
} else if (msg.type === 'webrtc/answer') {
|
||||||
pc.setRemoteDescription({type: 'answer', sdp: msg.value});
|
pc.setRemoteDescription({ type: 'answer', sdp: msg.value });
|
||||||
pc.getTransceivers().forEach(t => {
|
|
||||||
if (t.receiver.track.kind === 'audio') {
|
|
||||||
t.currentDirection
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [{ urls: 'stun:stun.l.google.com:19302' }],
|
iceServers: [{ urls: 'stun:stun.l.google.com:19302' }],
|
||||||
});
|
});
|
||||||
pc.onicecandidate = ev => {
|
pc.onicecandidate = (ev) => {
|
||||||
if (ev.candidate !== null) {
|
if (ev.candidate !== null) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(
|
||||||
type: 'webrtc/candidate', value: ev.candidate.toJSON().candidate,
|
JSON.stringify({
|
||||||
}));
|
type: 'webrtc/candidate',
|
||||||
|
value: ev.candidate.toJSON().candidate,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
pc.ontrack = ev => {
|
pc.ontrack = (ev) => {
|
||||||
const video = document.getElementById('video');
|
const video = document.getElementById('video');
|
||||||
|
|
||||||
// when audio track not exist in Chrome
|
// when audio track not exist in Chrome
|
||||||
@ -51,7 +49,7 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
|||||||
if (video.srcObject !== null) return;
|
if (video.srcObject !== null) return;
|
||||||
|
|
||||||
video.srcObject = ev.streams[0];
|
video.srcObject = ev.streams[0];
|
||||||
}
|
};
|
||||||
|
|
||||||
// Safari don't support "offerToReceiveVideo"
|
// Safari don't support "offerToReceiveVideo"
|
||||||
// so need to create transeivers manually
|
// so need to create transeivers manually
|
||||||
@ -68,7 +66,7 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<video id='video' autoplay playsinline controls muted width={width} height={height} />
|
<video id="video" autoplay playsinline controls muted width={width} height={height} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user