diff options
author | Philippe Rene <prene035@gmail.com> | 2010-09-07 17:35:51 -0400 |
---|---|---|
committer | Philippe Rene <prene035@gmail.com> | 2010-09-07 17:35:51 -0400 |
commit | a560e54bd44017d0e9286e1e08134309aac27780 (patch) | |
tree | 2ea158178c4e63ebe78ff2f7ede21d6c9e5e0f87 | |
parent | 62e0433758133e8298c1d50a565e9fb4c7d286d9 (diff) |
Added core of the mjpeg proxy, need to be reworked on this is just a working prototype
-rw-r--r-- | node-mjpeg-proxy.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/node-mjpeg-proxy.js b/node-mjpeg-proxy.js new file mode 100644 index 0000000..84f6a07 --- /dev/null +++ b/node-mjpeg-proxy.js @@ -0,0 +1,114 @@ +/************************** +TODO: +1. better passing of the headers +2. Make in modular +3. Write it modular so it can be dynamically set for cam creds +**************************/ + +var http = require('http'); +var sys = require('sys'); +// port of the cam +var cam = http.createClient(80, '192.168.1.186'); +var allHttpClient = []; +// Starting the stream on the cam +var request = cam.request('GET', '/axis-cgi/mjpg/video.cgi?fps=5', + {'host': '192.168.1.186', + 'Authorization': "Basic ZnFubWFveGJtb3A6MTAyMzc3"}); +request.end(); +request.on('response', function (response) { + response.setEncoding('binary'); + response.on('data', function (chunk) { + + for(i=0; i < allHttpClient.length; i++) + { + allHttpClient[i].write(chunk, 'binary'); + } + + }); + +}); +var testServer = http.createServer(); + +testServer.on('request', function (req, res){ + res.writeHead(200, {"cache-control":"no-cache","pragma":"no-cache","expires":"Thu, 01 Dec 1994 16:00:00 GMT","content-type":"multipart/x-mixed-replace; boundary=myboundary"}); + allHttpClient.push(res); +}); + +testServer.listen(5080, "0.0.0.0"); +sys.puts('Server started on port 5080'); + + + + + + + + + + + + + + + + + + + + + + + + + + + +/************************* +DEPRECATED SHIT +*************************/ +/******** READ AN IMAGE AND SEND IT ON CONNECTION *********/ +//var image = fs.readFileSync('/home/prene/Desktop/hotmail.png', 'binary', function(err, data){ +// sys.puts("yep gone through"); +// if(err) throw err; +// +// return data; +// }); + +//var server = http.createServer(function (req, res) { + +// res.writeHead(200, { "Content-Type": "text/jpg" +// , "Content-Length": image.length +// }); +// +// res.end(image, 'binary'); + +// +//}).listen(7878, "0.0.0.0"); + +/**** // *******/ + + +/************ STORE ALL SOCKETS CONNECTING *****************/ + +//sockets = []; +// + +//net.createServer(function (socket) { + +// socket.setEncoding("utf8"); +// socket.addListener("connect", function () { +// console.log("Connected"); +// +// }); + +// socket.addListener("end", function () { +// socket.end(); +// +// }); + +// sockets.push(socket); + +//}).listen(port, "0.0.0.0"); +//sys.puts("Server TCP listening on 127.0.0.1 on port: " + port); + +/************ // ********/ |