From 278365a33d30478c67b428eecee9eb56bb5cf256 Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 18:25:31 +1000 Subject: [PATCH 1/6] Update config --- .zuul.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zuul.yml b/.zuul.yml index dff82b1..95c9558 100644 --- a/.zuul.yml +++ b/.zuul.yml @@ -1,7 +1,7 @@ ui: tape browsers: - name: chrome - version: [35,36,beta] + version: [41,42,beta,dev] - name: firefox - version: 30..latest + version: [36,37,beta,dev] From ccb958f3ffc4b2524453873a43f8a6c32c1920bf Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 18:31:36 +1000 Subject: [PATCH 2/6] Remove dev browsers --- .zuul.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.zuul.yml b/.zuul.yml index 95c9558..b3e9b21 100644 --- a/.zuul.yml +++ b/.zuul.yml @@ -1,7 +1,7 @@ ui: tape browsers: - name: chrome - version: [41,42,beta,dev] + version: [41,42,beta] - name: firefox - version: [36,37,beta,dev] + version: [36,37,beta] From e916dc8b258c2c0844d3eb5297d5da299164534a Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 18:49:47 +1000 Subject: [PATCH 3/6] Added tests for mandatory constraint generation --- test/camera-combo-constraints-mandatory.js | 36 ++++++++++++++++++++ test/helpers/expect-constraints-mandatory.js | 12 +++++++ 2 files changed, 48 insertions(+) create mode 100644 test/camera-combo-constraints-mandatory.js create mode 100644 test/helpers/expect-constraints-mandatory.js diff --git a/test/camera-combo-constraints-mandatory.js b/test/camera-combo-constraints-mandatory.js new file mode 100644 index 0000000..1abf388 --- /dev/null +++ b/test/camera-combo-constraints-mandatory.js @@ -0,0 +1,36 @@ +var test = require('tape'); +var expect = require('./helpers/expect-constraints-mandatory'); + +test('camera min:1280x720 15fps', expect({ + audio: true, + video: { + mandatory: { + minFrameRate: 15, + maxFrameRate: 15, + frameRate: 15, + minWidth: 1280, + width: { min: 1280 }, + minHeight: 720, + height: { min: 720 } + }, + optional: [] + } +})); + +test('camera min:1280x720 max:1280x720 min:15fps max:25fps', expect({ + audio: true, + video: { + mandatory: { + minFrameRate: 15, + maxFrameRate: 25, + frameRate: { min: 15, max: 25 }, + minWidth: 1280, + maxWidth: 1280, + width: 1280, + minHeight: 720, + maxHeight: 720, + height: 720 + }, + optional: [] + } +})); diff --git a/test/helpers/expect-constraints-mandatory.js b/test/helpers/expect-constraints-mandatory.js new file mode 100644 index 0000000..68f6c78 --- /dev/null +++ b/test/helpers/expect-constraints-mandatory.js @@ -0,0 +1,12 @@ +var captureconfig = require('../../'); + +module.exports = function(expected) { + return function(t) { + t.plan(1); + t.deepEqual( + captureconfig(t.name).toConstraints({ useMandatory: true }), + expected, + JSON.stringify(expected) + ); + }; +}; \ No newline at end of file From d76ab5fadcdc850f51df62536d9ad73c486bfb3c Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 19:09:46 +1000 Subject: [PATCH 4/6] Upgrade deps --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cc35ff9..f35cb12 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ "url": "https://github.com/rtc-io/rtc-captureconfig/issues" }, "devDependencies": { - "async": "^0.9.0", + "async": "^1.0.0", "crel": "^2.1.5", "getusermedia": "^1.1.0", "rtc-media": "^1.5.5", - "tape": "^3.0.1", - "zuul": "^1.10.0" + "tape": "^4.0.0", + "zuul": "^3.0.0" }, "dependencies": { - "cog": "^1.0.0", + "cog": "^1.1.0", "rtc-core": "^4.0.0" } -} \ No newline at end of file +} From 70cb6b22db4693eb6e1bd8d4c65766a66a4e1426 Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 19:10:04 +1000 Subject: [PATCH 5/6] Include mandatory constraints generation test --- test/all.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/all.js b/test/all.js index c04922b..2ebb6c3 100644 --- a/test/all.js +++ b/test/all.js @@ -9,6 +9,7 @@ require('./camera-targets'); require('./camera-resolution-constraints'); require('./camera-fps-constraints'); require('./camera-combo-constraints'); +require('./camera-combo-constraints-mandatory'); require('./camera-noaudio-constraints'); require('./camera-targets-constraints'); From bf6e912bf25909bfcaba27c76f6b9d352471af25 Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Tue, 26 May 2015 19:11:01 +1000 Subject: [PATCH 6/6] Allow constraints to be generated as mandatory constraints - ref #5 --- index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index d73d367..150dc72 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ 'use strict'; var detect = require('rtc-core/detect'); +var extend = require('cog/extend'); var reSeparator = /[\,\s]\s*/; var offFlags = ['false', 'none', 'off']; var reFPS = /(\d+)fps/i; @@ -357,6 +358,15 @@ prot.toConstraints = function(opts) { return info && info.kind === 'audio'; }); var selectedSource; + var useMandatory = !!(opts || {}).useMandatory; + + function addConstraints(section, constraints) { + if (useMandatory) { + return extend.apply(null, [m[section]].concat(constraints)); + } + + o[section] = o[section].concat(constraints); + } function complexConstraints(target) { if (constraints[target] && typeof constraints[target] != 'object') { @@ -381,19 +391,19 @@ prot.toConstraints = function(opts) { // fps if (cfg.fps) { complexConstraints('video'); - o.video = o.video.concat(buildConstraints('frameRate', cfg.fps)); + addConstraints('video', buildConstraints('frameRate', cfg.fps)); } // min res specified if (cfg.res) { complexConstraints('video'); - o.video = o.video.concat(buildConstraints('width', { + addConstraints('video', buildConstraints('width', { min: cfg.res.min && cfg.res.min.w, max: cfg.res.max && cfg.res.max.w })); - o.video = o.video.concat(buildConstraints('height', { + addConstraints('video', buildConstraints('height', { min: cfg.res.min && cfg.res.min.h, max: cfg.res.max && cfg.res.max.h })); @@ -405,7 +415,7 @@ prot.toConstraints = function(opts) { if (selectedSource) { complexConstraints('video'); - o.video.push({ sourceId: selectedSource.id }); + addConstraints('video', { sourceId: selectedSource.id }); } } @@ -415,7 +425,7 @@ prot.toConstraints = function(opts) { if (selectedSource) { complexConstraints('audio'); - o.audio.push({ sourceId: selectedSource.id }); + addConstraints('audio', { sourceId: selectedSource.id }); } }