]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8181 #resolve [Verto check for camera perms fails init when no camera is present]
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Sep 2015 20:09:19 +0000 (15:09 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Sep 2015 20:09:19 +0000 (15:09 -0500)
html5/verto/js/src/jquery.FSRTC.js
html5/verto/js/src/jquery.verto.js
html5/verto/video_demo/js/verto-min.js

index e025c669c0e337b13850608aba722e9f50d1bde7..1bdeeed80fd6d6f11d1435a06a761f76d3fb559e 100644 (file)
        checkRes(cam, func);
     }
 
-    $.FSRTC.checkPerms = function (runtime) {
+    $.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
        getUserMedia({
            constraints: {
-               audio: true,
-               video: true,
+               audio: check_audio,
+               video: check_video,
            },
            onsuccess: function(e) {e.stop(); console.info("media perm init complete"); if (runtime) {setTimeout(runtime, 100, true)}},
-           onerror: function(e) {console.error("media perm init error"); if (runtime) {runtime(false)}}
+           onerror: function(e) {
+               if (check_video && check_audio) {
+                   console.error("error, retesting with audio params only");
+                   return $.FSRTC.checkPerms(runtime, check_audio, false);
+               }
+
+               console.error("media perm init error");
+
+               if (runtime) {
+                   runtime(false)
+               }
+           }
        });
     }
 
index 9a9ccc9fe5d26963ccd8add8d594ceb814fb804e..34acbd5fcc3ea3c80f8b035ab99a0b35e4cc025f 100644 (file)
     $.verto.init = function(obj, runtime) {
        $.FSRTC.checkPerms(function() {
            checkDevices(runtime);
-       });
+       }, true, true);
     }
 
     $.verto.genUUID = function () {
index 71380394d334627da8f64025dba4e0535478ee5e..66cc902862fb01b08062af522f7297601631dd70 100644 (file)
@@ -91,7 +91,8 @@ getUserMedia({constraints:{audio:ttl++==0,video:video},onsuccess:function(e){e.s
 $.FSRTC.getValidRes=function(cam,func){var used=[];var cached=localStorage.getItem("res_"+cam);if(cached){var cache=$.parseJSON(cached);if(cache){$.FSRTC.validRes=cache.validRes;console.log("CACHED RES FOR CAM "+cam,cache);}else{console.error("INVALID CACHE");}
 return func?func(cache):null;}
 $.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
-$.FSRTC.checkPerms=function(runtime){getUserMedia({constraints:{audio:true,video:true,},onsuccess:function(e){e.stop();console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true)}},onerror:function(e){console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
+$.FSRTC.checkPerms=function(runtime,check_audio,check_video){getUserMedia({constraints:{audio:check_audio,video:check_video,},onsuccess:function(e){e.stop();console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true)}},onerror:function(e){if(check_video&&check_audio){console.error("error, retesting with audio params only");return $.FSRTC.checkPerms(runtime,check_audio,false);}
+console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
 if(this.options.sessid){params.sessid=this.options.sessid;}
 var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
 if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
@@ -274,5 +275,5 @@ for(var i in $.verto.saved){var verto=$.verto.saved[i];if(verto){verto.purge();v
 return $.verto.warnOnUnload;});$.verto.videoDevices=[];$.verto.audioInDevices=[];$.verto.audioOutDevices=[];var checkDevices=function(runtime){console.info("enumerating devices");var aud_in=[],aud_out=[],vid=[];if((!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices)&&MediaStreamTrack.getSources){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_in.push(media_sources[i]);}}
 $.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;console.info("Audio Devices",$.verto.audioInDevices);console.info("Video Devices",$.verto.videoDevices);runtime();});}else{if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){console.log("enumerateDevices() not supported.");return;}
 navigator.mediaDevices.enumerateDevices().then(function(devices){devices.forEach(function(device){console.log(device);console.log(device.kind+": "+device.label+" id = "+device.deviceId);if(device.kind==="videoinput"){vid.push({id:device.deviceId,kind:"video",label:device.label});}else if(device.kind==="audioinput"){aud_in.push({id:device.deviceId,kind:"audio_in",label:device.label});}else if(device.kind==="audiooutput"){aud_out.push({id:device.deviceId,kind:"audio_out",label:device.label});}});$.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;$.verto.audioOutDevices=aud_out;console.info("Audio IN Devices",$.verto.audioInDevices);console.info("Audio Out Devices",$.verto.audioOutDevices);console.info("Video Devices",$.verto.videoDevices);runtime();}).catch(function(err){console.log(err.name+": "+error.message);runtime();});}};$.verto.refreshDevices=function(runtime){checkDevices(runtime);}
-$.verto.init=function(obj,runtime){$.FSRTC.checkPerms(function(){checkDevices(runtime);});}
+$.verto.init=function(obj,runtime){$.FSRTC.checkPerms(function(){checkDevices(runtime);},true,true);}
 $.verto.genUUID=function(){return generateGUID();}})(jQuery);
\ No newline at end of file