Skip to content

Commit

Permalink
Cleanups
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 Apr 13, 2016
1 parent d1f6e61 commit 2384531
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
33 changes: 11 additions & 22 deletions lib/camera.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Dependencies: Built-in
var cp = require('child_process');
var Emitter = require('events').EventEmitter;
var fs = require('fs');

var Emitter = require('events').EventEmitter;
var Readable = require('stream').Readable;
// Dependencies: Internal
var CaptureStream = require('./capture-stream');

// Program Specific
var priv = new Map();

function scale(value, fromLow, fromHigh, toLow, toHigh) {
Expand All @@ -15,17 +18,6 @@ function constrain(value, lower, upper) {
return Math.min(upper, Math.max(lower, value));
}

function CaptureStream() {
Readable.call(this);
this._read = function() {};
}

CaptureStream.prototype = Object.create(Readable.prototype, {
constructor: {
value: CaptureStream
}
});

var cameraDefaults = {
width: 320,
height: 240,
Expand Down Expand Up @@ -70,17 +62,18 @@ function Camera(options) {
};

priv.set(this, state);

Object.defineProperties(this, {
isStreaming: {
get: () => state.isStreaming,
},
});
}

Camera.prototype = Object.create(Emitter.prototype, {
constructor: {
value: Camera
},
isStreaming: {
get: function() {
return priv.get(this).isStreaming;
}
}
});

Camera.prototype.stop = function() {
Expand Down Expand Up @@ -260,7 +253,3 @@ Camera.prototype.stop = function() {


module.exports = Camera;

if (global.IS_TEST_ENV) {
module.exports.CaptureStream = CaptureStream;
}
15 changes: 15 additions & 0 deletions lib/capture-stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var Readable = require('stream').Readable;

function CaptureStream() {
Readable.call(this);
this._read = function() {};
}

CaptureStream.prototype = Object.create(Readable.prototype, {
constructor: {
value: CaptureStream
}
});


module.exports = CaptureStream;
6 changes: 4 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Dependencies: Built-in
var cp = require('child_process');
var Emitter = require('events').EventEmitter;
var path = require('path');

var Emitter = require('events').EventEmitter;
var priv = new WeakMap();

// Program Specific
var priv = new WeakMap();

function toSeconds(time) {
if (typeof time === 'number') {
Expand Down
7 changes: 4 additions & 3 deletions test/common/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.IS_TEST_ENV = true;

// System Objects
// Dependencies: Built-in
global.cp = require('child_process');
global.events = require('events');
global.fs = require('fs');
Expand All @@ -13,12 +13,13 @@ global.Readable = stream.Readable;
global.Writable = stream.Writable;


// Third Party
// Dependencies: Third Party
global.sinon = require('sinon');


// Module
// Dependencies: Internal
global.av = require('../../lib/index');
global.CaptureStream = require('../../lib/capture-stream');
global.Camera = require('../../lib/camera');
global.Player = require('../../lib/player');
global.Speaker = require('../../lib/speaker');
Expand Down
2 changes: 0 additions & 2 deletions test/unit/camera.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var CaptureStream = Camera.CaptureStream;

exports['av.Camera'] = {
setUp: function(done) {
this.sandbox = sinon.sandbox.create();
Expand Down

0 comments on commit 2384531

Please sign in to comment.