Skip to content

Commit

Permalink
Camera: further simplication
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Mar 17, 2016
1 parent 31ffce0 commit acff491
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions lib/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ CaptureStream.prototype = Object.create(Readable.prototype, {
}
});

var cameraDefaults = {
width: 320,
height: 240,
// 0-1 fractional percent. 1 => best, 0 => worst.
// maps to: ffmpeg -q:v 1-30 (Lower number is better)
quality: 1,
path: '/dev/video0',
stream: false,
pipe: true,
};

function Camera(options) {
Emitter.call(this);

options = options || {};

if (typeof options.stream === 'undefined') {
options.stream = false;
}

if (typeof options.pipe === 'undefined') {
options.pipe = true;
}
options = Object.assign({}, cameraDefaults, options || {});

var state = {
isStreaming: false,
Expand Down Expand Up @@ -180,18 +183,7 @@ Camera.prototype.stream = function() {
});
};

var cameraDefaults = {
width: 320,
height: 240,
// 0-1 fractional percent. 1 => best, 0 => worst.
// maps to: ffmpeg -q:v 1-30 (Lower number is better)
quality: 1,
path: '/dev/video0',
};

module.exports = function(options) {
return new Camera(Object.assign({}, cameraDefaults, options || {}));
};
module.exports = Camera;

if (global.IS_TEST_ENV) {
module.exports.CaptureStream = CaptureStream;
Expand Down

0 comments on commit acff491

Please sign in to comment.