Comparing version 0.2.0 to 0.2.1
@@ -22,5 +22,5 @@ var request = require("request"); | ||
var username = "admin"; | ||
var password = "password"; | ||
var password = "sweety"; | ||
var options = { | ||
url: "http://192.168.1.5/videostream.cgi", | ||
url: "http://192.168.7.6/videostream.cgi", | ||
headers: { | ||
@@ -27,0 +27,0 @@ 'Authorization': 'Basic ' + new Buffer(username + ':' + password).toString('base64') |
@@ -1,1 +0,2 @@ | ||
module.exports = require('./lib/motion'); | ||
module.exports.Motion = require('./lib/motion'); | ||
module.exports.Stream = require('./lib/motionstream'); |
var Motion = require('./motion'); | ||
var decode = require('im-decode'); | ||
var TimedQueue = require('ttq'); | ||
var util = require('util'); | ||
@@ -35,4 +36,10 @@ function MotionStream(options) { | ||
}; | ||
require('util').inherits(MotionStream, require('stream')); | ||
util.inherits(MotionStream, require('stream')); | ||
/** | ||
* TimeTestQueue test callback to determine whether motion was found | ||
* in the array of frames | ||
* @param {Array.<Object>} frames | ||
* @param {Function(Boolean)} done | ||
*/ | ||
MotionStream.prototype.queueTest = function(frames, done) { | ||
@@ -49,2 +56,6 @@ if (!frames || frames.length < 1) { | ||
/** | ||
* On TimeTestQueue fail, cache frames as the prebuffer | ||
* @param {Array.<Object>} frames | ||
*/ | ||
MotionStream.prototype.queueFail = function(frames) { | ||
@@ -55,9 +66,20 @@ if (this.postBuffering()) { | ||
this.preframes.unshift(frames); | ||
this.preframes = this.preframes.slice(0, | ||
Math.max(Math.floor(this.prebuf*1000 / this.interval), 1)); | ||
this.preframes = this.preframes.slice(0, this.prebufferCap()); | ||
} | ||
}; | ||
/** | ||
* Get the prebuffer size | ||
* @return {Number} | ||
*/ | ||
MotionStream.prototype.prebufferCap = function() { | ||
return Math.max(Math.floor(this.prebuf*1000 / this.interval), 1); | ||
}; | ||
/** | ||
* On TimeTestQueue success, write frames with any prebuffered frames | ||
* @param {Array.<Object>} frames | ||
*/ | ||
MotionStream.prototype.queueSuccess = function(frames) { | ||
[].concat.apply([], this.preframes.reverse()).concat(frames).forEach(this.sendFrame, this); | ||
this.withPrebuffer(frames).forEach(this.sendFrame, this); | ||
this.preframes.length = 0; | ||
@@ -67,2 +89,15 @@ this.nomotion = 0; | ||
/** | ||
* Concat frames onto prebuffer frames | ||
* @param {Array.<Object>} frames | ||
* @return {Array.<Object>} | ||
*/ | ||
MotionStream.prototype.withPrebuffer = function(frames) { | ||
return [].concat.apply([], this.preframes.slice(0).reverse()).concat(frames); | ||
}; | ||
/** | ||
* Send frames along | ||
* @param {Array.<Object>} frames | ||
*/ | ||
MotionStream.prototype.sendFrame = function(frame) { | ||
@@ -72,2 +107,6 @@ this.emit('data', frame); | ||
/** | ||
* A quick test whether we should write failed frames as a postbuffer | ||
* @return {Boolean} | ||
*/ | ||
MotionStream.prototype.postBuffering = function() { | ||
@@ -77,2 +116,6 @@ return (++this.nomotion * this.interval) <= (this.postbuf * 1000); | ||
/** | ||
* Take the passed in image and store it in an object with the current time | ||
* @param {Buffer} image | ||
*/ | ||
MotionStream.prototype.write = function(image) { | ||
@@ -79,0 +122,0 @@ this.queue.push({ data: image, time: Date.now() }); |
{ | ||
"name": "motion", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A node.js motion detection library written in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,3 +17,3 @@ Motion | ||
```javascript | ||
var Motion = require('motion'); | ||
var Motion = require('motion').Motion; | ||
var motion = new Motion(); | ||
@@ -33,3 +33,3 @@ var hasMotion = motion.detect(image1, image2); | ||
```javascript | ||
var Motion = require('motion'); | ||
var Motion = require('motion').Motion; | ||
var motion = new Motion(); | ||
@@ -36,0 +36,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5487534
167
260