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

Fix device selection #338

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions src/js/bandwidth_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,8 @@ function VideoBandwidthTest(test) {
this.constraints = {
audio: false,
video: {
optional: [
{minWidth: 1280},
{minHeight: 720}
]
minWidth: 1280,
minHeight: 720
}
};
}
Expand Down
74 changes: 50 additions & 24 deletions src/js/camresolutionstest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,32 @@ CamResolutionsTest.prototype = {
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] +

doGetUserMedia(constraints, onSuccess.bind(this), onFail.bind(this));

function onSuccess(stream) {
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);
}
};

function onFail(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));
} else {
this.test.reportError('getUserMedia failed with error: ' +
error);
}
this.maybeContinueGetUserMedia();
};
},

maybeContinueGetUserMedia: function() {
Expand All @@ -102,6 +103,31 @@ CamResolutionsTest.prototype = {
}
this.startGetUserMedia(this.resolutions[this.currentResolution++]);
},

onSuccess: function(stream) {
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);
}
},

onFail: 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);
}
this.maybeContinueGetUserMedia();
},


collectAndAnalyzeStats_: function(stream, resolution) {
var tracks = stream.getVideoTracks();
Expand Down
4 changes: 1 addition & 3 deletions src/js/mictest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ function MicTest(test) {
// Turning off echoCancellation constraint enables stereo input.
this.constraints = {
audio: {
optional: [
{echoCancellation: false}
]
echoCancellation: false
}
};

Expand Down
9 changes: 2 additions & 7 deletions src/ui/testrtc-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,8 @@ <h3>STUN</h3>
},

appendSourceId: function(id, type, constraints) {
if (constraints[type] === true) {
constraints[type] = {optional: [{sourceId: id}]};
} else if (typeof constraints[type] === 'object') {
if (typeof constraints[type].optional === 'undefined') {
constraints[type].optional = [];
}
constraints[type].optional.push({sourceId: id});
if (constraints[type] !== false && typeof(constraints[type]) !== 'undefined') {
constraints[type]['deviceId'] = id;
}
},

Expand Down