Commit 631ab8fa authored by Simon MacDonald's avatar Simon MacDonald Committed by GitHub

Merge pull request #303 from vladimir-kotikov/memory_consumption_fix

Reduce memory consumption by using smaller video resolution
parents 4fffc8d1 89a9c69f
......@@ -155,6 +155,7 @@ BarcodeReader.prototype.init = function (capture, width, height) {
this._width = width;
this._height = height;
this._zxingReader = new ZXing.BarcodeReader();
this._zxingReader.tryHarder = true;
};
/**
......@@ -450,7 +451,7 @@ module.exports = {
.then(function () {
var controller = capture.videoDeviceController;
var deviceProps = controller.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoRecord);
var deviceProps = controller.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoPreview);
deviceProps = Array.prototype.slice.call(deviceProps);
deviceProps = deviceProps.filter(function (prop) {
......@@ -461,8 +462,15 @@ module.exports = {
return propB.width - propA.width;
});
var maxResProps = deviceProps[0];
return controller.setMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.videoRecord, maxResProps)
var preferredProps = deviceProps.filter(function(prop){
// Filter out props where frame size is between 640*480 and 1280*720
return prop.width >= 640 && prop.height >= 480 && prop.width <= 1280 && prop.height <= 720;
});
// prefer video frame size between between 640*480 and 1280*720
// use maximum resolution otherwise
var maxResProps = preferredProps[0] || deviceProps[0];
return controller.setMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.videoPreview, maxResProps)
.then(function () {
return {
capture: capture,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment