]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak js for more Mozilla compat against FF Nightly
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 18 Jun 2015 17:47:04 +0000 (12:47 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 18 Jun 2015 17:47:10 +0000 (12:47 -0500)
html5/verto/demo/js/verto-min.js
html5/verto/js/src/jquery.FSRTC.js
html5/verto/video_demo/js/verto-min.js
html5/verto/video_demo/verto.js

index 451186f9b63fb78dd0e0712389a0aeb08c34c92c..772a28ecf4c0102dc868a8e7273007966c5bafc6 100644 (file)
@@ -40,7 +40,7 @@ function onError(e){onStreamError(self,e);}
 var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);if(self.options.useVideo&&self.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:self.options.videoParams,optional:[]},},localVideo:self.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
 getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:obj.options.audioParams,optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}}
 if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:obj.options.videoParams,optional:[]},},localVideo:obj.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
-var video={mandatory:obj.options.videoParams,optional:[]}
+var video={};if(window.moz){video=obj.options.videoParams;if(!video.width)video.width=video.minWidth;if(!video.height)video.height=video.minHeight;if(!video.frameRate)video.frameRate=video.minFrameRate;}else{video={mandatory:obj.options.videoParams,optional:[]}}
 var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(obj.options.useCamera!=="any"){video.optional=[{sourceId:obj.options.useCamera}]}}else{video=null;useVideo=null;}
 return{audio:audio,video:video,useVideo:useVideo};}
 $.FSRTC.prototype.call=function(profile){checkCompat();var self=this;var screen=false;self.type="offer";if(self.options.videoParams&&self.options.screenShare){screen=true;}
@@ -80,7 +80,8 @@ return[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:[]}
 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};getUserMedia({constraints:{audio:false,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);}});}
+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:true,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=[];$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
 $.FSRTC.checkPerms=function(){getUserMedia({constraints:{audio:true,video:true,},onsuccess:function(e){e.stop();console.info("media perm init complete");},onerror:function(e){console.error("media perm init error");}});}})(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;}
index 05debc676b96262a98d005fe7d079d66a338f0be..55d57fe4c24ee312885d043fa785bf08c5640da0 100644 (file)
@@ -467,11 +467,20 @@ var iceTimer;
             });
        }
 
-       var video = {
-            mandatory: obj.options.videoParams,
-            optional: []
-        }
+       var video = {};
 
+       if (window.moz) {
+           video = obj.options.videoParams;
+           if (!video.width) video.width = video.minWidth;
+           if (!video.height) video.height = video.minHeight;
+           if (!video.frameRate) video.frameRate = video.minFrameRate;
+       } else {
+           video = {
+               mandatory: obj.options.videoParams,
+               optional: []
+            }
+       }
+       
        var useVideo = obj.options.useVideo;
 
        if (useVideo && obj.options.useCamera && obj.options.useCamera !== "none") {
@@ -1042,9 +1051,16 @@ var iceTimer;
            "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: false,
+                audio: true,
                 video: video       
            },
            onsuccess: function(e) {e.stop(); console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
index 451186f9b63fb78dd0e0712389a0aeb08c34c92c..772a28ecf4c0102dc868a8e7273007966c5bafc6 100644 (file)
@@ -40,7 +40,7 @@ function onError(e){onStreamError(self,e);}
 var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);if(self.options.useVideo&&self.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:self.options.videoParams,optional:[]},},localVideo:self.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
 getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:obj.options.audioParams,optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}}
 if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:obj.options.videoParams,optional:[]},},localVideo:obj.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
-var video={mandatory:obj.options.videoParams,optional:[]}
+var video={};if(window.moz){video=obj.options.videoParams;if(!video.width)video.width=video.minWidth;if(!video.height)video.height=video.minHeight;if(!video.frameRate)video.frameRate=video.minFrameRate;}else{video={mandatory:obj.options.videoParams,optional:[]}}
 var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(obj.options.useCamera!=="any"){video.optional=[{sourceId:obj.options.useCamera}]}}else{video=null;useVideo=null;}
 return{audio:audio,video:video,useVideo:useVideo};}
 $.FSRTC.prototype.call=function(profile){checkCompat();var self=this;var screen=false;self.type="offer";if(self.options.videoParams&&self.options.screenShare){screen=true;}
@@ -80,7 +80,8 @@ return[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:[]}
 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};getUserMedia({constraints:{audio:false,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);}});}
+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:true,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=[];$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
 $.FSRTC.checkPerms=function(){getUserMedia({constraints:{audio:true,video:true,},onsuccess:function(e){e.stop();console.info("media perm init complete");},onerror:function(e){console.error("media perm init error");}});}})(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;}
index b9e458f3c9944ac1df2b6e5e266de41bd748dc10..e01fc405493095cf4e06c2310e881899aba07900 100644 (file)
@@ -179,7 +179,7 @@ function check_vid_res()
            "minHeight": vid_height,
            "maxWidth": vid_width,
            "maxHeight": vid_height,
-           //"minFrameRate": 30, 
+           "minFrameRate": 30, 
            //chromeMediaSource: 'screen', 
            //mediaSource: 'screen'
        });
@@ -1165,7 +1165,7 @@ function init() {
             "minHeight": vid_height,
            "maxWidth": vid_width,
            "maxHeight": vid_height,
-           //"minFrameRate": 30,
+           "minFrameRate": 30,
            //chromeMediaSource: 'screen',
            //mediaSource: 'screen'
         },