FS-7509: update res detection

This commit is contained in:
Anthony Minessale
2015-04-30 13:40:39 -05:00
committed by Michael Jerris
parent d1e466e76d
commit f48289ca2c
5 changed files with 66 additions and 43 deletions

View File

@@ -966,7 +966,16 @@
return [w, h];
}
var checkRes = function (cam, w, h) {
var resList = [[320, 180], [320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]];
var resI = 0;
var checkRes = function (cam, func) {
if (resI >= resList.length) {
if (func) return func();
return;
}
var video = {
mandatory: {},
optional: []
@@ -976,6 +985,10 @@
video.optional = [{sourceId: obj.options.useCamera}];
}
w = resList[resI][0];
h = resList[resI][1];
resI++;
video.mandatory = {
"minWidth": w,
"minHeight": h,
@@ -988,20 +1001,19 @@
audio: false,
video: video
},
onsuccess: function(e) {e.stop(); console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h])},
onerror: function(e) {console.error( w + "x" + h + " not supported.");}
onsuccess: function(e) {e.stop(); console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
onerror: function(e) {console.error( w + "x" + h + " not supported."); checkRes(cam, func);}
});
}
$.FSRTC.getValidRes = function (cam) {
var used = [[320, 180], [320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]];
$.FSRTC.getValidRes = function (cam, func) {
var used = [];
$.FSRTC.validRes = [];
resI = 0;
for (var i in used) {
checkRes(cam, used[i][0], used[i][1]);
}
checkRes(cam, func);
}
$.FSRTC.checkPerms = function () {

View File

@@ -2147,32 +2147,32 @@
$.verto.findDevices = function(runtime) {
var aud = [], vid = [];
$.FSRTC.checkPerms();
setTimeout(function() {
$.FSRTC.getValidRes(null);
}, 2000);
MediaStreamTrack.getSources(function (media_sources) {
for (var i = 0; i < media_sources.length; i++) {
$.FSRTC.getValidRes(null, function() {
console.info("enumerating devices");
if (media_sources[i].kind == 'video') {
vid.push(media_sources[i]);
} else {
aud.push(media_sources[i]);
MediaStreamTrack.getSources(function (media_sources) {
for (var i = 0; i < media_sources.length; i++) {
if (media_sources[i].kind == 'video') {
vid.push(media_sources[i]);
} else {
aud.push(media_sources[i]);
}
}
}
$.verto.videoDevices = vid;
$.verto.audioDevices = aud;
console.info("Audio Devices", $.verto.audioDevices);
console.info("Video Devices", $.verto.videoDevices);
runtime();
$.verto.videoDevices = vid;
$.verto.audioDevices = aud;
console.info("Audio Devices", $.verto.audioDevices);
console.info("Video Devices", $.verto.videoDevices);
runtime();
});
});
}
$.verto.init = function(runtime) {
$.verto.findDevices(runtime);
};
})(jQuery);