From a390809b8239d8c4cb5dada254cb65f8aa011a9e Mon Sep 17 00:00:00 2001 From: Felix Zapata Date: Tue, 26 Feb 2019 13:48:03 +0100 Subject: [PATCH 1/2] fix(camresolutionstest.js): allow to select video source --- src/js/camresolutionstest.js | 61 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/src/js/camresolutionstest.js b/src/js/camresolutionstest.js index 943ed4a1..06025e05 100644 --- a/src/js/camresolutionstest.js +++ b/src/js/camresolutionstest.js @@ -64,35 +64,44 @@ CamResolutionsTest.prototype = { var constraints = { audio: false, video: { - width: {exact: resolution[0]}, - height: {exact: resolution[1]} + deviceId: this.$.videoSource.value, + width: { exact: resolution[0] }, + height: { exact: resolution[1] } } }; - navigator.mediaDevices.getUserMedia(constraints) - .then(function(stream) { - // Do not check actual video frames when more than one resolution is - // provided. - if (this.resolutions.length > 1) { - this.test.reportSuccess('Supported: ' + resolution[0] + 'x' + - resolution[1]); - stream.getTracks().forEach(function(track) { - track.stop(); - }); - this.maybeContinueGetUserMedia(); - } else { - this.collectAndAnalyzeStats_(stream, resolution); - } - }.bind(this)) - .catch(function(error) { - if (this.resolutions.length > 1) { - this.test.reportInfo(resolution[0] + 'x' + resolution[1] + - ' not supported'); - } else { - this.test.reportError('getUserMedia failed with error: ' + - error.name); - } + var cam; + var traceGumEvent = report.traceEventAsync('getusermedia'); + try { + traceGumEvent({ status: 'pending', constraints: constraints }); + navigator.mediaDevices.getUserMedia(constraints).then(function(stream) { + // Do not check actual video frames when more than one resolution is + // provided. + cam = this.test.getDeviceName_(stream.getVideoTracks()); + traceGumEvent({ status: 'success', camera: cam }); + if(this.resolutions.length > 1) { + this.test.reportSuccess('Supported: ' + resolution[0] + 'x' + resolution[1]); + stream.getTracks().forEach(function(track) { + track.stop(); + }); this.maybeContinueGetUserMedia(); - }.bind(this)); + } else { + this.collectAndAnalyzeStats_(stream, resolution); + } + }.bind(this)).catch(function(error) { + traceGumEvent({ status: 'fail', error: error }); + if(this.resolutions.length > 1) { + this.test.reportInfo(resolution[0] + 'x' + resolution[1] + ' not supported'); + } else { + this.test.reportError('getUserMedia failed with error: ' + error.name); + } + this.maybeContinueGetUserMedia(); + }.bind(this)); + } catch (e) { + // eslint-disable-next-line + console.log(e); + traceGumEvent({ status: 'exception', error: e.message }); + return this.test.reportFatal('getUserMedia failed with exception: ' + e.message); + } }, maybeContinueGetUserMedia: function() { From cb2e03f3dd9985e68683cb580a914fb94a9cda5c Mon Sep 17 00:00:00 2001 From: Felix Zapata Date: Tue, 26 Feb 2019 13:49:13 +0100 Subject: [PATCH 2/2] style(camresolutionstest.js): remove eslint disable line --- src/js/camresolutionstest.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/camresolutionstest.js b/src/js/camresolutionstest.js index 06025e05..819e35a5 100644 --- a/src/js/camresolutionstest.js +++ b/src/js/camresolutionstest.js @@ -97,7 +97,6 @@ CamResolutionsTest.prototype = { this.maybeContinueGetUserMedia(); }.bind(this)); } catch (e) { - // eslint-disable-next-line console.log(e); traceGumEvent({ status: 'exception', error: e.message }); return this.test.reportFatal('getUserMedia failed with exception: ' + e.message);