1
0
mirror of synced 2024-11-16 19:13:49 +00:00
SecurityCam.js/processor-http-raw.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

var fs = require('fs');
var util = require('util');
var helpers = require('./helpers');
var logger = require('./logger');
var BaseHTTPStreamProcessor = require('./basehttpstreamprocessor');
function HTTPRawProcessor()
{
BaseHTTPStreamProcessor.apply(this, arguments);
}
util.inherits(HTTPRawProcessor, BaseHTTPStreamProcessor);
HTTPRawProcessor.prototype.run = function()
{
this.filename = helpers.createVariableFilename(this.cam.options.filename, this.now,
{
camId: this.camId
});
this.tempFilename = this.filename + '.recording';
this.output = fs.createWriteStream(this.tempFilename);
HTTPRawProcessor.super_.prototype.run.call(this);
}
HTTPRawProcessor.prototype.getStream = function()
{
return this.output;
}
module.exports = HTTPRawProcessor;
HTTPRawProcessor.prototype.cleanup = function()
{
if (this.output !== null)
{
this.output.end();
this.output = null;
}
fs.rename(this.tempFilename, this.filename, function(err)
{
2016-08-07 09:12:39 +00:00
if (err)
logger.error('Could not move ' + this.tempFilename + ' to ' + this.filename + ': ' + err);
});
}
module.exports = HTTPRawProcessor;