|
@@ -2,18 +2,19 @@
|
|
|
// wrt + socket + contrl
|
|
// wrt + socket + contrl
|
|
|
const io = require("socket.io-client")
|
|
const io = require("socket.io-client")
|
|
|
const PWM = require('./lib/Pwm')
|
|
const PWM = require('./lib/Pwm')
|
|
|
-const { PeerConnection, Video, RtcpReceivingSession } = require('node-datachannel');
|
|
|
|
|
|
|
+const { PeerConnection, Video } = require('node-datachannel');
|
|
|
const { createSocket } = require('dgram')
|
|
const { createSocket } = require('dgram')
|
|
|
const { spawn } = require('child_process')
|
|
const { spawn } = require('child_process')
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+// const url = 'ws://10.10.3.196:7896'
|
|
|
|
|
+const url = process.argv.splice(2);
|
|
|
class CarServer {
|
|
class CarServer {
|
|
|
constructor() {
|
|
constructor() {
|
|
|
this.Peer = null
|
|
this.Peer = null
|
|
|
this.track = null
|
|
this.track = null
|
|
|
this.child = null
|
|
this.child = null
|
|
|
this.udp = null
|
|
this.udp = null
|
|
|
- this.socket = io('ws://10.10.3.196:7896', { auth: { roomID: "feiCar", name: 'car' } });
|
|
|
|
|
|
|
+ this.socket = io(url, { auth: { roomID: "feiCar", name: 'car' } });
|
|
|
this.socket.on('connect', this.connected.bind(this))
|
|
this.socket.on('connect', this.connected.bind(this))
|
|
|
this.socket.on('msg', this.onMsg.bind(this))
|
|
this.socket.on('msg', this.onMsg.bind(this))
|
|
|
this.socket.on('leaved', this.onLeved.bind(this))
|
|
this.socket.on('leaved', this.onLeved.bind(this))
|
|
@@ -76,7 +77,6 @@ class CarServer {
|
|
|
this.udp.bind(port)
|
|
this.udp.bind(port)
|
|
|
|
|
|
|
|
// video push
|
|
// video push
|
|
|
-
|
|
|
|
|
const args = [
|
|
const args = [
|
|
|
"libcamerasrc",
|
|
"libcamerasrc",
|
|
|
"video/x-raw,width=640,height=480",
|
|
"video/x-raw,width=640,height=480",
|
|
@@ -92,8 +92,6 @@ class CarServer {
|
|
|
// listen UDP
|
|
// listen UDP
|
|
|
this.udp.on("message", (data) => {
|
|
this.udp.on("message", (data) => {
|
|
|
if (!this.track.isOpen()) return
|
|
if (!this.track.isOpen()) return
|
|
|
- console.log(data);
|
|
|
|
|
- this.track.setMediaHandler(new RtcpReceivingSession())
|
|
|
|
|
this.track.sendMessageBinary(data)
|
|
this.track.sendMessageBinary(data)
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -102,4 +100,4 @@ class CarServer {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-new CarServer()
|
|
|
|
|
|
|
+new CarServer(url[0])
|