|
|
|
@ -84,12 +84,20 @@ 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) {
|
|
|
|
|
if (sourceInfo.kind === "video" && !facingDetected) {
|
|
|
|
|
if (sourceInfo.facing === videoConstraints.facing) {
|
|
|
|
|
facingDetected = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!config.cameraIndex || config.cameraIndex <= videoIndex) {
|
|
|
|
|
videoSourceId = sourceInfo.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
videoIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
constraints.video = {
|
|
|
|
|
mandatory: {
|
|
|
|
|