Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

fix(camresolutionstest.js): allow to select video source #278

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions src/js/camresolutionstest.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,43 @@ 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) {
console.log(e);
traceGumEvent({ status: 'exception', error: e.message });
return this.test.reportFatal('getUserMedia failed with exception: ' + e.message);
}
},

maybeContinueGetUserMedia: function() {
Expand Down