mjpeg-consumer
Advanced tools
Comparing version 0.1.0 to 0.2.0
require("buffertools"); | ||
var length = /Content-Length: \d+\s*/; | ||
var length = /Content-Length: \d+/; | ||
var soi = new Buffer(2); | ||
soi.writeUInt16LE(0xd8ff, 0); | ||
@@ -17,4 +19,3 @@ var MjpegConsumer = function() { | ||
MjpegConsumer.prototype.write = function(chunk) { | ||
var len = length.exec(chunk); | ||
var start, initialBytes, remaining; | ||
var len, start, initialBytes, remaining, soiIndex; | ||
@@ -24,3 +25,6 @@ if (chunk.length < this.totalBytes - this.bytesWritten) { | ||
this.bytesWritten += chunk.length; | ||
} else if (this.initialized && this.bytesWritten < this.totalBytes) { | ||
return; | ||
} | ||
if (this.initialized && this.bytesWritten < this.totalBytes) { | ||
remaining = this.totalBytes - this.bytesWritten | ||
@@ -31,2 +35,3 @@ chunk.copy(this.buffer, this.bytesWritten, 0, remaining); | ||
len = length.exec(chunk); | ||
if (len) { | ||
@@ -40,6 +45,9 @@ if (this.initialized) { | ||
this.totalBytes = Number(/\d+/.exec(len[0])); | ||
this.buffer = new Buffer(this.totalBytes); | ||
start = chunk.indexOf("Content-Length"); | ||
initialBytes = (chunk.length - (start + len[0].length)); | ||
chunk.copy(this.buffer, 0, start + len[0].length, chunk.length); | ||
this.buffer = new Buffer(this.totalBytes); | ||
} | ||
start = chunk.indexOf(soi); | ||
if (start !== -1) { | ||
initialBytes = (chunk.length - start); | ||
chunk.copy(this.buffer, 0, start, chunk.length); | ||
this.bytesWritten += initialBytes; | ||
@@ -46,0 +54,0 @@ } |
{ | ||
"name": "mjpeg-consumer", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "a nodejs stream implementation that consumes http mjpeg streams", | ||
@@ -18,3 +18,4 @@ "main": "index.js", | ||
"author": "Mike Maelzer <mmaelzer@gmail.com>", | ||
"license": "BSD" | ||
"license": "BSD", | ||
"keywords": ["mjpg", "mjpeg", "motion jpeg", "stream", "http", "ip camera"] | ||
} |
@@ -15,4 +15,2 @@ mjpeg-consumer | ||
**MjpegConsumer()** | ||
var MjpegConsumer = require("mjpeg-consumer"); | ||
@@ -26,3 +24,3 @@ var consumer = new MjpegConsumer(); | ||
var request = require("request"); | ||
var MjpegConsumer = require("../lib/mjpeg-consumer"); | ||
var MjpegConsumer = require("mjpeg-consumer"); | ||
var FileOnWrite = require("file-on-write"); | ||
@@ -29,0 +27,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
4192
65
32