Preparation for ONVIF Events (Profile T cameras only)
parent
03c8ae8810
commit
971ecc513a
71
camera.js
71
camera.js
|
@ -27,7 +27,6 @@ try{
|
|||
}catch(err){
|
||||
staticFFmpeg = false;
|
||||
console.log('No Static FFmpeg. Continuing.')
|
||||
//no static ffmpeg
|
||||
}
|
||||
var os = require('os');
|
||||
var URL = require('url');
|
||||
|
@ -54,6 +53,7 @@ var jsonfile = require("jsonfile");
|
|||
var connectionTester = require('connection-tester');
|
||||
var events = require('events');
|
||||
var onvif = require('node-onvif');
|
||||
var onvifHawk = require('onvif-nvt');
|
||||
var knex = require('knex');
|
||||
var Mp4Frag = require('mp4frag');
|
||||
var P2P = require('pipe2pam');
|
||||
|
@ -914,6 +914,8 @@ s.init=function(x,e,k,fn){
|
|||
//build a complete url from pieces
|
||||
e.authd='';
|
||||
if(e.details.muser&&e.details.muser!==''&&e.host.indexOf('@')===-1) {
|
||||
e.username = e.details.muser
|
||||
e.password = e.details.mpass
|
||||
e.authd=e.details.muser+':'+e.details.mpass+'@';
|
||||
}
|
||||
if(e.port==80&&e.details.port_force!=='1'){e.porty=''}else{e.porty=':'+e.port}
|
||||
|
@ -2428,7 +2430,10 @@ s.camera=function(x,e,cn,tx){
|
|||
var monitorConfig = cn
|
||||
URLobject=URL.parse(e)
|
||||
if(monitorConfig.details.control_url_method === 'ONVIF' && monitorConfig.details.control_base_url === ''){
|
||||
URLobject.port = 8000
|
||||
if(monitorConfig.details.onvif_port === ''){
|
||||
monitorConfig.details.onvif_port = 8000
|
||||
}
|
||||
URLobject.port = monitorConfig.details.onvif_port
|
||||
}else if(!URLobject.port){
|
||||
URLobject.port = 80
|
||||
}
|
||||
|
@ -2831,6 +2836,68 @@ s.camera=function(x,e,cn,tx){
|
|||
}
|
||||
}
|
||||
setStreamDir()
|
||||
//try to create HawkEye Onvif Object
|
||||
if(e.details.is_onvif === '1'){
|
||||
console.log('onvifHawk',e.hosty, e.porty.replace(':',''), e.username, e.password)
|
||||
var doOnvifHawk = true
|
||||
var errorCount = 0
|
||||
var hawkFail = function(msg,callback){
|
||||
++errorCount
|
||||
if(errorCount > 2){
|
||||
callback()
|
||||
s.log(e,msg);
|
||||
}
|
||||
}
|
||||
var createHawkOnvif = function(){
|
||||
if(doOnvifHawk === false){
|
||||
return false
|
||||
}
|
||||
if(!e.details.onvif_port || e.details.onvif_port === ''){
|
||||
e.details.onvif_port = 8000
|
||||
}
|
||||
onvifHawk.connect(e.hosty, e.details.onvif_port, e.username, e.password).then(function(results){
|
||||
var camera = results
|
||||
// if the camera supports events, the module will already be loaded.
|
||||
if (camera.events) {
|
||||
camera.events.soap.username = e.username
|
||||
camera.events.soap.password = e.password
|
||||
camera.events.on('messages', messages => {
|
||||
console.log('Messages Received:', (typeof messages))
|
||||
s.log(e,{type:lang.ONVIFEventsNotAvailable,msg:{msg:lang.ONVIFnotCompliantProfileT}});
|
||||
})
|
||||
camera.events.on('messages:error', error => {
|
||||
if(error.body.indexOf('anonymous') > -1){
|
||||
hawkFail({type:lang.ONVIFEventsNotAvailable,msg:{msg:lang.ONVIFnotCompliantProfileT}},function(){
|
||||
camera.events.stopPull()
|
||||
})
|
||||
}
|
||||
})
|
||||
// start a pull event loop
|
||||
setTimeout(function(){
|
||||
camera.events.startPull()
|
||||
},3000)
|
||||
// call stopPull() to end the event loop
|
||||
// camera.events.stopPull()
|
||||
s.group[e.ke].mon[e.id].HawkEyeOnvifConnection = camera
|
||||
}
|
||||
if(s.group[e.ke].mon[e.id].HawkEyeOnvifConnection){
|
||||
console.log('Found')
|
||||
}else{
|
||||
console.log('Not Found')
|
||||
}
|
||||
}).catch(function(err){
|
||||
console.log('Error Connecting')
|
||||
console.log(err.code)
|
||||
hawkFail({type:lang.ONVIFEventsNotAvailable,msg:{msg:lang.ONVIFnotCompliantProfileT}},function(){
|
||||
doOnvifHawk = false
|
||||
})
|
||||
setTimeout(function(){
|
||||
createHawkOnvif()
|
||||
},3000)
|
||||
})
|
||||
}
|
||||
createHawkOnvif()
|
||||
}
|
||||
//set up fatal error handler
|
||||
if(e.details.fatal_max===''){
|
||||
e.details.fatal_max = 10
|
||||
|
|
|
@ -156,6 +156,8 @@
|
|||
"FFmpegTip": "FFprobe is a simple multimedia streams analyzer. You can use it to output all kinds of information about an input including duration, frame rate, frame size, etc.",
|
||||
"Complete Stream URL": "Complete Stream URL",
|
||||
"ONVIF Scanner": "ONVIF Scanner",
|
||||
"ONVIFEventsNotAvailable": "ONVIF Events not Available",
|
||||
"ONVIFnotCompliantProfileT": "Camera is not ONVIF Profile T Compliant",
|
||||
"Scan Settings": "Scan Settings",
|
||||
"ONVIFnote": "Discover ONVIF devices on networks outside your own or leave it blank to scan your current network. <br>Username and Password can be left blank.",
|
||||
"Range or Single": "Range or Single",
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"pipe2pam": "^0.6.2",
|
||||
"nodemailer": "^4.0.1",
|
||||
"node-onvif": "^0.1.4",
|
||||
"onvif-nvt": "0.2.8",
|
||||
"path": "^0.12.7",
|
||||
"request": "^2.79.0",
|
||||
"socket.io": "^1.7.1",
|
||||
|
|
|
@ -180,6 +180,19 @@
|
|||
</select></div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><div><span><%-lang['ONVIF']%></span></div>
|
||||
<div><select class="form-control" detail="is_onvif" selector="h_onvif">
|
||||
<option value="0" selected><%-lang.No%></option>
|
||||
<option value="1"><%-lang.Yes%></option>
|
||||
</select></div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group h_onvif_input h_onvif_1">
|
||||
<label><div><span><%-lang['ONVIF Port']%></span></div>
|
||||
<div><input class="form-control" detail="onvif_port" placeholder="8000" type="number"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END of Connection -->
|
||||
<!-- START of Input -->
|
||||
|
|
Loading…
Reference in New Issue