added config 'cameraIndex' to select the camera by index

pull/97/head
Matthias Jauernig 9 years ago
parent 82ef5b9397
commit bd429ec362

@ -84,11 +84,19 @@ function normalizeConstraints(config, cb) {
if ( typeof MediaStreamTrack !== 'undefined' && typeof MediaStreamTrack.getSources !== 'undefined') {
MediaStreamTrack.getSources(function(sourceInfos) {
var videoSourceId;
var videoSourceId, facingDetected, videoIndex = 0;
for (var i = 0; i < sourceInfos.length; ++i) {
var sourceInfo = sourceInfos[i];
if (sourceInfo.kind === "video" && sourceInfo.facing === videoConstraints.facing) {
videoSourceId = sourceInfo.id;
if (sourceInfo.kind === "video" && !facingDetected) {
if (sourceInfo.facing === videoConstraints.facing) {
facingDetected = true;
}
if (!config.cameraIndex || config.cameraIndex <= videoIndex) {
videoSourceId = sourceInfo.id;
}
videoIndex++;
}
}
constraints.video = {

Loading…
Cancel
Save