pull/362/merge
John Beaumier 6 years ago committed by GitHub
commit d24d43443c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
const GetPixels = require("get-pixels"); const getPixels = require("get-pixels");
var InputStream = {}; var InputStream = {};
@ -22,12 +22,12 @@ InputStream.createImageStream = function() {
_topRight = {x: 0, y: 0}, _topRight = {x: 0, y: 0},
_canvasSize = {x: 0, y: 0}; _canvasSize = {x: 0, y: 0};
function loadImages() { function loadImages(callback) {
loaded = false; loaded = false;
GetPixels(baseUrl, _config.mime, function(err, pixels) { getPixels(baseUrl, _config.mime, function (err, pixels) {
if (err) { if (err) {
console.log(err); console.log(err);
exit(1); return callback(err);
} }
loaded = true; loaded = true;
console.log(pixels.shape); console.log(pixels.shape);
@ -84,11 +84,11 @@ InputStream.createImageStream = function() {
return height; return height;
}; };
that.setInputStream = function(stream) { that.setInputStream = function(stream, callback) {
_config = stream; _config = stream;
baseUrl = _config.src; baseUrl = _config.src;
size = 1; size = 1;
loadImages(); loadImages(callback);
}; };
that.ended = function() { that.ended = function() {

@ -3645,7 +3645,11 @@ function initInputStream(cb) {
} }
_inputStream.setAttribute("preload", "auto"); _inputStream.setAttribute("preload", "auto");
_inputStream.setInputStream(_config.inputStream); _inputStream.setInputStream(_config.inputStream, function (err) {
if (err) {
cb(err);
}
});
_inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb)); _inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb));
} }
@ -3839,6 +3843,10 @@ function locateAndDecode() {
function update() { function update() {
var availableWorker; var availableWorker;
if (!_framegrabber) {
return;
}
if (_onUIThread) { if (_onUIThread) {
if (_workerPool.length > 0) { if (_workerPool.length > 0) {
availableWorker = _workerPool.filter(function (workerThread) { availableWorker = _workerPool.filter(function (workerThread) {
@ -4099,7 +4107,10 @@ exports.default = {
halfSample: false halfSample: false
} }
}, config); }, config);
this.init(config, function () { this.init(config, function (err) {
if (err) {
return resultCallback.call(null);
}
_events2.default.once("processed", function (result) { _events2.default.once("processed", function (result) {
_this.stop(); _this.stop();
resultCallback.call(null, result); resultCallback.call(null, result);
@ -4219,7 +4230,7 @@ module.exports = FrameGrabber;
"use strict"; "use strict";
var GetPixels = __webpack_require__(164); var getPixels = __webpack_require__(164);
var InputStream = {}; var InputStream = {};
@ -4243,13 +4254,13 @@ InputStream.createImageStream = function () {
_topRight = { x: 0, y: 0 }, _topRight = { x: 0, y: 0 },
_canvasSize = { x: 0, y: 0 }; _canvasSize = { x: 0, y: 0 };
function loadImages() { function loadImages(callback) {
loaded = false; loaded = false;
GetPixels(baseUrl, _config.mime, function (err, pixels) { getPixels(baseUrl, _config.mime, function (err, pixels) {
if (err) { if (err) {
console.log(err); return callback(err);
exit(1);
} }
loaded = true; loaded = true;
console.log(pixels.shape); console.log(pixels.shape);
frame = pixels; frame = pixels;
@ -4304,11 +4315,11 @@ InputStream.createImageStream = function () {
return height; return height;
}; };
that.setInputStream = function (stream) { that.setInputStream = function (stream, callback) {
_config = stream; _config = stream;
baseUrl = _config.src; baseUrl = _config.src;
size = 1; size = 1;
loadImages(); loadImages(callback);
}; };
that.ended = function () { that.ended = function () {

Loading…
Cancel
Save