Additional Extenders

merge-requests/43/head
Moe 2018-12-04 08:34:43 -08:00
parent 23ab10d906
commit c91ce87ec7
4 changed files with 25 additions and 6 deletions

View File

@ -334,6 +334,9 @@
"Control": "Control",
"Grouping": "Grouping <small>Add groups in <b>Settings</b></small>",
"Detector Grouping": "Detector Grouping <small>Add groups in <b>Settings</b></small>",
"Detector Recording Process Exited Prematurely. Restarting.": "Detector Recording Process Exited Prematurely. Restarting.",
"Detector Recording Complete": "Detector Recording Complete",
"Clear Recorder Process": "Clear Recorder Process",
"Logging": "Logging",
"IdentityText1": "This is how the system will identify the data for this stream. You cannot change the <b>Monitor ID</b> once you have pressed save. If you want you can make the <b>Monitor ID</b> more human readable before you continue.",
"IdentityText2": "You can duplicate a monitor by modifying the <b>Monitor ID</b> then pressing save. You <b>cannot</b> use the ID of a monitor that already exists or it will save over that monitor's database information.",

View File

@ -319,6 +319,7 @@ module.exports = function(s,config,lang){
s.tx(d.cx,'DETECTOR_'+d.ke+d.id);
}
s.createEventBasedRecording = function(d){
d.mon = s.group[d.ke].mon_conf[d.id]
var currentConfig = s.group[d.ke].mon[d.id].details
var detector_timeout
if(!currentConfig.detector_timeout||currentConfig.detector_timeout===''){
@ -339,25 +340,25 @@ module.exports = function(s,config,lang){
s.group[d.ke].mon[d.id].eventBasedRecording.allowEnd = false;
var runRecord = function(){
var filename = s.formattedTime()+'.mp4'
s.userLog(d,{type:"Traditional Recording",msg:"Started"})
s.userLog(d,{type:lang["Traditional Recording"],msg:lang["Started"]})
//-t 00:'+s.timeObject(new Date(detector_timeout * 1000 * 60)).format('mm:ss')+'
s.group[d.ke].mon[d.id].eventBasedRecording.process = spawn(config.ffmpegDir,s.splitForFFPMEG(('-loglevel warning -analyzeduration 1000000 -probesize 1000000 -re -i "'+s.dir.streams+'/'+d.ke+'/'+d.id+'/detectorStream.m3u8" -c:v copy -strftime 1 "'+s.getVideoDirectory(d.mon) + filename + '"')))
var ffmpegError='';
var error
s.group[d.ke].mon[d.id].eventBasedRecording.process.stderr.on('data',function(data){
s.userLog(d,{type:"Traditional Recording",msg:data.toString()})
s.userLog(d,{type:lang["Traditional Recording"],msg:data.toString()})
})
s.group[d.ke].mon[d.id].eventBasedRecording.process.on('close',function(){
if(!s.group[d.ke].mon[d.id].eventBasedRecording.allowEnd){
s.userLog(d,{type:"Traditional Recording",msg:"Detector Recording Process Exited Prematurely. Restarting."})
s.userLog(d,{type:lang["Traditional Recording"],msg:lang["Detector Recording Process Exited Prematurely. Restarting."]})
runRecord()
return
}
s.insertCompletedVideo(d.mon,{
file : filename
})
s.userLog(d,{type:"Traditional Recording",msg:"Detector Recording Complete"})
s.userLog(d,{type:"Traditional Recording",msg:'Clear Recorder Process'})
s.userLog(d,{type:lang["Traditional Recording"],msg:lang["Detector Recording Complete"]})
s.userLog(d,{type:lang["Traditional Recording"],msg:lang["Clear Recorder Process"]})
delete(s.group[d.ke].mon[d.id].eventBasedRecording.process)
clearTimeout(s.group[d.ke].mon[d.id].eventBasedRecording.timeout)
delete(s.group[d.ke].mon[d.id].eventBasedRecording.timeout)
@ -373,5 +374,12 @@ module.exports = function(s,config,lang){
s.group[e.ke].mon[e.id].eventBasedRecording.allowEnd = true;
s.group[e.ke].mon[e.id].eventBasedRecording.process.kill('SIGTERM');
}
// var stackedProcesses = s.group[e.ke].mon[e.id].eventBasedRecording.stackable
// Object.keys(stackedProcesses).forEach(function(key){
// var item = stackedProcesses[key]
// clearTimeout(item.timeout)
// item.allowEnd = true;
// item.process.kill('SIGTERM');
// })
}
}

View File

@ -5,6 +5,11 @@ module.exports = function(s,config){
s.onSocketAuthenticationExtensions.push(callback)
}
//
s.loadGroupExtensions = []
s.loadGroupExtender = function(callback){
s.loadGroupExtensions.push(callback)
}
//
s.loadGroupAppExtensions = []
s.loadGroupAppExtender = function(callback){
s.loadGroupAppExtensions.push(callback)

View File

@ -116,6 +116,9 @@ module.exports = function(s,config){
s.tx({f:'log',ke:e.ke,mid:e.mid,log:x,time:s.timeObject()},'GRPLOG_'+e.ke);
}
s.loadGroup = function(e){
s.loadGroupExtensions.forEach(function(extender){
extender(e)
})
if(!s.group[e.ke]){
s.group[e.ke]={}
}
@ -145,7 +148,7 @@ module.exports = function(s,config){
ar=JSON.parse(r.details);
//load extenders
s.loadGroupAppExtensions.forEach(function(extender){
extender(r)
extender(r,ar)
})
//disk Used Emitter
if(!s.group[e.ke].diskUsedEmitter){