-
Notifications
You must be signed in to change notification settings - Fork 989
Closed
Description
I'm trying to set up my Creality K2 Plus 3D printer camera in my HomeAssistant.
The camera is available on port 8000 of the printer IP. But of course this is a JavaScript wrapper doing all the WebRTC/stun "magic".
As I'm very new to WebRTC stuff, I'd be more than happy if someone could point me in the right direction on how to configure the stream in go2rtc.
curl 192.168.1.140:8000
<!DOCTYPE html>
<html>
<head>
<title>Video On Demand</title>
</head>
<body>
<video style='display:block; margin: 0 auto;' id='remoteVideos'></video>
<script>
var pc = new RTCPeerConnection({
iceServers: [{urls: 'stun:stun.l.google.com:19302'}]
});
var log = msg => { console.log(msg); };
function sendOfferToCall(sdp) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
let res = JSON.parse(atob(this.responseText));
console.log(res);
if(res.type == 'answer') {
pc.setRemoteDescription(new RTCSessionDescription(res));
}
}
};
xhttp.open('POST', '/call/webrtc_local');
xhttp.setRequestHeader('Content-Type', 'plain/text');
xhttp.send(btoa(JSON.stringify({'type': 'offer', 'sdp': sdp})));
}
pc.ontrack = function (event) {
var el = document.getElementById('remoteVideos');
el.srcObject = event.streams[0];
el.autoplay = true;
el.controls = true;
el.muted = true;
};
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState);
pc.onicecandidate = event => {
if(event.candidate === null) sendOfferToCall(pc.localDescription.sdp)
};
pc.addTransceiver('video', {'direction': 'sendrecv'})
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log);
</script>
</body>
</html>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request