Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #303 from vladimir-kotikov/memory_consumption_fix
Browse files Browse the repository at this point in the history
Reduce memory consumption by using smaller video resolution
  • Loading branch information
macdonst committed Sep 8, 2016
2 parents 4fffc8d + 89a9c69 commit 631ab8f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/windows/BarcodeScannerProxy.js
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 631ab8f

Please sign in to comment.