From 2f6e8a407e3b0e17d3f50f0d28ec08cea26778d9 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 21 Jan 2014 02:55:00 +0100 Subject: Initial commit --- cam_public/index.html | 2 ++ noise.jpg | Bin 0 -> 23666 bytes noise2.jpg | Bin 0 -> 23653 bytes server.js | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 cam_public/index.html create mode 100644 noise.jpg create mode 100644 noise2.jpg create mode 100644 server.js 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 @@ +

Hello, World!

+ diff --git a/noise.jpg b/noise.jpg new file mode 100644 index 0000000..d657b3a Binary files /dev/null and b/noise.jpg differ diff --git a/noise2.jpg b/noise2.jpg new file mode 100644 index 0000000..865a788 Binary files /dev/null and b/noise2.jpg differ 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); -- cgit v1.2.1