2016-07-26 18:25:18 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var util = require('util');
|
|
|
|
|
|
|
|
var helpers = require('./helpers');
|
|
|
|
var BaseHTTPStreamProcessor = require('./basehttpstreamprocessor');
|
|
|
|
|
|
|
|
function HTTPRawProcessor()
|
|
|
|
{
|
|
|
|
BaseHTTPStreamProcessor.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
util.inherits(HTTPRawProcessor, BaseHTTPStreamProcessor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HTTPRawProcessor.prototype.run = function()
|
|
|
|
{
|
2016-08-07 08:05:18 +00:00
|
|
|
this.filename = helpers.createVariableFilename(this.cam.options.filename, this.now,
|
2016-07-26 18:25:18 +00:00
|
|
|
{
|
|
|
|
camId: this.camId
|
2016-08-07 08:05:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.tempFilename = this.filename + '.recording';
|
|
|
|
this.output = fs.createWriteStream(this.tempFilename);
|
2016-07-26 18:25:18 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2016-08-07 08:05:18 +00:00
|
|
|
|
|
|
|
fs.rename(this.tempFilename, this.filename, function(err)
|
|
|
|
{
|
|
|
|
console.log('Error: could not move ' + this.tempFilename + ' to ' + this.filename + ': ' + err.message);
|
|
|
|
});
|
2016-07-26 18:25:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HTTPRawProcessor;
|