]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8087 test for valid cache before setting vars
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 28 Aug 2015 19:32:48 +0000 (14:32 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 28 Aug 2015 19:32:48 +0000 (14:32 -0500)
html5/verto/js/src/jquery.FSRTC.js
html5/verto/video_demo/js/verto-min.js

index adf8667fced94ba19271253e7a8d4ba8d5b9161b..04046a6db236bcb955f255883b86a49faf75ea18 100644 (file)
@@ -1106,8 +1106,13 @@ var iceTimer;
        
        if (cached) {
            var cache = $.parseJSON(cached);
-           $.FSRTC.validRes = cache.validRes;
-           console.log("CACHED RES FOR CAM " + cam, cache);
+
+           if (cache) {
+               $.FSRTC.validRes = cache.validRes;
+               console.log("CACHED RES FOR CAM " + cam, cache);
+           } else {
+               console.error("INVALID CACHE");
+           }
            return func ? func(cache) : null;
        }
 
index 9873f2ff3b02d0a3ab82e49e60cff1b76e14000b..212ee8aa61ccd586c6a008c1226174c671aa9e42 100644 (file)
@@ -85,7 +85,8 @@ var video={mandatory:{},optional:[]}
 if(cam){video.optional=[{sourceId:cam}];}
 w=resList[resI][0];h=resList[resI][1];resI++;video.mandatory={"minWidth":w,"minHeight":h,"maxWidth":w,"maxHeight":h};if(window.moz){video=video.mandatory;if(!video.width)video.width=video.minWidth;if(!video.height)video.height=video.minHeight;if(!video.frameRate)video.frameRate=video.minFrameRate;}
 getUserMedia({constraints:{audio:ttl++==0,video:video},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,func){var used=[];var cached=localStorage.getItem("res_"+cam);if(cached){var cache=$.parseJSON(cached);$.FSRTC.validRes=cache.validRes;console.log("CACHED RES FOR CAM "+cam,cache);return func?func(cache):null;}
+$.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){runtime(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={};}
 if(this.options.sessid){params.sessid=this.options.sessid;}