Propeliranje, env fajl za IP, popravki, WIP webrtc data xfer

sbc
Jurij Podgoršek 2023-03-20 02:34:49 +01:00
parent cbc1770d43
commit 0d74389113
8 changed files with 166 additions and 83 deletions

2
.env.dist 100644
View File

@ -0,0 +1,2 @@
VIR="http://192.168.64.101"
CILJ="rtp://localhost:8004"

1
.gitignore vendored
View File

@ -1 +1,2 @@
settings.js
.env

View File

@ -1,4 +1,5 @@
#!/bin/bash
VIR="http://192.168.64.104:81"
ffplay $VIR
source .env
ffplay $VIR:81

View File

@ -1,8 +1,7 @@
#!/bin/bash
source .env
# Pretvori MJPEG v VP8 RTP stream
VIR="http://192.168.64.104:81"
CILJ="rtp://localhost:8004"
#ffmpeg -re -stream_loop -1 -i $VIR -c:v libx264 -tune zerolatency -profile:v baseline -b:v 1M -an -f rtp $CILJ
ffmpeg -re -stream_loop -1 -i $VIR -c:v libvpx -b:v 1M -an -f rtp $CILJ
ffmpeg -re -stream_loop -1 -i "$VIR:81" -c:v libvpx -b:v 1M -an -f rtp $CILJ

16
2_vent_vklop.sh 100755
View File

@ -0,0 +1,16 @@
#!/bin/bash
source .env
ventilator=$1
if [[ ! $ventilator ]]; then
echo "Izberi ventilator (1 ali 2 kot parameter)"
exit 0
fi
url="$VIR/?m=1&o=$ventilator"
curl "$url"
sleep 2
curl "$url"

View File

@ -11,6 +11,7 @@
<script type="text/javascript" src="webrtc-adapter.min.js" ></script>
<script type="text/javascript" src="settings.js" ></script>
<script type="text/javascript" src="janus.js" ></script>
<script type="text/javascript" src="propeliraj.js"></script>
<script type="text/javascript" src="streaming.js"></script>
<link rel="stylesheet" href="stil.css" type="text/css"/>

54
propeliraj.js 100644
View File

@ -0,0 +1,54 @@
var BOT="http://192.168.1.101/";
// Koliko milisekund se naj vrtijo propelerji?
var DOLZINA=10000;
function xhttp() {
return new XMLHttpRequest();
}
function cors(xh) {
xh.setRequestHeader('Content-Type', 'application/x-www-form-urlencode');
xh.withCredentials = true;
return xh;
}
function preklopiA() {
var xh = xhttp();
xh.open('GET', BOT + "?m=1&o=1");
return xh;
}
function preklopiB() {
var xh = xhttp();
xh.open('GET', BOT + "?m=1&o=2");
return xh;
}
window.peljiLevo = function () {
var rb = preklopiB();
console.log('lev?', rb);
rb.send();
console.log(streaming);
setTimeout(function () {
var rb = preklopiB();
rb.send();
}, DOLZINA);
}
window.peljiDesno = function () {
var ra = preklopiA();
ra.send();
setTimeout(function () {
var ra = preklopiA();
ra.send();
}, DOLZINA);
}
window.peljiRavno = function () {
window.peljiLevo();
window.peljiDesno();
}

View File

@ -33,7 +33,7 @@ window.addEventListener('DOMContentLoaded', function () {
Janus.init({debug: "all", callback: function() {
// Make sure the browser supports WebRTC
if(!Janus.isWebrtcSupported()) {
bootbox.alert("No WebRTC support... ");
console.log("ERROR cannot start; no WebRTC support... ");
return;
}
// Create session
@ -79,6 +79,7 @@ window.addEventListener('DOMContentLoaded', function () {
// Gumbi levo in desno
gLevo.addEventListener('click', function () {
console.log('GREMO LEVO!');
window.peljiLevo();
vsiGumbi.forEach(function (gEl) {
gEl.toggleAttribute('disabled', true);
});
@ -91,6 +92,7 @@ window.addEventListener('DOMContentLoaded', function () {
});
gDesno.addEventListener('click', function () {
console.log('GREMO DESNO!');
window.peljiDesno();
vsiGumbi.forEach(function (gEl) {
gEl.toggleAttribute('disabled', true);
});
@ -103,6 +105,7 @@ window.addEventListener('DOMContentLoaded', function () {
});
gRavno.addEventListener('click', function () {
console.log('GREMO RAVNO!');
window.peljiRavno();
vsiGumbi.forEach(function (gEl) {
gEl.toggleAttribute('disabled', true);
});
@ -240,10 +243,12 @@ window.addEventListener('DOMContentLoaded', function () {
},
ondataopen: function(data) {
Janus.log("The DataChannel is available!");
window.dataKanal = data;
},
ondata: function(data) {
Janus.debug("We got data from the DataChannel!", data);
console.log('DUBU DATA', data);
obdelajData(data);
},
oncleanup: function() {
Janus.log(" ::: Got a cleanup notification :::");
@ -353,3 +358,7 @@ function stopStream() {
streaming.send({ message: body });
streaming.hangup();
}
function obdelajData(data) {
console.log('obdelam webrtc podatke', data);
}