parent
e89ad75f71
commit
df74cef008
|
@ -2,6 +2,10 @@ var os = require('os');
|
|||
var exec = require('child_process').exec;
|
||||
const onvif = require("shinobi-onvif");
|
||||
module.exports = function(s,config,lang,app,io){
|
||||
const {
|
||||
createSnapshot,
|
||||
addCredentialsToStreamLink,
|
||||
} = require('../monitor/utils.js')(s,config,lang)
|
||||
const createOnvifDevice = async (onvifAuth) => {
|
||||
var response = {ok: false}
|
||||
const monitorConfig = s.group[onvifAuth.ke].rawMonitorConfigurations[onvifAuth.id]
|
||||
|
@ -118,6 +122,16 @@ module.exports = function(s,config,lang,app,io){
|
|||
doAction(s.group[onvifAuth.ke].activeMonitors[onvifAuth.id].onvifConnection)
|
||||
}
|
||||
}
|
||||
async function getSnapshotFromOnvif(onvifOptions){
|
||||
return await createSnapshot({
|
||||
output: ['-s 400x400'],
|
||||
url: addCredentialsToStreamLink({
|
||||
username: onvifOptions.username,
|
||||
password: onvifOptions.password,
|
||||
url: onvifOptions.uri
|
||||
}),
|
||||
})
|
||||
}
|
||||
/**
|
||||
* API : ONVIF Method Controller
|
||||
*/
|
||||
|
@ -140,6 +154,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
})
|
||||
},res,req);
|
||||
})
|
||||
s.getSnapshotFromOnvif = getSnapshotFromOnvif
|
||||
s.createOnvifDevice = createOnvifDevice
|
||||
s.runOnvifMethod = runOnvifMethod
|
||||
}
|
||||
|
|
|
@ -500,9 +500,12 @@ module.exports = function(s,config,lang){
|
|||
s.checkDetails(e)
|
||||
if(e.ke && config.doSnapshot === true){
|
||||
if(s.group[e.ke] && s.group[e.ke].rawMonitorConfigurations && s.group[e.ke].rawMonitorConfigurations[e.mid] && s.group[e.ke].rawMonitorConfigurations[e.mid].mode !== 'stop'){
|
||||
var pathDir = s.dir.streams+e.ke+'/'+e.mid+'/'
|
||||
const {screenShot, isStaticFile} = await s.getRawSnapshotFromMonitor(s.group[e.ke].rawMonitorConfigurations[e.mid],options)
|
||||
if(screenShot){
|
||||
if(s.group[e.ke].activeMonitors[e.mid].onvifConnection){
|
||||
const screenShot = await s.getSnapshotFromOnvif({
|
||||
username: onvifUsername,
|
||||
password: onvifPassword,
|
||||
uri: cameraResponse.uri,
|
||||
});
|
||||
s.tx({
|
||||
f: 'monitor_snapshot',
|
||||
snapshot: screenShot.toString('base64'),
|
||||
|
@ -511,9 +514,21 @@ module.exports = function(s,config,lang){
|
|||
ke: e.ke
|
||||
},'GRP_'+e.ke)
|
||||
}else{
|
||||
s.debugLog('Damaged Snapshot Data')
|
||||
s.tx({f:'monitor_snapshot',snapshot:e.mon.name,snapshot_format:'plc',mid:e.mid,ke:e.ke},'GRP_'+e.ke)
|
||||
}
|
||||
var pathDir = s.dir.streams+e.ke+'/'+e.mid+'/'
|
||||
const {screenShot, isStaticFile} = await s.getRawSnapshotFromMonitor(s.group[e.ke].rawMonitorConfigurations[e.mid],options)
|
||||
if(screenShot){
|
||||
s.tx({
|
||||
f: 'monitor_snapshot',
|
||||
snapshot: screenShot.toString('base64'),
|
||||
snapshot_format: 'b64',
|
||||
mid: e.mid,
|
||||
ke: e.ke
|
||||
},'GRP_'+e.ke)
|
||||
}else{
|
||||
s.debugLog('Damaged Snapshot Data')
|
||||
s.tx({f:'monitor_snapshot',snapshot:e.mon.name,snapshot_format:'plc',mid:e.mid,ke:e.ke},'GRP_'+e.ke)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
s.tx({f:'monitor_snapshot',snapshot:'Disabled',snapshot_format:'plc',mid:e.mid,ke:e.ke},'GRP_'+e.ke)
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@ const {
|
|||
stringContains,
|
||||
} = require('../common.js')
|
||||
module.exports = (s,config,lang) => {
|
||||
const {
|
||||
createSnapshot,
|
||||
addCredentialsToStreamLink,
|
||||
} = require('../monitor/utils.js')(s,config,lang)
|
||||
const ipRange = (start_ip, end_ip) => {
|
||||
var startLong = toLong(start_ip);
|
||||
var endLong = toLong(end_ip);
|
||||
|
@ -148,13 +144,10 @@ module.exports = (s,config,lang) => {
|
|||
var imageSnap
|
||||
if(cameraResponse.uri){
|
||||
try{
|
||||
imageSnap = (await createSnapshot({
|
||||
output: ['-s 400x400'],
|
||||
url: addCredentialsToStreamLink({
|
||||
username: onvifUsername,
|
||||
password: onvifPassword,
|
||||
url: cameraResponse.uri
|
||||
}),
|
||||
imageSnap = (await s.getSnapshotFromOnvif({
|
||||
username: onvifUsername,
|
||||
password: onvifPassword,
|
||||
uri: cameraResponse.uri,
|
||||
})).toString('base64');
|
||||
}catch(err){
|
||||
s.debugLog(err)
|
||||
|
|
|
@ -302,7 +302,13 @@ module.exports = function(s,config,lang,app){
|
|||
}
|
||||
}else{
|
||||
if(!user.details.sub || user.details.allmonitors === '1' || user.details.monitor_edit.indexOf(req.params.id) > -1 || hasRestrictions && user.details.monitor_create === '1'){
|
||||
s.userLog(s.group[req.params.ke].rawMonitorConfigurations[req.params.id],{type:'Monitor Deleted',msg:'by user : '+user.uid});
|
||||
s.userLog({
|
||||
ke: req.params.ke,
|
||||
mid: req.params.id
|
||||
},{
|
||||
type: 'Monitor Deleted',
|
||||
msg: 'by user : '+user.uid
|
||||
});
|
||||
req.params.delete=1;s.camera('stop',req.params);
|
||||
s.tx({f:'monitor_delete',uid:user.uid,mid:req.params.id,ke:req.params.ke},'GRP_'+req.params.ke);
|
||||
s.knexQuery({
|
||||
|
|
Loading…
Reference in New Issue