summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cam_public/index.html16
-rw-r--r--server.js57
2 files changed, 67 insertions, 6 deletions
diff --git a/cam_public/index.html b/cam_public/index.html
index 8bdde6e..790efca 100644
--- a/cam_public/index.html
+++ b/cam_public/index.html
@@ -1,2 +1,14 @@
-<h1>Hello, World!</h1>
-<img src="../stream.mjpeg"></img>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8"></meta>
+ <script src="main.js"></script>
+ </head>
+ <body>
+ <img src="../stream.mjpeg"></img><br/>
+ <input type="submit" value="<" id="left"></input>
+ <input type="submit" value="A" id="up"></input>
+ <input type="submit" value="V" id="down"></input>
+ <input type="submit" value=">" id="right"></input>
+ </body>
+</html>
diff --git a/server.js b/server.js
index c887b1f..f8dcd8a 100644
--- a/server.js
+++ b/server.js
@@ -1,15 +1,24 @@
+'use strict';
+
var express = require('express');
var fs = require('fs');
+var request = require('request');
var MjpegProxy = require('mjpeg-proxy').MjpegProxy;
var app = express();
var cameras = [
{
- url: 'http://admin:123456@192.168.0.117/videostream.cgi?rate=1'
+ baseurl: 'http://admin:123456@192.168.0.33',
+ model: 'conceptronic'
+ },
+ {
+ baseurl: 'http://admin:123456@192.168.0.117',
+ model: 'conceptronic'
},
{
- url: 'http://admin:123456@192.168.0.178/videostream.cgi?rate=1'
+ url: 'http://admin:123456@192.168.0.178',
+ model: 'conceptronic'
}
];
@@ -18,12 +27,52 @@ var still_frames = [
fs.readFileSync(__dirname + '/noise2.jpg'),
];
+function SimpleProxy(url) {
+ var self = this;
+
+ self.url = url;
+ self.handle_request = function(req, res) {
+ console.log('Got request. Forwarding to ' + self.url);
+ request(self.url).pipe(res);
+ };
+}
+
for (var camera_idx in cameras) {
var camera = cameras[camera_idx];
- camera.proxy = new MjpegProxy(camera.url, still_frames)
+ var urls = {};
+
+ if (camera.model == 'conceptronic') {
+ urls.mjpeg = camera.baseurl + '/videostream.cgi?rate=1';
+ urls.down = camera.baseurl
+ + '/decoder_control.cgi?onestep=1&command=0';
+ urls.up = camera.baseurl
+ + '/decoder_control.cgi?onestep=1&command=2';
+ urls.right = camera.baseurl
+ + '/decoder_control.cgi?onestep=1&command=4';
+ urls.left = camera.baseurl
+ + '/decoder_control.cgi?onestep=1&command=6';
+ urls.snapshot = camera.baseurl + '/snapshot.cgi';
+ } else if (camera.model == 'mjpegplexer') {
+ urls.mjpeg = camera.baseurl + '/stream.mjpeg';
+ urls.down = camera.baseurl + '/control/down';
+ urls.up = camera.baseurl + '/control/up';
+ urls.right = camera.baseurl + '/control/right';
+ urls.left = camera.baseurl + '/control/left';
+ urls.snapshow = camera.baseurl + '/snapshot.jpg';
+ };
+
+ camera.proxy = new MjpegProxy(urls.mjpeg, still_frames);
app.get('/cam/' + camera_idx + '/stream.mjpeg', camera.proxy.proxyRequest);
+ for (var url in urls) {
+ if (url == 'mjpeg' || url == 'snapshot')
+ continue;
+ app.get('/cam/' + camera_idx + '/control/' + url,
+ new SimpleProxy(urls[url]).handle_request);
+ }
+ app.get('/cam/' + camera_idx + '/snapshot.jpg',
+ new SimpleProxy(urls.snapshot).handle_request);
app.use('/cam/' + camera_idx + '/browse',
- express.static(__dirname + '/cam_public'));
+ express.static(__dirname + '/cam_public'));
}
app.get('/blackout', function(req, res) {