diff --git a/web-service/public/js/bundle.js b/web-service/public/js/bundle.js index d260a3145086387df1d1e9b871bf4fb820bb6210..5629c0f18acd7468f526c70044388327abe9ca28 100644 --- a/web-service/public/js/bundle.js +++ b/web-service/public/js/bundle.js @@ -28,7 +28,7 @@ checkIfLoggedIn = async () => { // //Token is valid, show available streams // if(response.status === 200){ // console.log("SUCCESS") - renderThumbnails() + renderThumbnails() // } // } @@ -56,7 +56,7 @@ getAvailableStreams = async () => { createVideoPlayer = () => { const containerDiv = document.getElementById('container') - containerDiv.innerHTML = `<h1>Stream ${current_data.uri} is live right here!</h1><br><button onclick="renderThumbnails(); closeStream()">Go back</button><br> + containerDiv.innerHTML = `<h1>Stream ${current_data.uri} is live right here!</h1><br><button onclick="renderThumbnails(); closeStream()">Go back</button> <button onclick="connectToStream()">Start Stream</button><br> <canvas id="ftlab-stream-video" width="640" height="360"></canvas>`; containerDiv.innerHTML += '<br>' containerDiv.innerHTML += '' @@ -320,7 +320,7 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { var decode = function(pckg) { if (!that.running) { return; } - console.log("PACKAGE", pckg) + // console.log("PACKAGE", pckg) var err; if (pckg == null) { return; @@ -328,14 +328,12 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { try { var tmp = pckg err = decoder.push_data(tmp); - console.log("ERR VALUE INSIDE TRY", err, tmp) } catch(e) { console.log(e); err = decoder.flush(); return; } } - console.log("ERR VALUE AFTER ELSE", err) if (!libde265.de265_isOK(err)) { that._set_error(err, libde265.de265_get_error_text(err)); return; @@ -357,10 +355,10 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { * to number 13 which is the case number for waiting for input data */ decoder.decode(function(cbErr) { - console.log("paramErr SHOULD BE 0, BUT IT'S", cbErr) + // console.log("paramErr SHOULD BE 0, BUT IT'S", cbErr) switch(cbErr) { case libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA: - console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA"); + // console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA"); return; default: if (!libde265.de265_isOK(cbErr)) { @@ -370,20 +368,19 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { } if (decoder.has_more()) { - console.log("has more"); + // console.log("has more"); return; } decoder.free(); that.stop(); - console.log("SHOULD LOG THIS"); + // console.log("SHOULD LOG THIS"); }); } peer.bind(decodedURI, (latency, streampckg, pckg) => { - console.log(pckg[0]) - if(pckg[0] === 0){ + if(pckg[0] === 3){ decode(pckg[5]); }; }) @@ -4772,9 +4769,10 @@ const kDisconnected = 3; // Generate a unique id for this webservice let cpp_my_uuid = uuidv4(); console.log(cpp_my_uuid) -let my_uuid = uuidParser.parse(uuidv4()) -my_uuid = new Uint8Array(cpp_my_uuid); +let my_uuid = uuidParser.parse(cpp_my_uuid) +my_uuid = new Uint8Array(my_uuid); // my_uuid[0] = 44; +// console.log(my_uuid) my_uuid = Buffer.from(my_uuid); const kMagic = 0x0009340053640912; @@ -4815,7 +4813,7 @@ function Peer(ws) { } } if (msg[0] == 0) { - console.log("MSG", msg[1]); + // console.log("MSG...", msg[2]); // Notification if (msg.length == 3) { this._dispatchNotification(msg[1], msg[2]); @@ -4868,6 +4866,7 @@ function Peer(ws) { this.close(); } }); + console.log("MY_UUID", my_uuid) this.send("__handshake__", kMagic, kVersion, [my_uuid]); } @@ -4890,6 +4889,7 @@ Peer.prototype._dispatchNotification = function(name, args) { * @private */ Peer.prototype._dispatchCall = function(name, id, args) { + console.log("DISPATCHCALL", name, id, args) if (this.bindings.hasOwnProperty(name)) { //console.log("Call for:", name, id); @@ -4897,7 +4897,7 @@ Peer.prototype._dispatchCall = function(name, id, args) { let res = this.bindings[name].apply(this, args); this.sock.send(encode([1,id,name,res])); } catch(e) { - console.error("Could to dispatch or return call"); + console.error("Could to dispatch or return call", e); this.close(); } } else if (this.proxies.hasOwnProperty(name)) { @@ -4906,6 +4906,7 @@ Peer.prototype._dispatchCall = function(name, id, args) { try { this.sock.send(encode([1,id,name,res])); } catch(e) { + console.log("ERROR") this.close(); } }); @@ -5039,12 +5040,8 @@ Peer.prototype.on = function(evt, f) { Peer.prototype.getUuid = function() { const digits = "0123456789abcdef"; let uuid = ""; - - //If the char is "-" add it, else add the letter/digit represented in the variable digits - for(let i=0; i<cpp_my_uuid.length; i++){ - uuid += (cpp_my_uuid[i] == "-") ? "-" : digits[digits.indexOf(cpp_my_uuid[i])] - } - return uuid; + + return cpp_my_uuid; } module.exports = Peer; diff --git a/web-service/public/js/index.js b/web-service/public/js/index.js index 4b774b12552a8a9d32473f91647d669e81cd4ce8..ed99d81286221f7cedd4a557242356e129715292 100644 --- a/web-service/public/js/index.js +++ b/web-service/public/js/index.js @@ -27,7 +27,7 @@ checkIfLoggedIn = async () => { // //Token is valid, show available streams // if(response.status === 200){ // console.log("SUCCESS") - renderThumbnails() + renderThumbnails() // } // } @@ -55,7 +55,7 @@ getAvailableStreams = async () => { createVideoPlayer = () => { const containerDiv = document.getElementById('container') - containerDiv.innerHTML = `<h1>Stream ${current_data.uri} is live right here!</h1><br><button onclick="renderThumbnails(); closeStream()">Go back</button><br> + containerDiv.innerHTML = `<h1>Stream ${current_data.uri} is live right here!</h1><br><button onclick="renderThumbnails(); closeStream()">Go back</button> <button onclick="connectToStream()">Start Stream</button><br> <canvas id="ftlab-stream-video" width="640" height="360"></canvas>`; containerDiv.innerHTML += '<br>' containerDiv.innerHTML += '' diff --git a/web-service/public/js/lib/VideoPlayer.js b/web-service/public/js/lib/VideoPlayer.js index 0bea1f4ddbea1702e028938049adafaf5a6f02f5..36514e27f207d9b15d5c408b919965d1728eb1eb 100644 --- a/web-service/public/js/lib/VideoPlayer.js +++ b/web-service/public/js/lib/VideoPlayer.js @@ -105,7 +105,7 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { var decode = function(pckg) { if (!that.running) { return; } - console.log("PACKAGE", pckg) + // console.log("PACKAGE", pckg) var err; if (pckg == null) { return; @@ -113,14 +113,12 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { try { var tmp = pckg err = decoder.push_data(tmp); - console.log("ERR VALUE INSIDE TRY", err, tmp) } catch(e) { console.log(e); err = decoder.flush(); return; } } - console.log("ERR VALUE AFTER ELSE", err) if (!libde265.de265_isOK(err)) { that._set_error(err, libde265.de265_get_error_text(err)); return; @@ -142,10 +140,10 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { * to number 13 which is the case number for waiting for input data */ decoder.decode(function(cbErr) { - console.log("paramErr SHOULD BE 0, BUT IT'S", cbErr) + // console.log("paramErr SHOULD BE 0, BUT IT'S", cbErr) switch(cbErr) { case libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA: - console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA"); + // console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA"); return; default: if (!libde265.de265_isOK(cbErr)) { @@ -155,20 +153,19 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) { } if (decoder.has_more()) { - console.log("has more"); + // console.log("has more"); return; } decoder.free(); that.stop(); - console.log("SHOULD LOG THIS"); + // console.log("SHOULD LOG THIS"); }); } peer.bind(decodedURI, (latency, streampckg, pckg) => { - console.log(pckg[0]) - if(pckg[0] === 0){ + if(pckg[0] === 3){ decode(pckg[5]); }; }) diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js index 1f414cb1e71df0add7570953dfff7e6745a975d6..9a798b9b4d1fec87ca565d0e63d24548fe40c3bb 100644 --- a/web-service/server/src/index.js +++ b/web-service/server/src/index.js @@ -126,7 +126,7 @@ RGBDStream.prototype.subscribe = function() { //console.log("Subscribe to ", this.uri); // TODO: Don't hard code 9 here, instead use 9 for thumbnails and 0 for // the video... - this.peer.send("get_stream", this.uri, 10, 9, [Peer.uuid], this.uri); + this.peer.send("get_stream", this.uri, 10, 3, [Peer.uuid], this.uri); } RGBDStream.prototype.pushFrames = function(latency, spacket, packet) { @@ -191,7 +191,7 @@ app.get('/streams', (req, res) => { app.get('/stream/rgb', (req, res) => { let uri = req.query.uri; if (uri_data.hasOwnProperty(uri)) { - uri_data[uri].peer.send("get_stream", uri, 3, 9, [Peer.uuid], uri); + uri_data[uri].peer.send("get_stream", uri, 3, 0, [Peer.uuid], uri); res.writeHead(200, {'Content-Type': 'image/jpeg'}); res.end(uri_data[uri].rgb); } @@ -458,12 +458,17 @@ app.ws('/', (ws, req) => { }); /** - * Get configuration JSON values + * Get JSON values for stream configuration */ p.bind("get_cfg", (cb, uri) => { - let peer = uri_data[uri].peer - if(peer){ - peer.rpc("get_cfg", cb, uri) + if(uri_data[uri]){ + let peer = uri_data[uri].peer + if(peer){ + peer.rpc("get_cfg", cb, uri) + } + }else{ + console.log("Config not found", uri) + return "{}"; } }) diff --git a/web-service/server/src/peer.js b/web-service/server/src/peer.js index 1c2ff1505c51cdde0987863ba71eb95b05be8718..856222ad8319d839d6fbcf884bf13926adf996b0 100644 --- a/web-service/server/src/peer.js +++ b/web-service/server/src/peer.js @@ -11,9 +11,10 @@ const kDisconnected = 3; // Generate a unique id for this webservice let cpp_my_uuid = uuidv4(); console.log(cpp_my_uuid) -let my_uuid = uuidParser.parse(uuidv4()) -my_uuid = new Uint8Array(cpp_my_uuid); +let my_uuid = uuidParser.parse(cpp_my_uuid) +my_uuid = new Uint8Array(my_uuid); // my_uuid[0] = 44; +// console.log(my_uuid) my_uuid = Buffer.from(my_uuid); const kMagic = 0x0009340053640912; @@ -54,7 +55,7 @@ function Peer(ws) { } } if (msg[0] == 0) { - console.log("MSG", msg[1]); + // console.log("MSG...", msg[2]); // Notification if (msg.length == 3) { this._dispatchNotification(msg[1], msg[2]); @@ -107,6 +108,7 @@ function Peer(ws) { this.close(); } }); + console.log("MY_UUID", my_uuid) this.send("__handshake__", kMagic, kVersion, [my_uuid]); } @@ -129,6 +131,7 @@ Peer.prototype._dispatchNotification = function(name, args) { * @private */ Peer.prototype._dispatchCall = function(name, id, args) { + console.log("DISPATCHCALL", name, id, args) if (this.bindings.hasOwnProperty(name)) { //console.log("Call for:", name, id); @@ -136,7 +139,7 @@ Peer.prototype._dispatchCall = function(name, id, args) { let res = this.bindings[name].apply(this, args); this.sock.send(encode([1,id,name,res])); } catch(e) { - console.error("Could to dispatch or return call"); + console.error("Could to dispatch or return call", e); this.close(); } } else if (this.proxies.hasOwnProperty(name)) { @@ -145,6 +148,7 @@ Peer.prototype._dispatchCall = function(name, id, args) { try { this.sock.send(encode([1,id,name,res])); } catch(e) { + console.log("ERROR") this.close(); } }); @@ -278,12 +282,8 @@ Peer.prototype.on = function(evt, f) { Peer.prototype.getUuid = function() { const digits = "0123456789abcdef"; let uuid = ""; - - //If the char is "-" add it, else add the letter/digit represented in the variable digits - for(let i=0; i<cpp_my_uuid.length; i++){ - uuid += (cpp_my_uuid[i] == "-") ? "-" : digits[digits.indexOf(cpp_my_uuid[i])] - } - return uuid; + + return cpp_my_uuid; } module.exports = Peer; diff --git a/web-service/server/src/utils/config.js b/web-service/server/src/utils/config.js index 546dd8d2fa3b29d9e19e137121d94af9deeb86a4..076d2550007919fd55c67f67a7c2e4e90ebcf588 100644 --- a/web-service/server/src/utils/config.js +++ b/web-service/server/src/utils/config.js @@ -1,5 +1,5 @@ module.exports = { //This needs to be changed, //Currently linked to Sami's mongo-atlas account - MONGODB_URI: 'mongodb+srv://ftl:sOgIX%2638@FTL-w141e.mongodb.net/FTL?retryWrites=true&w=majority' + MONGODB_URI: '' //Add the mongo URI here } \ No newline at end of file