-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample5.js
51 lines (41 loc) · 1.17 KB
/
example5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Created by Andrew D.Laptev<[email protected]> on 1/21/15.
* Edited by Lucas Zanella <[email protected]> on 27/08/17.
* Same as example.json but uses SOCKS5 (useful to access cameras securely through SSH)
*/
var ProxyAgent = require('proxy-agent');
var CAMERA_HOST = '192.168.1.164',
USERNAME = 'admin',
PASSWORD = 'admin',
PORT = 1018,
PROXY_URI = 'socks5://localhost:1234';
var http = require('http'),
Cam = require('./lib/onvif').Cam;
new Cam({
hostname: CAMERA_HOST,
username: USERNAME,
password: PASSWORD,
port: PORT,
agent: new ProxyAgent(PROXY_URI)
}, function(err) {
if (err) {
console.log('Connection Failed for ' + CAMERA_HOST + ' Port: ' + PORT + ' Username: ' + USERNAME + ' Password: ' + PASSWORD);
return;
}
console.log('CONNECTED');
this.absoluteMove({
x: 1
, y: 1
, zoom: 1
});
this.getStreamUri({protocol:'RTSP'}, function(err, stream) {
console.log(stream);
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(
'<html><body>' +
'<embed type="application/x-vlc-plugin" target="' + stream.uri + '"></embed>' +
'</boby></html>');
}).listen(3030);
});
});