diff options
author | Christian Franke <nobody@nowhere.ws> | 2014-01-21 02:55:00 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2014-01-21 02:55:00 +0100 |
commit | 2f6e8a407e3b0e17d3f50f0d28ec08cea26778d9 (patch) | |
tree | e8bb936efdc64f840647ac71825b95a95b3e8ca8 |
Initial commit
-rw-r--r-- | cam_public/index.html | 2 | ||||
-rw-r--r-- | noise.jpg | bin | 0 -> 23666 bytes | |||
-rw-r--r-- | noise2.jpg | bin | 0 -> 23653 bytes | |||
-rw-r--r-- | server.js | 39 |
4 files changed, 41 insertions, 0 deletions
diff --git a/cam_public/index.html b/cam_public/index.html new file mode 100644 index 0000000..8bdde6e --- /dev/null +++ b/cam_public/index.html @@ -0,0 +1,2 @@ +<h1>Hello, World!</h1> +<img src="../stream.mjpeg"></img> diff --git a/noise.jpg b/noise.jpg Binary files differnew file mode 100644 index 0000000..d657b3a --- /dev/null +++ b/noise.jpg diff --git a/noise2.jpg b/noise2.jpg Binary files differnew file mode 100644 index 0000000..865a788 --- /dev/null +++ b/noise2.jpg diff --git a/server.js b/server.js new file mode 100644 index 0000000..c887b1f --- /dev/null +++ b/server.js @@ -0,0 +1,39 @@ +var express = require('express'); +var fs = require('fs'); +var MjpegProxy = require('mjpeg-proxy').MjpegProxy; + +var app = express(); + +var cameras = [ + { + url: 'http://admin:123456@192.168.0.117/videostream.cgi?rate=1' + }, + { + url: 'http://admin:123456@192.168.0.178/videostream.cgi?rate=1' + } +]; + +var still_frames = [ + fs.readFileSync(__dirname + '/noise.jpg'), + fs.readFileSync(__dirname + '/noise2.jpg'), +]; + +for (var camera_idx in cameras) { + var camera = cameras[camera_idx]; + camera.proxy = new MjpegProxy(camera.url, still_frames) + app.get('/cam/' + camera_idx + '/stream.mjpeg', camera.proxy.proxyRequest); + app.use('/cam/' + camera_idx + '/browse', + express.static(__dirname + '/cam_public')); +} + +app.get('/blackout', function(req, res) { + for (var camera_idx in cameras) { + var camera = cameras[camera_idx]; + + camera.proxy.on_air = !camera.proxy.on_air; + } + res.send('OK'); +}); + + +app.listen(8080); |