mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
Merge branch 'master' into v1.4
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
<param name="offer-uri" value="true"/>
|
||||
<!-- if true, channel variables are added to rayo client offer -->
|
||||
<param name="add-variables-to-offer" value="false"/>
|
||||
<!-- if true, channel variables are added to offer, ringing, answered, and end events sent to rayo clients -->
|
||||
<param name="add-variables-to-events" value="false"/>
|
||||
</settings>
|
||||
|
||||
<!-- record component params -->
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
<profile name="cdquality">
|
||||
<param name="domain" value="$${domain}"/>
|
||||
<param name="rate" value="48000"/>
|
||||
<param name="interval" value="10"/>
|
||||
<param name="interval" value="20"/>
|
||||
<param name="energy-level" value="300"/>
|
||||
<!--<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>-->
|
||||
<param name="muted-sound" value="conference/conf-muted.wav"/>
|
||||
|
||||
+14
-1
@@ -517,6 +517,19 @@ AC_SUBST(SYS_XMLRPC_CFLAGS)
|
||||
AC_SUBST(SYS_XMLRPC_LDFLAGS)
|
||||
AM_CONDITIONAL([SYSTEM_XMLRPCC],[test "${enable_xmlrpcc}" = "yes"])
|
||||
|
||||
AC_ARG_ENABLE([system-lua],[AS_HELP_STRING([--enable-system-lua],[use system lib for lua])],,[enable_system_lua="no"])
|
||||
PKG_CHECK_MODULES([LUA],[lua5.2],[have_lua=yes],[have_lua=no])
|
||||
if test "${have_lua}" = "no" ; then
|
||||
PKG_CHECK_MODULES([LUA],[lua5.1],[have_lua=yes],[have_lua=no])
|
||||
fi
|
||||
if test "${have_lua}" = "no" ; then
|
||||
PKG_CHECK_MODULES([LUA],[lua],[have_lua=yes],[have_lua=no])
|
||||
fi
|
||||
if test x"${LUA_LIBS}" = x"" ; then
|
||||
LUA_LIBS="-llua"
|
||||
fi
|
||||
AM_CONDITIONAL([SYSTEM_LUA],[test "${enable_system_lua}" = "yes"])
|
||||
|
||||
AC_ARG_ENABLE(srtp,
|
||||
[AC_HELP_STRING([--disable-srtp],[build without srtp support])],[enable_srtp="$enableval"],[enable_srtp="yes"])
|
||||
|
||||
@@ -766,7 +779,7 @@ AC_SUBST(LIBTOOL_LIB_EXTEN)
|
||||
# Checks for header files.
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([sys/types.h sys/resource.h sched.h wchar.h sys/filio.h sys/ioctl.h sys/select.h netdb.h execinfo.h])
|
||||
AC_CHECK_HEADERS([sys/types.h sys/resource.h sched.h wchar.h sys/filio.h sys/ioctl.h sys/prctl.h sys/select.h netdb.h execinfo.h])
|
||||
|
||||
if test x"$ac_cv_header_wchar_h" = xyes; then
|
||||
HAVE_WCHAR_H_DEFINE=1
|
||||
|
||||
Vendored
+1
-1
@@ -308,7 +308,7 @@ Build-Depends:
|
||||
libogg-dev, libspeex-dev, libspeexdsp-dev,
|
||||
# configure options
|
||||
libssl-dev, unixodbc-dev, libpq-dev,
|
||||
libncurses5-dev, libjpeg62-dev | libjpeg8-dev,
|
||||
libncurses5-dev, libjpeg62-turbo-dev | libjpeg62-dev | libjpeg8-dev,
|
||||
python-dev, erlang-dev,
|
||||
# documentation
|
||||
doxygen,
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ Group=freeswitch
|
||||
LimitCORE=infinity
|
||||
LimitNOFILE=100000
|
||||
LimitNPROC=60000
|
||||
LimitSTACK=240
|
||||
;LimitSTACK=240
|
||||
LimitRTPRIO=infinity
|
||||
LimitRTTIME=7000000
|
||||
IOSchedulingClass=realtime
|
||||
|
||||
Vendored
+1
-1
@@ -101,7 +101,7 @@ getlibs () {
|
||||
getlib http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-v1.8-latest.tgz
|
||||
getlib http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz
|
||||
getlib http://files.freeswitch.org/downloads/libs/soundtouch-1.7.1.tar.gz
|
||||
getlib http://files.freeswitch.org/downloads/libs/flite-1.5.4-current.tar.bz2
|
||||
getlib http://files.freeswitch.org/downloads/libs/flite-2.0.0-release.tar.bz2
|
||||
getlib http://files.freeswitch.org/downloads/libs/sphinxbase-0.8.tar.gz
|
||||
getlib http://files.freeswitch.org/downloads/libs/pocketsphinx-0.8.tar.gz
|
||||
getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
This needs to be fleshed out more.
|
||||
It would be nice to develop a web app here that implements a web phone.
|
||||
Do not base it on the demo because it was just tossed together.
|
||||
|
||||
To run jshint:
|
||||
|
||||
cd js
|
||||
npm install
|
||||
grunt
|
||||
|
||||
Vendored
+35
-48
@@ -3,17 +3,18 @@
|
||||
function findLineInRange(sdpLines,startLine,endLine,prefix,substr){var realEndLine=(endLine!=-1)?endLine:sdpLines.length;for(var i=startLine;i<realEndLine;++i){if(sdpLines[i].indexOf(prefix)===0){if(!substr||sdpLines[i].toLowerCase().indexOf(substr.toLowerCase())!==-1){return i;}}}
|
||||
return null;}
|
||||
function getCodecPayloadType(sdpLine){var pattern=new RegExp('a=rtpmap:(\\d+) \\w+\\/\\d+');var result=sdpLine.match(pattern);return(result&&result.length==2)?result[1]:null;}
|
||||
function setDefaultCodec(mLine,payload){var elements=mLine.split(' ');var newLine=[];var index=0;for(var i=0;i<elements.length;i++){if(index===3)
|
||||
newLine[index++]=payload;if(elements[i]!==payload)newLine[index++]=elements[i];}
|
||||
function setDefaultCodec(mLine,payload){var elements=mLine.split(' ');var newLine=[];var index=0;for(var i=0;i<elements.length;i++){if(index===3){newLine[index++]=payload;}
|
||||
if(elements[i]!==payload)newLine[index++]=elements[i];}
|
||||
return newLine.join(' ');}
|
||||
$.FSRTC=function(options){this.options=$.extend({useVideo:null,useStereo:false,userData:null,iceServers:false,videoParams:{},audioParams:{},callbacks:{onICEComplete:function(){},onICE:function(){},onOfferSDP:function(){}}},options);this.mediaData={SDP:null,profile:{},candidateList:[]};this.constraints={optional:[{'DtlsSrtpKeyAgreement':'true'}],mandatory:{OfferToReceiveAudio:true,OfferToReceiveVideo:this.options.useVideo?true:false,}};if(self.options.useVideo){self.options.useVideo.style.display='none';}
|
||||
setCompat();checkCompat();};$.FSRTC.prototype.useVideo=function(obj){var self=this;if(obj){self.options.useVideo=obj;self.constraints.mandatory.OfferToReceiveVideo=true;}else{self.options.useVideo=null;self.constraints.mandatory.OfferToReceiveVideo=false;}
|
||||
$.FSRTC=function(options){this.options=$.extend({useVideo:null,useStereo:false,userData:null,iceServers:false,videoParams:{},audioParams:{},callbacks:{onICEComplete:function(){},onICE:function(){},onOfferSDP:function(){}}},options);this.mediaData={SDP:null,profile:{},candidateList:[]};if(moz){this.constraints={offerToReceiveAudio:true,offerToReceiveVideo:this.options.useVideo?true:false,};}else{this.constraints={optional:[{'DtlsSrtpKeyAgreement':'true'}],mandatory:{OfferToReceiveAudio:true,OfferToReceiveVideo:this.options.useVideo?true:false,}};}
|
||||
if(self.options.useVideo){self.options.useVideo.style.display='none';}
|
||||
setCompat();checkCompat();};$.FSRTC.prototype.useVideo=function(obj){var self=this;if(obj){self.options.useVideo=obj;if(moz){self.constraints.offerToReceiveVideo=true;}else{self.constraints.mandatory.OfferToReceiveVideo=true;}}else{self.options.useVideo=null;if(moz){self.constraints.offerToReceiveVideo=false;}else{self.constraints.mandatory.OfferToReceiveVideo=false;}}
|
||||
if(self.options.useVideo){self.options.useVideo.style.display='none';}};$.FSRTC.prototype.useStereo=function(on){var self=this;self.options.useStereo=on;};$.FSRTC.prototype.stereoHack=function(sdp){var self=this;if(!self.options.useStereo){return sdp;}
|
||||
var sdpLines=sdp.split('\r\n');var opusIndex=findLine(sdpLines,'a=rtpmap','opus/48000'),opusPayload;if(opusIndex){opusPayload=getCodecPayloadType(sdpLines[opusIndex]);}
|
||||
var fmtpLineIndex=findLine(sdpLines,'a=fmtp:'+opusPayload.toString());if(fmtpLineIndex===null)return sdp;sdpLines[fmtpLineIndex]=sdpLines[fmtpLineIndex].concat('; stereo=1');sdp=sdpLines.join('\r\n');return sdp;};function setCompat(){$.FSRTC.moz=!!navigator.mozGetUserMedia;if(!navigator.getUserMedia){navigator.getUserMedia=navigator.mozGetUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia;}}
|
||||
function checkCompat(){if(!navigator.getUserMedia){alert('This application cannot function in this browser.');return false;}
|
||||
return true;}
|
||||
function onStreamError(self){console.log('There has been a problem retrieving the streams - did you allow access?');}
|
||||
function onStreamError(self,e){console.log('There has been a problem retrieving the streams - did you allow access?',e);}
|
||||
function onStreamSuccess(self){console.log("Stream Success");}
|
||||
function onICE(self,candidate){self.mediaData.candidate=candidate;self.mediaData.candidateList.push(self.mediaData.candidate);doCallback(self,"onICE");}
|
||||
function doCallback(self,func,arg){if(func in self.options.callbacks){self.options.callbacks[func](self,arg);}}
|
||||
@@ -29,16 +30,18 @@ function onOfferSDP(self,sdp){self.mediaData.SDP=self.stereoHack(sdp.sdp);consol
|
||||
$.FSRTC.prototype.answer=function(sdp,onSuccess,onError){this.peer.addAnswerSDP({type:"answer",sdp:sdp},onSuccess,onError);};$.FSRTC.prototype.stop=function(){var self=this;if(self.options.useVideo){self.options.useVideo.style.display='none';}
|
||||
if(self.localStream){self.localStream.stop();self.localStream=null;}
|
||||
if(self.peer){console.log("stopping peer");self.peer.stop();}};$.FSRTC.prototype.createAnswer=function(sdp){var self=this;self.type="answer";self.remoteSDP=sdp;console.debug("inbound sdp: ",sdp);function onSuccess(stream){self.localStream=stream;self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:function(stream){return onRemoteStream(self,stream);},onICESDP:function(sdp){return onICESDP(self,sdp);},onChannelError:function(e){return onChannelError(self,e);},constraints:self.constraints,iceServers:self.options.iceServers,offerSDP:{type:"offer",sdp:self.remoteSDP}});onStreamSuccess(self);}
|
||||
function onError(){onStreamError(self);}
|
||||
getUserMedia({constraints:{audio:{mandatory:this.options.audioParams,optional:[]},video:this.options.useVideo?{mandatory:this.options.videoParams,optional:[]}:null},video:this.options.useVideo?true:false,onsuccess:onSuccess,onerror:onError});};$.FSRTC.prototype.call=function(profile){checkCompat();var self=this;self.type="offer";function onSuccess(stream){self.localStream=stream;self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:function(stream){return onRemoteStream(self,stream);},onOfferSDP:function(sdp){return onOfferSDP(self,sdp);},onICESDP:function(sdp){return onICESDP(self,sdp);},onChannelError:function(e){return onChannelError(self,e);},constraints:self.constraints,iceServers:self.options.iceServers,});onStreamSuccess(self);}
|
||||
function onError(){onStreamError(self);}
|
||||
getUserMedia({constraints:{audio:{mandatory:this.options.audioParams,optional:[]},video:this.options.useVideo?{mandatory:this.options.videoParams,optional:[]}:null},video:this.options.useVideo?true:false,onsuccess:onSuccess,onerror:onError});};window.moz=!!navigator.mozGetUserMedia;function RTCPeerConnection(options){var w=window,PeerConnection=w.mozRTCPeerConnection||w.webkitRTCPeerConnection,SessionDescription=w.mozRTCSessionDescription||w.RTCSessionDescription,IceCandidate=w.mozRTCIceCandidate||w.RTCIceCandidate;var STUN={url:!moz?'stun:stun.l.google.com:19302':'stun:23.21.150.121'};var TURN={url:'turn:homeo@turn.bistri.com:80',credential:'homeo'};var iceServers=null;if(options.iceServers){var tmp=options.iceServers;;if(typeof(tmp)==="boolean"){tmp=null;}
|
||||
if(tmp&&typeof(tmp)!=="array"){console.warn("iceServers must be an array, reverting to default ice servers");tmp=null;}
|
||||
function onError(e){onStreamError(self,e);}
|
||||
var audio;if(this.options.videoParams&&this.options.videoParams.chromeMediaSource=='screen'){this.options.videoParams={chromeMediaSource:'screen',maxWidth:screen.width,maxHeight:screen.height};console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:this.options.audioParams,optional:[]};}
|
||||
console.log("Mandatory audio constraints",this.options.audioParams);console.log("Mandatory video constraints",this.options.videoParams);getUserMedia({constraints:{audio:audio,video:this.options.useVideo?{mandatory:this.options.videoParams,optional:[]}:null},video:this.options.useVideo?true:false,onsuccess:onSuccess,onerror:onError});};$.FSRTC.prototype.call=function(profile){checkCompat();var self=this;self.type="offer";function onSuccess(stream){self.localStream=stream;self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:function(stream){return onRemoteStream(self,stream);},onOfferSDP:function(sdp){return onOfferSDP(self,sdp);},onICESDP:function(sdp){return onICESDP(self,sdp);},onChannelError:function(e){return onChannelError(self,e);},constraints:self.constraints,iceServers:self.options.iceServers,});onStreamSuccess(self);}
|
||||
function onError(e){onStreamError(self,e);}
|
||||
var audio;if(this.options.videoParams&&this.options.videoParams.chromeMediaSource=='screen'){this.options.videoParams={chromeMediaSource:'screen',maxWidth:screen.width,maxHeight:screen.height};console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:this.options.audioParams,optional:[]};}
|
||||
console.log("Mandatory audio constraints",this.options.audioParams);console.log("Mandatory video constraints",this.options.videoParams);getUserMedia({constraints:{audio:audio,video:this.options.useVideo?{mandatory:this.options.videoParams,optional:[]}:null},video:this.options.useVideo?true:false,onsuccess:onSuccess,onerror:onError});};window.moz=!!navigator.mozGetUserMedia;function RTCPeerConnection(options){var w=window,PeerConnection=w.mozRTCPeerConnection||w.webkitRTCPeerConnection,SessionDescription=w.mozRTCSessionDescription||w.RTCSessionDescription,IceCandidate=w.mozRTCIceCandidate||w.RTCIceCandidate;var STUN={url:!moz?'stun:stun.l.google.com:19302':'stun:23.21.150.121'};var TURN={url:'turn:homeo@turn.bistri.com:80',credential:'homeo'};var iceServers=null;if(options.iceServers){var tmp=options.iceServers;if(typeof(tmp)==="boolean"){tmp=null;}
|
||||
if(tmp&&!(typeof(tmp)=="object"&&tmp.constructor===Array)){console.warn("iceServers must be an array, reverting to default ice servers");tmp=null;}
|
||||
iceServers={iceServers:tmp||[STUN]};if(!moz&&!tmp){if(parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2])>=28)TURN={url:'turn:turn.bistri.com:80',credential:'homeo',username:'homeo'};iceServers.iceServers=[STUN];}}
|
||||
var optional={optional:[]};if(!moz){optional.optional=[{DtlsSrtpKeyAgreement:true},{RtpDataChannels:options.onChannelMessage?true:false}];}
|
||||
var peer=new PeerConnection(iceServers,optional);openOffererChannel();var x=0;peer.onicecandidate=function(event){if(event.candidate){options.onICE(event.candidate);}else{if(options.onICEComplete){options.onICEComplete();}
|
||||
if(options.type=="offer"){if(!moz&&!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
|
||||
peer.onaddstream=function(event){var remoteMediaStream=event.stream;remoteMediaStream.onended=function(){if(options.onRemoteStreamEnded)options.onRemoteStreamEnded(remoteMediaStream);};if(options.onRemoteStream)options.onRemoteStream(remoteMediaStream);};var constraints=options.constraints||{optional:[],mandatory:{OfferToReceiveAudio:true,OfferToReceiveVideo:true}};function createOffer(){if(!options.onOfferSDP)return;peer.createOffer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);options.onOfferSDP(sessionDescription);if(moz&&options.onICESDP){options.onICESDP(sessionDescription);}},onSdpError,constraints);}
|
||||
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
|
||||
peer.onaddstream=function(event){var remoteMediaStream=event.stream;remoteMediaStream.onended=function(){if(options.onRemoteStreamEnded)options.onRemoteStreamEnded(remoteMediaStream);};if(options.onRemoteStream)options.onRemoteStream(remoteMediaStream);};var constraints=options.constraints||{offerToReceiveAudio:true,offerToReceiveVideo:true};function createOffer(){if(!options.onOfferSDP)return;peer.createOffer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);options.onOfferSDP(sessionDescription);if(moz&&options.onICESDP&&sessionDescription.sdp.match(/a=candidate/)){options.onICESDP(sessionDescription);options.sentICESDP=1;}},onSdpError,constraints);}
|
||||
function createAnswer(){if(options.type!="answer")return;peer.setRemoteDescription(new SessionDescription(options.offerSDP),onSdpSuccess,onSdpError);peer.createAnswer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);if(options.onAnswerSDP){options.onAnswerSDP(sessionDescription);}},onSdpError,constraints);}
|
||||
if((options.onChannelMessage&&!moz)||!options.onChannelMessage){createOffer();createAnswer();}
|
||||
function setBandwidth(sdp){sdp=sdp.replace(/b=AS([^\r\n]+\r\n)/g,'');sdp=sdp.replace(/a=mid:data\r\n/g,'a=mid:data\r\nb=AS:1638400\r\n');return sdp;}
|
||||
@@ -63,48 +66,37 @@ var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if
|
||||
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
|
||||
var socket=this.options.getSocket(this.wsOnMessage);if(socket!==null){this._wsCall(socket,request,success_cb,error_cb);return;}
|
||||
if(this.options.ajaxUrl===null){throw"$.JsonRpcClient.call used with no websocket and no http endpoint.";}
|
||||
$.ajax({type:'POST',url:this.options.ajaxUrl,data:$.toJSON(request),dataType:'json',cache:false,success:function(data){if('error'in data)error_cb(data.error,this);success_cb(data.result,this);},error:function(jqXHR,textStatus,errorThrown){try{var response=$.parseJSON(jqXHR.responseText);if('console'in window)console.log(response);error_cb(response.error,this);}
|
||||
catch(err){error_cb({error:jqXHR.responseText},this);}}});};$.JsonRpcClient.prototype.notify=function(method,params){if(this.options.sessid){params.sessid=this.options.sessid;}
|
||||
$.ajax({type:'POST',url:this.options.ajaxUrl,data:$.toJSON(request),dataType:'json',cache:false,success:function(data){if('error'in data)error_cb(data.error,this);success_cb(data.result,this);},error:function(jqXHR,textStatus,errorThrown){try{var response=$.parseJSON(jqXHR.responseText);if('console'in window)console.log(response);error_cb(response.error,this);}catch(err){error_cb({error:jqXHR.responseText},this);}}});};$.JsonRpcClient.prototype.notify=function(method,params){if(this.options.sessid){params.sessid=this.options.sessid;}
|
||||
var request={jsonrpc:'2.0',method:method,params:params};var socket=this.options.getSocket(this.wsOnMessage);if(socket!==null){this._wsCall(socket,request);return;}
|
||||
if(this.options.ajaxUrl===null){throw"$.JsonRpcClient.notify used with no websocket and no http endpoint.";}
|
||||
$.ajax({type:'POST',url:this.options.ajaxUrl,data:$.toJSON(request),dataType:'json',cache:false});};$.JsonRpcClient.prototype.batch=function(callback,all_done_cb,error_cb){var batch=new $.JsonRpcClient._batchObject(this,all_done_cb,error_cb);callback(batch);batch._execute();};$.JsonRpcClient.prototype.socketReady=function(){if(this._ws_socket===null||this._ws_socket.readyState>1){return false;}
|
||||
return true;}
|
||||
$.JsonRpcClient.prototype.closeSocket=function(){if(self.socketReady()){this._ws_socket.onclose=function(w){console.log("Closing Socket")}
|
||||
this._ws_socket.close();}}
|
||||
$.JsonRpcClient.prototype.loginData=function(params){self.options.login=params.login;self.options.passwd=params.passwd;}
|
||||
$.JsonRpcClient.prototype.connectSocket=function(onmessage_cb){var self=this;if(self.to){clearTimeout(self.to);}
|
||||
return true;};$.JsonRpcClient.prototype.closeSocket=function(){if(self.socketReady()){this._ws_socket.onclose=function(w){console.log("Closing Socket");};this._ws_socket.close();}};$.JsonRpcClient.prototype.loginData=function(params){self.options.login=params.login;self.options.passwd=params.passwd;};$.JsonRpcClient.prototype.connectSocket=function(onmessage_cb){var self=this;if(self.to){clearTimeout(self.to);}
|
||||
if(!self.socketReady()){self.authing=false;if(self._ws_socket){delete self._ws_socket;}
|
||||
self._ws_socket=new WebSocket(self.options.socketUrl);if(self._ws_socket){self._ws_socket.onmessage=onmessage_cb;self._ws_socket.onclose=function(w){if(!self.ws_sleep){self.ws_sleep=1000;}
|
||||
if(self.options.onWSClose){self.options.onWSClose(self);}
|
||||
console.error("Websocket Lost "+self.ws_cnt+" sleep: "+self.ws_sleep+"msec");self.to=setTimeout(function(){console.log("Attempting Reconnection....");self.connectSocket(onmessage_cb);},self.ws_sleep);self.ws_cnt++;if(self.ws_sleep<3000&&(self.ws_cnt%10)==0){self.ws_sleep+=1000;}}
|
||||
self._ws_socket.onopen=function(){if(self.to){clearTimeout(self.to);}
|
||||
console.error("Websocket Lost "+self.ws_cnt+" sleep: "+self.ws_sleep+"msec");self.to=setTimeout(function(){console.log("Attempting Reconnection....");self.connectSocket(onmessage_cb);},self.ws_sleep);self.ws_cnt++;if(self.ws_sleep<3000&&(self.ws_cnt%10)===0){self.ws_sleep+=1000;}};self._ws_socket.onopen=function(){if(self.to){clearTimeout(self.to);}
|
||||
self.ws_sleep=1000;self.ws_cnt=0;if(self.options.onWSConnect){self.options.onWSConnect(self);}
|
||||
var req;while(req=$.JsonRpcClient.q.pop()){self._ws_socket.send(req);}}}}
|
||||
return self._ws_socket?true:false;}
|
||||
$.JsonRpcClient.prototype._getSocket=function(onmessage_cb){if(this.options.socketUrl===null||!("WebSocket"in window))return null;this.connectSocket(onmessage_cb);return this._ws_socket;};$.JsonRpcClient.q=[];$.JsonRpcClient.prototype._wsCall=function(socket,request,success_cb,error_cb){var request_json=$.toJSON(request);if(socket.readyState<1){self=this;$.JsonRpcClient.q.push(request_json);}
|
||||
else{socket.send(request_json);}
|
||||
if('id'in request&&typeof success_cb!=='undefined'){this._ws_callbacks[request.id]={request:request_json,request_obj:request,success_cb:success_cb,error_cb:error_cb};}};$.JsonRpcClient.prototype._wsOnMessage=function(event){var response;try{response=$.parseJSON(event.data);if(typeof response==='object'&&'jsonrpc'in response&&response.jsonrpc==='2.0'){if('result'in response&&this._ws_callbacks[response.id]){var success_cb=this._ws_callbacks[response.id].success_cb;delete this._ws_callbacks[response.id];success_cb(response.result,this);return;}
|
||||
else if('error'in response&&this._ws_callbacks[response.id]){var error_cb=this._ws_callbacks[response.id].error_cb;var orig_req=this._ws_callbacks[response.id].request;if(!self.authing&&response.error.code==-32000&&self.options.login&&self.options.passwd){self.authing=true;this.call("login",{login:self.options.login,passwd:self.options.passwd},this._ws_callbacks[response.id].request_obj.method=="login"?function(e){self.authing=false;console.log("logged in");delete self._ws_callbacks[response.id];if(self.options.onWSLogin){self.options.onWSLogin(true,self);}}:function(e){self.authing=false;console.log("logged in, resending request id: "+response.id);var socket=self.options.getSocket(self.wsOnMessage);if(socket!==null){socket.send(orig_req);}
|
||||
var req;while((req=$.JsonRpcClient.q.pop())){self._ws_socket.send(req);}};}}
|
||||
return self._ws_socket?true:false;};$.JsonRpcClient.prototype._getSocket=function(onmessage_cb){if(this.options.socketUrl===null||!("WebSocket"in window))return null;this.connectSocket(onmessage_cb);return this._ws_socket;};$.JsonRpcClient.q=[];$.JsonRpcClient.prototype._wsCall=function(socket,request,success_cb,error_cb){var request_json=$.toJSON(request);if(socket.readyState<1){self=this;$.JsonRpcClient.q.push(request_json);}else{socket.send(request_json);}
|
||||
if('id'in request&&typeof success_cb!=='undefined'){this._ws_callbacks[request.id]={request:request_json,request_obj:request,success_cb:success_cb,error_cb:error_cb};}};$.JsonRpcClient.prototype._wsOnMessage=function(event){var response;try{response=$.parseJSON(event.data);if(typeof response==='object'&&'jsonrpc'in response&&response.jsonrpc==='2.0'){if('result'in response&&this._ws_callbacks[response.id]){var success_cb=this._ws_callbacks[response.id].success_cb;delete this._ws_callbacks[response.id];success_cb(response.result,this);return;}else if('error'in response&&this._ws_callbacks[response.id]){var error_cb=this._ws_callbacks[response.id].error_cb;var orig_req=this._ws_callbacks[response.id].request;if(!self.authing&&response.error.code==-32000&&self.options.login&&self.options.passwd){self.authing=true;this.call("login",{login:self.options.login,passwd:self.options.passwd},this._ws_callbacks[response.id].request_obj.method=="login"?function(e){self.authing=false;console.log("logged in");delete self._ws_callbacks[response.id];if(self.options.onWSLogin){self.options.onWSLogin(true,self);}}:function(e){self.authing=false;console.log("logged in, resending request id: "+response.id);var socket=self.options.getSocket(self.wsOnMessage);if(socket!==null){socket.send(orig_req);}
|
||||
if(self.options.onWSLogin){self.options.onWSLogin(true,self);}},function(e){console.log("error logging in, request id:",response.id);delete self._ws_callbacks[response.id];error_cb(response.error,this);if(self.options.onWSLogin){self.options.onWSLogin(false,self);}});return;}
|
||||
delete this._ws_callbacks[response.id];error_cb(response.error,this);return;}}}
|
||||
catch(err){console.log("ERROR: "+err);return;}
|
||||
delete this._ws_callbacks[response.id];error_cb(response.error,this);return;}}}catch(err){console.log("ERROR: "+err);return;}
|
||||
if(typeof this.options.onmessage==='function'){event.eventData=response;if(!event.eventData){event.eventData={};}
|
||||
var reply=this.options.onmessage(event);if(reply&&typeof reply==="object"&&event.eventData.id){var msg={jsonrpc:"2.0",id:event.eventData.id,result:reply};var socket=self.options.getSocket(self.wsOnMessage);if(socket!==null){socket.send($.toJSON(msg));}}}};$.JsonRpcClient._batchObject=function(jsonrpcclient,all_done_cb,error_cb){this._requests=[];this.jsonrpcclient=jsonrpcclient;this.all_done_cb=all_done_cb;this.error_cb=typeof error_cb==='function'?error_cb:function(){};};$.JsonRpcClient._batchObject.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
|
||||
if(this.options.sessid){params.sessid=this.options.sessid;}
|
||||
if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
|
||||
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
|
||||
this._requests.push({request:{jsonrpc:'2.0',method:method,params:params,id:this.jsonrpcclient._current_id++},success_cb:success_cb,error_cb:error_cb});};$.JsonRpcClient._batchObject.prototype.notify=function(method,params){if(this.options.sessid){params.sessid=this.options.sessid;}
|
||||
this._requests.push({request:{jsonrpc:'2.0',method:method,params:params}});};$.JsonRpcClient._batchObject.prototype._execute=function(){var self=this;if(this._requests.length===0)return;var batch_request=[];var handlers={};var socket=self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage);if(socket!==null){for(var i=0;i<this._requests.length;i++){var call=this._requests[i];var success_cb=('success_cb'in call)?call.success_cb:undefined;var error_cb=('error_cb'in call)?call.error_cb:undefined;self.jsonrpcclient._wsCall(socket,call.request,success_cb,error_cb);}
|
||||
this._requests.push({request:{jsonrpc:'2.0',method:method,params:params}});};$.JsonRpcClient._batchObject.prototype._execute=function(){var self=this;if(this._requests.length===0)return;var batch_request=[];var handlers={};var i=0;var call;var success_cb;var error_cb;var socket=self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage);if(socket!==null){for(i=0;i<this._requests.length;i++){call=this._requests[i];success_cb=('success_cb'in call)?call.success_cb:undefined;error_cb=('error_cb'in call)?call.error_cb:undefined;self.jsonrpcclient._wsCall(socket,call.request,success_cb,error_cb);}
|
||||
if(typeof all_done_cb==='function')all_done_cb(result);return;}
|
||||
for(var i=0;i<this._requests.length;i++){var call=this._requests[i];batch_request.push(call.request);if('id'in call.request){handlers[call.request.id]={success_cb:call.success_cb,error_cb:call.error_cb};}}
|
||||
var success_cb=function(data){self._batchCb(data,handlers,self.all_done_cb);};if(self.jsonrpcclient.options.ajaxUrl===null){throw"$.JsonRpcClient.batch used with no websocket and no http endpoint.";}
|
||||
$.ajax({url:self.jsonrpcclient.options.ajaxUrl,data:$.toJSON(batch_request),dataType:'json',cache:false,type:'POST',error:function(jqXHR,textStatus,errorThrown){self.error_cb(jqXHR,textStatus,errorThrown);},success:success_cb});};$.JsonRpcClient._batchObject.prototype._batchCb=function(result,handlers,all_done_cb){for(var i=0;i<result.length;i++){var response=result[i];if('error'in response){if(response.id===null||!(response.id in handlers)){if('console'in window)console.log(response);}
|
||||
else handlers[response.id].error_cb(response.error,this);}
|
||||
else{if(!(response.id in handlers)&&'console'in window)console.log(response);else handlers[response.id].success_cb(response.result,this);}}
|
||||
for(i=0;i<this._requests.length;i++){call=this._requests[i];batch_request.push(call.request);if('id'in call.request){handlers[call.request.id]={success_cb:call.success_cb,error_cb:call.error_cb};}}
|
||||
success_cb=function(data){self._batchCb(data,handlers,self.all_done_cb);};if(self.jsonrpcclient.options.ajaxUrl===null){throw"$.JsonRpcClient.batch used with no websocket and no http endpoint.";}
|
||||
$.ajax({url:self.jsonrpcclient.options.ajaxUrl,data:$.toJSON(batch_request),dataType:'json',cache:false,type:'POST',error:function(jqXHR,textStatus,errorThrown){self.error_cb(jqXHR,textStatus,errorThrown);},success:success_cb});};$.JsonRpcClient._batchObject.prototype._batchCb=function(result,handlers,all_done_cb){for(var i=0;i<result.length;i++){var response=result[i];if('error'in response){if(response.id===null||!(response.id in handlers)){if('console'in window)console.log(response);}else{handlers[response.id].error_cb(response.error,this);}}else{if(!(response.id in handlers)&&'console'in window){console.log(response);}else{handlers[response.id].success_cb(response.result,this);}}}
|
||||
if(typeof all_done_cb==='function')all_done_cb(result);};})(jQuery);(function($){var generateGUID=(typeof(window.crypto)!=='undefined'&&typeof(window.crypto.getRandomValues)!=='undefined')?function(){var buf=new Uint16Array(8);window.crypto.getRandomValues(buf);var S4=function(num){var ret=num.toString(16);while(ret.length<4){ret="0"+ret;}
|
||||
return ret;};return(S4(buf[0])+S4(buf[1])+"-"+S4(buf[2])+"-"+S4(buf[3])+"-"+S4(buf[4])+"-"+S4(buf[5])+S4(buf[6])+S4(buf[7]));}:function(){return'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(c){var r=Math.random()*16|0,v=c=='x'?r:(r&0x3|0x8);return v.toString(16);});};$.verto=function(options,callbacks){var verto=this;$.verto.saved.push(verto);verto.options=$.extend({login:null,passwd:null,socketUrl:null,tag:null,videoParams:{},audioParams:{},iceServers:false,ringSleep:6000},options);verto.sessid=$.cookie('verto_session_uuid')||generateGUID();$.cookie('verto_session_uuid',verto.sessid,{expires:1});verto.dialogs={};verto.callbacks=callbacks||{};verto.eventSUBS={};verto.rpcClient=new $.JsonRpcClient({login:verto.options.login,passwd:verto.options.passwd,socketUrl:verto.options.socketUrl,sessid:verto.sessid,onmessage:function(e){return verto.handleMessage(e.eventData);},onWSConnect:function(o){o.call('login',{});},onWSLogin:function(success){if(verto.callbacks.onWSLogin){verto.callbacks.onWSLogin(verto,success);}},onWSClose:function(success){if(verto.callbacks.onWSClose){verto.callbacks.onWSClose(verto,success);}
|
||||
verto.purge();}});if(verto.options.ringFile&&verto.options.tag){verto.ringer=$("#"+verto.options.tag);}
|
||||
verto.rpcClient.call('login',{});};$.verto.prototype.iceServers=function(on){var verto=this;verto.options.iceServers=on;};$.verto.prototype.loginData=function(params){verto.options.login=params.login;verto.options.passwd=params.passwd;verto.rpcClient.loginData(params);};$.verto.prototype.logout=function(msg){var verto=this;verto.rpcClient.closeSocket();verto.purge();};$.verto.prototype.login=function(msg){var verto=this;verto.logout();verto.rpcClient.call('login',{});};$.verto.prototype.message=function(msg){var verto=this;var err=0;if(!msg.to){console.error("Missing To");err++;}
|
||||
verto.rpcClient.call('login',{});};$.verto.prototype.videoParams=function(on){var verto=this;verto.options.videoParams=on;};$.verto.prototype.iceServers=function(on){var verto=this;verto.options.iceServers=on;};$.verto.prototype.loginData=function(params){verto.options.login=params.login;verto.options.passwd=params.passwd;verto.rpcClient.loginData(params);};$.verto.prototype.logout=function(msg){var verto=this;verto.rpcClient.closeSocket();if(verto.callbacks.onWSClose){verto.callbacks.onWSClose(verto,false);}
|
||||
verto.purge();};$.verto.prototype.login=function(msg){var verto=this;verto.logout();verto.rpcClient.call('login',{});};$.verto.prototype.message=function(msg){var verto=this;var err=0;if(!msg.to){console.error("Missing To");err++;}
|
||||
if(!msg.body){console.error("Missing Body");err++;}
|
||||
if(err){return false;}
|
||||
verto.sendMethod("verto.info",{msg:msg});return true;};$.verto.prototype.processReply=function(method,success,e){var verto=this;var i;switch(method){case"verto.subscribe":for(i in e.unauthorizedChannels){drop_bad(verto,e.unauthorizedChannels[i]);}
|
||||
@@ -132,7 +124,7 @@ if(data.params.sdp&&data.params.sdp.indexOf("stereo=1")>0){data.params.useStereo
|
||||
dialog=new $.verto.dialog($.verto.enum.direction.inbound,verto,data.params);dialog.setState($.verto.enum.state.recovering);break;case'verto.invite':if(data.params.sdp&&data.params.sdp.indexOf("m=video")>0){data.params.wantVideo=true;}
|
||||
if(data.params.sdp&&data.params.sdp.indexOf("stereo=1")>0){data.params.useStereo=true;}
|
||||
dialog=new $.verto.dialog($.verto.enum.direction.inbound,verto,data.params);break;default:console.debug("INVALID METHOD OR NON-EXISTANT CALL REFERENCE IGNORED");break;}}
|
||||
return{method:data.method};}else{switch(data.method){case'verto.event':var list=null;var key=null;if(data.params){key=data.params.eventChannel;}
|
||||
return{method:data.method};}else{switch(data.method){case'verto.punt':verto.purge();verto.logout();break;case'verto.event':var list=null;var key=null;if(data.params){key=data.params.eventChannel;}
|
||||
if(key){list=verto.eventSUBS[key];if(!list){list=verto.eventSUBS[key.split(".")[0]];}}
|
||||
if(!list&&key&&key===verto.sessid){if(verto.callbacks.onMessage){verto.callbacks.onMessage(verto,null,$.verto.enum.message.pvtEvent,data.params);}}else if(!list&&key&&verto.dialogs[key]){verto.dialogs[key].sendMessage($.verto.enum.message.pvtEvent,data.params);}else if(!list){if(!key){key="UNDEFINED";}
|
||||
console.error("UNSUBBED or invalid EVENT "+key+" IGNORED");}else{for(var i in list){var sub=list[i];if(!sub||!sub.ready){console.error("invalid EVENT for "+key+" IGNORED");}else if(sub.handler){sub.handler(verto,data.params,sub.userData);}else if(verto.callbacks.onEvent){verto.callbacks.onEvent(verto,data.params,sub.userData);}else{console.log("EVENT:",data.params);}}}
|
||||
@@ -171,22 +163,17 @@ dt.fnClearTable();dt.fnAddData(obj.asArray());dt.fnAdjustColumnSizing();break;ca
|
||||
if(args.redraw>-1){dt.fnClearTable();dt.fnAddData(obj.asArray());}else{dt.fnAddData(args.data);}
|
||||
dt.fnAdjustColumnSizing();break;case"modify":if(!args.data){return;}
|
||||
dt.fnUpdate(args.data,index);dt.fnAdjustColumnSizing();break;case"del":dt.fnDeleteRow(index);dt.fnAdjustColumnSizing();break;case"clear":dt.fnClearTable();break;case"reorder":dt.fnClearTable();dt.fnAddData(obj.asArray());break;case"hide":jq.hide();break;case"show":jq.show();break;}}catch(err){console.error("ERROR: "+err);iserr++;}
|
||||
if(iserr){obj.errs++;if(obj.errs<3){obj.bootstrap(obj.user_obj);}}else{obj.errs=0;}};la.onChange(la,{action:"init"});};var CONFMAN_SERNO=1;$.verto.confMan=function(verto,params){var confMan=this;conf
|
||||
confMan.params=$.extend({tableID:null,statusID:null,mainModID:null,dialog:null,hasVid:false,laData:null,onBroadcast:null,onLaChange:null,onLaRow:null},params);confMan.verto=verto;confMan.serno=CONFMAN_SERNO++;function genMainMod(jq){var play_id="play_"+confMan.serno;var stop_id="stop_"+confMan.serno;var recording_id="recording_"+confMan.serno;var rec_stop_id="recording_stop"+confMan.serno;var div_id="confman_"+confMan.serno;var html="<div id='"+div_id+"'><br>"+"<button class='ctlbtn' id='"+play_id+"'>Play</button>"+"<button class='ctlbtn' id='"+stop_id+"'>Stop</button>"+"<button class='ctlbtn' id='"+recording_id+"'>Record</button>"+"<button class='ctlbtn' id='"+rec_stop_id+"'>Record Stop</button>"
|
||||
+"<br><br></div>";jq.html(html);$("#"+play_id).click(function(){var file=prompt("Please enter file name","");confMan.modCommand("play",null,file);});$("#"+stop_id).click(function(){confMan.modCommand("stop",null,"all");});$("#"+recording_id).click(function(){var file=prompt("Please enter file name","");confMan.modCommand("recording",null,["start",file]);});$("#"+rec_stop_id).click(function(){confMan.modCommand("recording",null,["stop","all"]);});}
|
||||
if(iserr){obj.errs++;if(obj.errs<3){obj.bootstrap(obj.user_obj);}}else{obj.errs=0;}};la.onChange(la,{action:"init"});};var CONFMAN_SERNO=1;$.verto.confMan=function(verto,params){var confMan=this;confMan.params=$.extend({tableID:null,statusID:null,mainModID:null,dialog:null,hasVid:false,laData:null,onBroadcast:null,onLaChange:null,onLaRow:null},params);confMan.verto=verto;confMan.serno=CONFMAN_SERNO++;function genMainMod(jq){var play_id="play_"+confMan.serno;var stop_id="stop_"+confMan.serno;var recording_id="recording_"+confMan.serno;var rec_stop_id="recording_stop"+confMan.serno;var div_id="confman_"+confMan.serno;var html="<div id='"+div_id+"'><br>"+"<button class='ctlbtn' id='"+play_id+"'>Play</button>"+"<button class='ctlbtn' id='"+stop_id+"'>Stop</button>"+"<button class='ctlbtn' id='"+recording_id+"'>Record</button>"+"<button class='ctlbtn' id='"+rec_stop_id+"'>Record Stop</button>"+"<br><br></div>";jq.html(html);$("#"+play_id).click(function(){var file=prompt("Please enter file name","");confMan.modCommand("play",null,file);});$("#"+stop_id).click(function(){confMan.modCommand("stop",null,"all");});$("#"+recording_id).click(function(){var file=prompt("Please enter file name","");confMan.modCommand("recording",null,["start",file]);});$("#"+rec_stop_id).click(function(){confMan.modCommand("recording",null,["stop","all"]);});}
|
||||
function genControls(jq,rowid){var x=parseInt(rowid);var kick_id="kick_"+x;var tmute_id="tmute_"+x;var box_id="box_"+x;var volup_id="volume_in_up"+x;var voldn_id="volume_in_dn"+x;var transfer_id="transfer"+x;var html="<div id='"+box_id+"'>"+"<button class='ctlbtn' id='"+kick_id+"'>Kick</button>"+"<button class='ctlbtn' id='"+tmute_id+"'>Mute</button>"+"<button class='ctlbtn' id='"+voldn_id+"'>Vol -</button>"+"<button class='ctlbtn' id='"+volup_id+"'>Vol +</button>"+"<button class='ctlbtn' id='"+transfer_id+"'>Transfer</button>"+"</div>";jq.html(html);if(!jq.data("mouse")){$("#"+box_id).hide();}
|
||||
jq.mouseover(function(e){jq.data({"mouse":true});$("#"+box_id).show();});jq.mouseout(function(e){jq.data({"mouse":false});$("#"+box_id).hide();});$("#"+transfer_id).click(function(){var xten=prompt("Enter Extension");confMan.modCommand("transfer",x,xten);});$("#"+kick_id).click(function(){confMan.modCommand("kick",x);});$("#"+tmute_id).click(function(){confMan.modCommand("tmute",x);});$("#"+volup_id).click(function(){confMan.modCommand("volume_in",x,"up");});$("#"+voldn_id).click(function(){confMan.modCommand("volume_in",x,"down");});return html;}
|
||||
var atitle="";var awidth=0;if(confMan.params.laData.role==="moderator"){atitle="Action";awidth=200;if(confMan.params.mainModID){genMainMod($(confMan.params.mainModID));$(confMan.params.displayID).html("Moderator Controls Ready<br><br>")}else{$(confMan.params.mainModID).html("");}
|
||||
var atitle="";var awidth=0;if(confMan.params.laData.role==="moderator"){atitle="Action";awidth=200;if(confMan.params.mainModID){genMainMod($(confMan.params.mainModID));$(confMan.params.displayID).html("Moderator Controls Ready<br><br>");}else{$(confMan.params.mainModID).html("");}
|
||||
verto.subscribe(confMan.params.laData.modChannel,{handler:function(v,e){console.error("MODDATA:",e.data);if(confMan.params.onBroadcast){confMan.params.onBroadcast(verto,confMan,e.data);}
|
||||
if(!confMan.destroyed&&confMan.params.displayID){$(confMan.params.displayID).html(e.data.response+"<br><br>");if(confMan.lastTimeout){clearTimeout(confMan.lastTimeout);confMan.lastTimeout=0;}
|
||||
confMan.lastTimeout=setTimeout(function(){$(confMan.params.displayID).html(confMan.destroyed?"":"Moderator Controls Ready<br><br>")},4000);}}});}
|
||||
confMan.lastTimeout=setTimeout(function(){$(confMan.params.displayID).html(confMan.destroyed?"":"Moderator Controls Ready<br><br>");},4000);}}});}
|
||||
var row_callback=null;if(confMan.params.laData.role==="moderator"){row_callback=function(nRow,aData,iDisplayIndex,iDisplayIndexFull){if(!aData[5]){var $row=$('td:eq(5)',nRow);genControls($row,aData);if(confMan.params.onLaRow){confMan.params.onLaRow(verto,confMan,$row,aData);}}};}
|
||||
confMan.lt=new $.verto.liveTable(verto,confMan.params.laData.laChannel,confMan.params.laData.laName,$(confMan.params.tableID),{subParams:{callID:confMan.params.dialog?confMan.params.dialog.callID:null},"onChange":function(obj,args){$(confMan.params.statusID).text("Conference Members: "+" ("+obj.arrayLen()+" Total)");if(confMan.params.onLaChange){confMan.params.onLaChange(verto,confMan,$.verto.enum.confEvent.laChange,obj,args);}},"aaData":[],"aoColumns":[{"sTitle":"ID"},{"sTitle":"Number"},{"sTitle":"Name"},{"sTitle":"Codec"},{"sTitle":"Status","sWidth":confMan.params.hasVid?"300px":"150px"},{"sTitle":atitle,"sWidth":awidth,}],"bAutoWidth":true,"bDestroy":true,"bSort":false,"bInfo":false,"bFilter":false,"bLengthChange":false,"bPaginate":false,"iDisplayLength":1000,"oLanguage":{"sEmptyTable":"The Conference is Empty....."},"fnRowCallback":row_callback});}
|
||||
$.verto.confMan.prototype.modCommand=function(cmd,id,value){var confMan=this;confMan.verto.sendMethod("verto.broadcast",{"eventChannel":confMan.params.laData.modChannel,"data":{"application":"conf-control","command":cmd,"id":id,"value":value}});}
|
||||
$.verto.confMan.prototype.destroy=function(){var confMan=this;confMan.destroyed=true;if(confMan.lt){confMan.lt.destroy();}
|
||||
confMan.lt=new $.verto.liveTable(verto,confMan.params.laData.laChannel,confMan.params.laData.laName,$(confMan.params.tableID),{subParams:{callID:confMan.params.dialog?confMan.params.dialog.callID:null},"onChange":function(obj,args){$(confMan.params.statusID).text("Conference Members: "+" ("+obj.arrayLen()+" Total)");if(confMan.params.onLaChange){confMan.params.onLaChange(verto,confMan,$.verto.enum.confEvent.laChange,obj,args);}},"aaData":[],"aoColumns":[{"sTitle":"ID"},{"sTitle":"Number"},{"sTitle":"Name"},{"sTitle":"Codec"},{"sTitle":"Status","sWidth":confMan.params.hasVid?"300px":"150px"},{"sTitle":atitle,"sWidth":awidth,}],"bAutoWidth":true,"bDestroy":true,"bSort":false,"bInfo":false,"bFilter":false,"bLengthChange":false,"bPaginate":false,"iDisplayLength":1000,"oLanguage":{"sEmptyTable":"The Conference is Empty....."},"fnRowCallback":row_callback});};$.verto.confMan.prototype.modCommand=function(cmd,id,value){var confMan=this;confMan.verto.sendMethod("verto.broadcast",{"eventChannel":confMan.params.laData.modChannel,"data":{"application":"conf-control","command":cmd,"id":id,"value":value}});};$.verto.confMan.prototype.destroy=function(){var confMan=this;confMan.destroyed=true;if(confMan.lt){confMan.lt.destroy();}
|
||||
if(confMan.params.laData.modChannel){confMan.verto.unsubscribe(confMan.params.laData.modChannel);}
|
||||
if(confMan.params.mainModID){$(confMan.params.mainModID).html("");}}
|
||||
$.verto.dialog=function(direction,verto,params){var dialog=this;dialog.params=$.extend({useVideo:verto.options.useVideo,useStereo:verto.options.useStereo,tag:verto.options.tag,login:verto.options.login},params);dialog.verto=verto;dialog.direction=direction;dialog.lastState=null;dialog.state=dialog.lastState=$.verto.enum.state.new;dialog.callbacks=verto.callbacks;dialog.answered=false;dialog.attach=params.attach||false;if(dialog.params.callID){dialog.callID=dialog.params.callID;}else{dialog.callID=dialog.params.callID=generateGUID();}
|
||||
if(confMan.params.mainModID){$(confMan.params.mainModID).html("");}};$.verto.dialog=function(direction,verto,params){var dialog=this;dialog.params=$.extend({useVideo:verto.options.useVideo,useStereo:verto.options.useStereo,tag:verto.options.tag,login:verto.options.login},params);dialog.verto=verto;dialog.direction=direction;dialog.lastState=null;dialog.state=dialog.lastState=$.verto.enum.state.new;dialog.callbacks=verto.callbacks;dialog.answered=false;dialog.attach=params.attach||false;if(dialog.params.callID){dialog.callID=dialog.params.callID;}else{dialog.callID=dialog.params.callID=generateGUID();}
|
||||
if(dialog.params.tag){dialog.audioStream=document.getElementById(dialog.params.tag);if(dialog.params.useVideo){dialog.videoStream=dialog.audioStream;}}
|
||||
dialog.verto.dialogs[dialog.callID]=dialog;var RTCcallbacks={};if(dialog.direction==$.verto.enum.direction.inbound){if(dialog.params.display_direction==="outbound"){dialog.params.remote_caller_id_name=dialog.params.caller_id_name;dialog.params.remote_caller_id_number=dialog.params.caller_id_number;}else{dialog.params.remote_caller_id_name=dialog.params.callee_id_name;dialog.params.remote_caller_id_number=dialog.params.callee_id_number;}
|
||||
if(!dialog.params.remote_caller_id_name){dialog.params.remote_caller_id_name="Nobody";}
|
||||
@@ -216,7 +203,7 @@ if(err){return false;}
|
||||
dialog.sendMethod("verto.info",{msg:msg});return true;};$.verto.dialog.prototype.answer=function(params){var dialog=this;if(!dialog.answered){if(params){if(params.useVideo){dialog.useVideo(true);}
|
||||
dialog.params.callee_id_name=params.callee_id_name;dialog.params.callee_id_number=params.callee_id_number;}
|
||||
dialog.rtc.createAnswer(dialog.params.sdp);dialog.answered=true;}};$.verto.dialog.prototype.handleAnswer=function(params){var dialog=this;dialog.gotAnswer=true;if(dialog.state.val>=$.verto.enum.state.active.val){return;}
|
||||
if(dialog.state.val>=$.verto.enum.state.early.val){dialog.setState($.verto.enum.state.active);}else{if(dialog.gotEarly){console.log("Dialog "+dialog.callID+"Got answer while still establishing early media, delaying...");}else{console.log("Dialog "+dialog.callID+"Answering Channel");dialog.rtc.answer(params.sdp,function(){dialog.setState($.verto.enum.state.active);},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"ANSWER SDP",params.sdp);}}};$.verto.dialog.prototype.cidString=function(enc){var dialog=this;var party=dialog.params.remote_caller_id_name+(enc?" <":" <")+dialog.params.remote_caller_id_number+(enc?">":">");return party;};$.verto.dialog.prototype.sendMessage=function(msg,params){var dialog=this;if(dialog.callbacks.onMessage){dialog.callbacks.onMessage(dialog.verto,dialog,msg,params);}};$.verto.dialog.prototype.handleInfo=function(params){var dialog=this;dialog.sendMessage($.verto.enum.message.info,params.msg);};$.verto.dialog.prototype.handleDisplay=function(params){var dialog=this;if(params.display_name){dialog.params.remote_caller_id_name=params.display_name;}
|
||||
if(dialog.state.val>=$.verto.enum.state.early.val){dialog.setState($.verto.enum.state.active);}else{if(dialog.gotEarly){console.log("Dialog "+dialog.callID+" Got answer while still establishing early media, delaying...");}else{console.log("Dialog "+dialog.callID+" Answering Channel");dialog.rtc.answer(params.sdp,function(){dialog.setState($.verto.enum.state.active);},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"ANSWER SDP",params.sdp);}}};$.verto.dialog.prototype.cidString=function(enc){var dialog=this;var party=dialog.params.remote_caller_id_name+(enc?" <":" <")+dialog.params.remote_caller_id_number+(enc?">":">");return party;};$.verto.dialog.prototype.sendMessage=function(msg,params){var dialog=this;if(dialog.callbacks.onMessage){dialog.callbacks.onMessage(dialog.verto,dialog,msg,params);}};$.verto.dialog.prototype.handleInfo=function(params){var dialog=this;dialog.sendMessage($.verto.enum.message.info,params.msg);};$.verto.dialog.prototype.handleDisplay=function(params){var dialog=this;if(params.display_name){dialog.params.remote_caller_id_name=params.display_name;}
|
||||
if(params.display_number){dialog.params.remote_caller_id_number=params.display_number;}
|
||||
dialog.sendMessage($.verto.enum.message.display,{});};$.verto.dialog.prototype.handleMedia=function(params){var dialog=this;if(dialog.state.val>=$.verto.enum.state.early.val){return;}
|
||||
dialog.gotEarly=true;dialog.rtc.answer(params.sdp,function(){console.log("Dialog "+dialog.callID+"Establishing early media");dialog.setState($.verto.enum.state.early);if(dialog.gotAnswer){console.log("Dialog "+dialog.callID+"Answering Channel");dialog.setState($.verto.enum.state.active);}},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"EARLY SDP",params.sdp);};$.verto.ENUM=function(s){var i=0,o={};s.split(" ").map(function(x){o[x]={name:x,val:i++};});return Object.freeze(o);};$.verto.enum={};$.verto.enum.states=Object.freeze({new:{requesting:1,recovering:1,ringing:1,destroy:1,answering:1},requesting:{trying:1,hangup:1},recovering:{answering:1,hangup:1},trying:{active:1,early:1,hangup:1},ringing:{answering:1,hangup:1},answering:{active:1,hangup:1},active:{answering:1,requesting:1,hangup:1,held:1},held:{hangup:1,active:1},early:{hangup:1,active:1},hangup:{destroy:1},destroy:{},purge:{destroy:1}});$.verto.enum.state=$.verto.ENUM("new requesting trying recovering ringing answering early active held hangup destroy purge");$.verto.enum.direction=$.verto.ENUM("inbound outbound");$.verto.enum.message=$.verto.ENUM("display info pvtEvent");$.verto.enum=Object.freeze($.verto.enum);$.verto.saved=[];$(window).bind('beforeunload',function(){for(var i in $.verto.saved){var verto=$.verto.saved[i];if(verto){verto.logout();verto.purge();}}
|
||||
|
||||
@@ -308,10 +308,8 @@ var callbacks = {
|
||||
|
||||
},
|
||||
onWSClose: function(v, success) {
|
||||
if ($('#online').is(':visible')) {
|
||||
display("");
|
||||
online(false);
|
||||
}
|
||||
display("");
|
||||
online(false);
|
||||
var today = new Date();
|
||||
$("#errordisplay").html("Connection Error.<br>Last Attempt: " + today);
|
||||
goto_page("main");
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
jsmin
|
||||
node_modules
|
||||
verto-max.js
|
||||
verto-min.js
|
||||
@@ -0,0 +1,30 @@
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
jshint: {
|
||||
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
files: ['<%= jshint.files %>'],
|
||||
tasks: ['jshint']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
|
||||
grunt.registerTask('default', ['jshint']);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "verto",
|
||||
"version": "0.0.1",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-jshint": "~0.10.0",
|
||||
"grunt-contrib-watch": "*"
|
||||
}
|
||||
}
|
||||
@@ -93,15 +93,22 @@
|
||||
candidateList: []
|
||||
};
|
||||
|
||||
this.constraints = {
|
||||
optional: [{
|
||||
'DtlsSrtpKeyAgreement': 'true'
|
||||
}],
|
||||
mandatory: {
|
||||
OfferToReceiveAudio: true,
|
||||
OfferToReceiveVideo: this.options.useVideo ? true : false,
|
||||
}
|
||||
};
|
||||
|
||||
if (moz) {
|
||||
this.constraints = {
|
||||
offerToReceiveAudio: true,
|
||||
offerToReceiveVideo: this.options.useVideo ? true : false,
|
||||
};
|
||||
} else {
|
||||
this.constraints = {
|
||||
optional: [{
|
||||
'DtlsSrtpKeyAgreement': 'true'
|
||||
}],mandatory: {
|
||||
OfferToReceiveAudio: true,
|
||||
OfferToReceiveVideo: this.options.useVideo ? true : false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (self.options.useVideo) {
|
||||
self.options.useVideo.style.display = 'none';
|
||||
@@ -116,10 +123,18 @@
|
||||
|
||||
if (obj) {
|
||||
self.options.useVideo = obj;
|
||||
self.constraints.mandatory.OfferToReceiveVideo = true;
|
||||
if (moz) {
|
||||
self.constraints.offerToReceiveVideo = true;
|
||||
} else {
|
||||
self.constraints.mandatory.OfferToReceiveVideo = true;
|
||||
}
|
||||
} else {
|
||||
self.options.useVideo = null;
|
||||
self.constraints.mandatory.OfferToReceiveVideo = false;
|
||||
if (moz) {
|
||||
self.constraints.offerToReceiveVideo = false;
|
||||
} else {
|
||||
self.constraints.mandatory.OfferToReceiveVideo = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.options.useVideo) {
|
||||
@@ -176,8 +191,8 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
function onStreamError(self) {
|
||||
console.log('There has been a problem retrieving the streams - did you allow access?');
|
||||
function onStreamError(self, e) {
|
||||
console.log('There has been a problem retrieving the streams - did you allow access?', e);
|
||||
|
||||
}
|
||||
|
||||
@@ -317,16 +332,36 @@
|
||||
onStreamSuccess(self);
|
||||
}
|
||||
|
||||
function onError() {
|
||||
onStreamError(self);
|
||||
function onError(e) {
|
||||
onStreamError(self, e);
|
||||
}
|
||||
|
||||
|
||||
var audio;
|
||||
|
||||
if (this.options.videoParams && this.options.videoParams.chromeMediaSource == 'screen') {
|
||||
|
||||
this.options.videoParams = {
|
||||
chromeMediaSource: 'screen',
|
||||
maxWidth:screen.width,
|
||||
maxHeight:screen.height
|
||||
};
|
||||
|
||||
console.error("SCREEN SHARE");
|
||||
audio = false;
|
||||
} else {
|
||||
audio = {
|
||||
mandatory: this.options.audioParams,
|
||||
optional: []
|
||||
};
|
||||
}
|
||||
|
||||
console.log("Mandatory audio constraints", this.options.audioParams);
|
||||
console.log("Mandatory video constraints", this.options.videoParams);
|
||||
|
||||
getUserMedia({
|
||||
constraints: {
|
||||
audio: {
|
||||
mandatory: this.options.audioParams,
|
||||
optional: []
|
||||
},
|
||||
audio: audio,
|
||||
video: this.options.useVideo ? {
|
||||
mandatory: this.options.videoParams,
|
||||
optional: []
|
||||
@@ -377,16 +412,37 @@
|
||||
onStreamSuccess(self);
|
||||
}
|
||||
|
||||
function onError() {
|
||||
onStreamError(self);
|
||||
function onError(e) {
|
||||
onStreamError(self, e);
|
||||
}
|
||||
|
||||
|
||||
var audio;
|
||||
|
||||
if (this.options.videoParams && this.options.videoParams.chromeMediaSource == 'screen') {
|
||||
|
||||
this.options.videoParams = {
|
||||
chromeMediaSource: 'screen',
|
||||
maxWidth:screen.width,
|
||||
maxHeight:screen.height
|
||||
};
|
||||
|
||||
console.error("SCREEN SHARE");
|
||||
audio = false;
|
||||
} else {
|
||||
audio = {
|
||||
mandatory: this.options.audioParams,
|
||||
optional: []
|
||||
};
|
||||
}
|
||||
|
||||
console.log("Mandatory audio constraints", this.options.audioParams);
|
||||
console.log("Mandatory video constraints", this.options.videoParams);
|
||||
|
||||
|
||||
getUserMedia({
|
||||
constraints: {
|
||||
audio: {
|
||||
mandatory: this.options.audioParams,
|
||||
optional: []
|
||||
},
|
||||
audio: audio,
|
||||
video: this.options.useVideo ? {
|
||||
mandatory: this.options.videoParams,
|
||||
optional: []
|
||||
@@ -431,13 +487,13 @@
|
||||
var iceServers = null;
|
||||
|
||||
if (options.iceServers) {
|
||||
var tmp = options.iceServers;;
|
||||
var tmp = options.iceServers;
|
||||
|
||||
if (typeof(tmp) === "boolean") {
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
if (tmp && typeof(tmp) !== "array") {
|
||||
if (tmp && !(typeof(tmp) == "object" && tmp.constructor === Array)) {
|
||||
console.warn("iceServers must be an array, reverting to default ice servers");
|
||||
tmp = null;
|
||||
}
|
||||
@@ -484,7 +540,11 @@
|
||||
}
|
||||
|
||||
if (options.type == "offer") {
|
||||
if (!moz && !x && options.onICESDP) {
|
||||
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
|
||||
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
|
||||
to handle partial setups to maybe save 100m
|
||||
*/
|
||||
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
|
||||
options.onICESDP(peer.localDescription);
|
||||
//x = 1;
|
||||
/*
|
||||
@@ -545,11 +605,8 @@
|
||||
};
|
||||
|
||||
var constraints = options.constraints || {
|
||||
optional: [],
|
||||
mandatory: {
|
||||
OfferToReceiveAudio: true,
|
||||
OfferToReceiveVideo: true
|
||||
}
|
||||
offerToReceiveAudio: true,
|
||||
offerToReceiveVideo: true
|
||||
};
|
||||
|
||||
// onOfferSDP(RTCSessionDescription)
|
||||
@@ -560,8 +617,10 @@
|
||||
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
|
||||
peer.setLocalDescription(sessionDescription);
|
||||
options.onOfferSDP(sessionDescription);
|
||||
if (moz && options.onICESDP) {
|
||||
/* old mozilla behaviour the SDP was already great right away */
|
||||
if (moz && options.onICESDP && sessionDescription.sdp.match(/a=candidate/)) {
|
||||
options.onICESDP(sessionDescription);
|
||||
options.sentICESDP = 1;
|
||||
}
|
||||
},
|
||||
onSdpError, constraints);
|
||||
|
||||
@@ -247,19 +247,19 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
$.JsonRpcClient.prototype.closeSocket = function() {
|
||||
if (self.socketReady()) {
|
||||
this._ws_socket.onclose = function (w) {console.log("Closing Socket")}
|
||||
this._ws_socket.onclose = function (w) {console.log("Closing Socket");};
|
||||
this._ws_socket.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.JsonRpcClient.prototype.loginData = function(params) {
|
||||
self.options.login = params.login;
|
||||
self.options.passwd = params.passwd;
|
||||
}
|
||||
};
|
||||
|
||||
$.JsonRpcClient.prototype.connectSocket = function(onmessage_cb) {
|
||||
var self = this;
|
||||
@@ -299,10 +299,10 @@
|
||||
|
||||
self.ws_cnt++;
|
||||
|
||||
if (self.ws_sleep < 3000 && (self.ws_cnt % 10) == 0) {
|
||||
if (self.ws_sleep < 3000 && (self.ws_cnt % 10) === 0) {
|
||||
self.ws_sleep += 1000;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Set up sending of message for when the socket is open.
|
||||
self._ws_socket.onopen = function() {
|
||||
@@ -317,15 +317,15 @@
|
||||
|
||||
var req;
|
||||
// Send the requests.
|
||||
while (req = $.JsonRpcClient.q.pop()) {
|
||||
while ((req = $.JsonRpcClient.q.pop())) {
|
||||
self._ws_socket.send(req);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return self._ws_socket ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
$.JsonRpcClient.prototype._getSocket = function(onmessage_cb) {
|
||||
// If there is no ws url set, we don't have a socket.
|
||||
@@ -381,9 +381,9 @@
|
||||
|
||||
/// @todo Make using the jsonrcp 2.0 check optional, to use this on JSON-RPC 1 backends.
|
||||
|
||||
if (typeof response === 'object'
|
||||
&& 'jsonrpc' in response
|
||||
&& response.jsonrpc === '2.0') {
|
||||
if (typeof response === 'object' &&
|
||||
'jsonrpc' in response &&
|
||||
response.jsonrpc === '2.0') {
|
||||
|
||||
/// @todo Handle bad response (without id).
|
||||
|
||||
@@ -419,8 +419,7 @@
|
||||
self.authing = true;
|
||||
|
||||
this.call("login", { login: self.options.login, passwd: self.options.passwd},
|
||||
this._ws_callbacks[response.id].request_obj.method == "login"
|
||||
?
|
||||
this._ws_callbacks[response.id].request_obj.method == "login" ?
|
||||
function(e) {
|
||||
self.authing = false;
|
||||
console.log("logged in");
|
||||
@@ -575,14 +574,18 @@
|
||||
// Collect all request data and sort handlers by request id.
|
||||
var batch_request = [];
|
||||
var handlers = {};
|
||||
var i = 0;
|
||||
var call;
|
||||
var success_cb;
|
||||
var error_cb;
|
||||
|
||||
// If we have a WebSocket, just send the requests individually like normal calls.
|
||||
var socket = self.jsonrpcclient.options.getSocket(self.jsonrpcclient.wsOnMessage);
|
||||
if (socket !== null) {
|
||||
for (var i = 0; i < this._requests.length; i++) {
|
||||
var call = this._requests[i];
|
||||
var success_cb = ('success_cb' in call) ? call.success_cb : undefined;
|
||||
var error_cb = ('error_cb' in call) ? call.error_cb : undefined;
|
||||
for (i = 0; i < this._requests.length; i++) {
|
||||
call = this._requests[i];
|
||||
success_cb = ('success_cb' in call) ? call.success_cb : undefined;
|
||||
error_cb = ('error_cb' in call) ? call.error_cb : undefined;
|
||||
self.jsonrpcclient._wsCall(socket, call.request, success_cb, error_cb);
|
||||
}
|
||||
|
||||
@@ -590,8 +593,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < this._requests.length; i++) {
|
||||
var call = this._requests[i];
|
||||
for (i = 0; i < this._requests.length; i++) {
|
||||
call = this._requests[i];
|
||||
batch_request.push(call.request);
|
||||
|
||||
// If the request has an id, it should handle returns (otherwise it's a notify).
|
||||
@@ -603,7 +606,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
var success_cb = function(data) { self._batchCb(data, handlers, self.all_done_cb); };
|
||||
success_cb = function(data) { self._batchCb(data, handlers, self.all_done_cb); };
|
||||
|
||||
// No WebSocket, and no HTTP backend? This won't work.
|
||||
if (self.jsonrpcclient.options.ajaxUrl === null) {
|
||||
|
||||
@@ -118,6 +118,11 @@
|
||||
|
||||
};
|
||||
|
||||
$.verto.prototype.videoParams = function(on) {
|
||||
var verto = this;
|
||||
verto.options.videoParams = on;
|
||||
};
|
||||
|
||||
$.verto.prototype.iceServers = function(on) {
|
||||
var verto = this;
|
||||
verto.options.iceServers = on;
|
||||
@@ -132,6 +137,9 @@
|
||||
$.verto.prototype.logout = function(msg) {
|
||||
var verto = this;
|
||||
verto.rpcClient.closeSocket();
|
||||
if (verto.callbacks.onWSClose) {
|
||||
verto.callbacks.onWSClose(verto, false);
|
||||
}
|
||||
verto.purge();
|
||||
};
|
||||
|
||||
@@ -490,6 +498,10 @@
|
||||
};
|
||||
} else {
|
||||
switch (data.method) {
|
||||
case 'verto.punt':
|
||||
verto.purge();
|
||||
verto.logout();
|
||||
break;
|
||||
case 'verto.event':
|
||||
var list = null;
|
||||
var key = null;
|
||||
@@ -1137,7 +1149,7 @@
|
||||
|
||||
$.verto.confMan = function(verto, params) {
|
||||
var confMan = this;
|
||||
conf
|
||||
|
||||
confMan.params = $.extend({
|
||||
tableID: null,
|
||||
statusID: null,
|
||||
@@ -1164,9 +1176,8 @@
|
||||
"<button class='ctlbtn' id='" + play_id + "'>Play</button>" +
|
||||
"<button class='ctlbtn' id='" + stop_id + "'>Stop</button>" +
|
||||
"<button class='ctlbtn' id='" + recording_id + "'>Record</button>" +
|
||||
"<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>"
|
||||
|
||||
+ "<br><br></div>";
|
||||
"<button class='ctlbtn' id='" + rec_stop_id + "'>Record Stop</button>" +
|
||||
"<br><br></div>";
|
||||
|
||||
jq.html(html);
|
||||
|
||||
@@ -1260,7 +1271,7 @@
|
||||
|
||||
if (confMan.params.mainModID) {
|
||||
genMainMod($(confMan.params.mainModID));
|
||||
$(confMan.params.displayID).html("Moderator Controls Ready<br><br>")
|
||||
$(confMan.params.displayID).html("Moderator Controls Ready<br><br>");
|
||||
} else {
|
||||
$(confMan.params.mainModID).html("");
|
||||
}
|
||||
@@ -1277,7 +1288,7 @@
|
||||
clearTimeout(confMan.lastTimeout);
|
||||
confMan.lastTimeout = 0;
|
||||
}
|
||||
confMan.lastTimeout = setTimeout(function() { $(confMan.params.displayID).html(confMan.destroyed ? "" : "Moderator Controls Ready<br><br>")}, 4000);
|
||||
confMan.lastTimeout = setTimeout(function() { $(confMan.params.displayID).html(confMan.destroyed ? "" : "Moderator Controls Ready<br><br>");}, 4000);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1349,7 +1360,7 @@
|
||||
"fnRowCallback": row_callback
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.verto.confMan.prototype.modCommand = function(cmd, id, value) {
|
||||
var confMan = this;
|
||||
@@ -1363,7 +1374,7 @@
|
||||
"value": value
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.verto.confMan.prototype.destroy = function() {
|
||||
var confMan = this;
|
||||
@@ -1381,7 +1392,7 @@
|
||||
if (confMan.params.mainModID) {
|
||||
$(confMan.params.mainModID).html("");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.verto.dialog = function(direction, verto, params) {
|
||||
var dialog = this;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
|
||||
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
noinst_SCRIPTS = broadvoice.spec
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
|
||||
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
|
||||
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
EXTRA_DIST = libbroadvoice.dsp \
|
||||
|
||||
@@ -74,7 +74,7 @@ phpmod: $(MYLIB)
|
||||
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C php
|
||||
|
||||
luamod: $(MYLIB)
|
||||
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C lua
|
||||
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" LUA_CFLAGS="$(LUA_CFLAGS)" LUA_LIBS="$(LUA_LIBS)" -C lua
|
||||
|
||||
pymod: $(MYLIB)
|
||||
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python
|
||||
|
||||
+20
-1
@@ -57,6 +57,8 @@ typedef struct {
|
||||
char pass[128];
|
||||
int debug;
|
||||
const char *console_fnkeys[12];
|
||||
const char *console_fnkeys_toggle[12];
|
||||
int console_fnkeys_state[12];
|
||||
char loglevel[128];
|
||||
int log_uuid;
|
||||
int log_uuid_length;
|
||||
@@ -158,8 +160,15 @@ static void screen_size(int *x, int *y)
|
||||
static unsigned char console_fnkey_pressed(int i)
|
||||
{
|
||||
const char *c;
|
||||
int fnkey;
|
||||
assert((i > 0) && (i <= 12));
|
||||
if (!(c = global_profile->console_fnkeys[i - 1])) {
|
||||
fnkey = i - 1;
|
||||
|
||||
if ((c = global_profile->console_fnkeys_toggle[fnkey]) && global_profile->console_fnkeys_state[fnkey]) {
|
||||
global_profile->console_fnkeys_state[fnkey] = 0;
|
||||
} else if ((c = global_profile->console_fnkeys[fnkey])) {
|
||||
global_profile->console_fnkeys_state[fnkey] = 1;
|
||||
} else {
|
||||
printf("\n");
|
||||
esl_log(ESL_LOG_ERROR, "FUNCTION KEY F%d IS NOT BOUND, please edit your config.\n", i);
|
||||
return CC_REDISPLAY;
|
||||
@@ -1278,6 +1287,14 @@ static void read_config(const char *dft_cfile, const char *cfile) {
|
||||
profiles[pcount-1].console_fnkeys[i - 1] = strdup(val);
|
||||
}
|
||||
}
|
||||
} else if (!strncasecmp(var, "key_toggle_F", 12)) {
|
||||
char *key = var + 12;
|
||||
if (key) {
|
||||
int i = atoi(key);
|
||||
if (i > 0 && i < 13) {
|
||||
profiles[pcount-1].console_fnkeys_toggle[i - 1] = strdup(val);
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(var, "timeout")) {
|
||||
timeout = atoi(val);
|
||||
} else if (!strcasecmp(var, "connect-timeout")) {
|
||||
@@ -1674,6 +1691,8 @@ int main(int argc, char *argv[])
|
||||
goto done;
|
||||
}
|
||||
history(myhistory, &ev, H_SETSIZE, 800);
|
||||
/* Ignore duplicate lines */
|
||||
history(myhistory, &ev, H_SETUNIQUE, 1);
|
||||
el_set(el, EL_HIST, history, myhistory);
|
||||
if (use_history_file) history(myhistory, &ev, H_LOAD, hfile);
|
||||
el_source(el, NULL);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
LOCAL_CFLAGS=
|
||||
LOCAL_LDFLAGS=-llua -lpthread
|
||||
LOCAL_LDFLAGS=$(LUA_LIBS) -lpthread
|
||||
WRAP_GCC_WARNING_SILENCE=-Wno-unused-function
|
||||
|
||||
all: ESL.so
|
||||
|
||||
esl_wrap.cpp:
|
||||
swig -module ESL -lua -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
|
||||
swig2.0 -module ESL -lua -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
|
||||
|
||||
esl_wrap.o: esl_wrap.cpp
|
||||
$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) $(WRAP_GCC_WARNING_SILENCE) -c esl_wrap.cpp -o esl_wrap.o
|
||||
$(CXX) $(CXX_CFLAGS) $(LUA_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) $(WRAP_GCC_WARNING_SILENCE) -c esl_wrap.cpp -o esl_wrap.o
|
||||
|
||||
ESL.so: esl_wrap.o
|
||||
$(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o ESL.so -L. $(LIBS)
|
||||
|
||||
+484
-383
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
AM_CFLAGS = -Isrc -fPIC -Wall -O3 -lm
|
||||
AUTOMAKE_OPTS = gnu
|
||||
AUTOMAKE_OPTIONS = gnu subdir-objects
|
||||
NAME = codec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AM_CFLAGS = -I../src -fPIC -Wall -O3 -g
|
||||
AUTOMAKE_OPTS = gnu
|
||||
AUTOMAKE_OPTIONS = gnu subdir-objects
|
||||
NAME = codec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AM_CFLAGS = -I../src -I$(abs_srcdir)/../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall
|
||||
AUTOMAKE_OPTS = gnu
|
||||
AUTOMAKE_OPTIONS = gnu subdir-objects
|
||||
NAME = libcodec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EXTRA_DIST =
|
||||
SUBDIRS =
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
NAME=dingaling
|
||||
PREFIX=$(prefix)
|
||||
TOUCH_TARGET=@if test -f "$@" ; then touch "$@" ; fi ;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
# Viktor Krikun <v.krikun@soft-industry.com> <v.krikun@gmail.com>
|
||||
#
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
libzrtp_includedir=$(includedir)/libzrtp
|
||||
libzrtp_include_HEADERS = \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AM_CFLAGS = -Isrc -I$(abs_srcdir)/src -Iinterface -I$(abs_srcdir)/interface -fPIC -O3
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
AUTOMAKE_OPTIONS = gnu subdir-objects
|
||||
NAME = libSKP_SILK_SDK
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
Fri Dec 12 10:24:52 CST 2014
|
||||
Wed Jan 7 11:24:56 PST 2015
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
# Licensed under LGPL. See file COPYING.
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign 1.7
|
||||
AUTOMAKE_OPTIONS = foreign 1.7 subdir-objects
|
||||
|
||||
SUBDIRS = libsofia-sip-ua $(GLIB_SUBDIRS) packages # tests s2check utils
|
||||
DIST_SUBDIRS = s2check libsofia-sip-ua libsofia-sip-ua-glib utils packages \
|
||||
|
||||
@@ -76,7 +76,7 @@ check_nta_SOURCES = check_nta.c check_nta.h \
|
||||
check_nta_LDADD = ${LDADD} @CHECK_LIBS@
|
||||
|
||||
else
|
||||
check_nta_SOURCES = $(top_srcdir)/s2check/exit77.c
|
||||
check_nta_SOURCES = exit77.c
|
||||
endif
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
@@ -309,9 +309,12 @@ int ws_handshake(wsh_t *wsh)
|
||||
"%s\r\n",
|
||||
b64,
|
||||
proto_buf);
|
||||
respond[511] = 0;
|
||||
|
||||
if (ws_raw_write(wsh, respond, strlen(respond)) != strlen(respond)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
wsh->handshake = 1;
|
||||
|
||||
return 0;
|
||||
@@ -322,6 +325,7 @@ int ws_handshake(wsh_t *wsh)
|
||||
|
||||
snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n"
|
||||
"Sec-WebSocket-Version: 13\r\n\r\n");
|
||||
respond[511] = 0;
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
|
||||
@@ -399,13 +403,19 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
||||
|
||||
ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
{
|
||||
size_t r;
|
||||
ssize_t r;
|
||||
int sanity = 2000;
|
||||
int ssl_err = 0;
|
||||
ssize_t wrote = 0;
|
||||
|
||||
if (wsh->ssl) {
|
||||
do {
|
||||
r = SSL_write(wsh->ssl, data, bytes);
|
||||
r = SSL_write(wsh->ssl, (void *)((unsigned char *)data + wrote), bytes - wrote);
|
||||
|
||||
if (r > 0) {
|
||||
wrote += r;
|
||||
}
|
||||
|
||||
if (sanity < 2000) {
|
||||
ms_sleep(1);
|
||||
}
|
||||
@@ -414,7 +424,7 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
ssl_err = SSL_get_error(wsh->ssl, r);
|
||||
}
|
||||
|
||||
} while (--sanity > 0 && r == -1 && ssl_err == SSL_ERROR_WANT_WRITE);
|
||||
} while (--sanity > 0 && ((r == -1 && ssl_err == SSL_ERROR_WANT_WRITE) || (wsh->block && wrote < bytes)));
|
||||
|
||||
if (ssl_err) {
|
||||
r = ssl_err * -1;
|
||||
@@ -424,12 +434,18 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
}
|
||||
|
||||
do {
|
||||
r = send(wsh->sock, data, bytes, 0);
|
||||
r = send(wsh->sock, (void *)((unsigned char *)data + wrote), bytes - wrote, 0);
|
||||
|
||||
if (r > 0) {
|
||||
wrote += r;
|
||||
}
|
||||
|
||||
if (sanity < 2000) {
|
||||
ms_sleep(1);
|
||||
}
|
||||
} while (--sanity > 0 && r == -1 && xp_is_blocking(xp_errno()));
|
||||
|
||||
|
||||
} while (--sanity > 0 && ((r == -1 && xp_is_blocking(xp_errno())) || (wsh->block && wrote < bytes)));
|
||||
|
||||
//if (r<0) {
|
||||
//printf("wRITE FAIL: %s\n", strerror(errno));
|
||||
//}
|
||||
@@ -656,7 +672,11 @@ ssize_t ws_close(wsh_t *wsh, int16_t reason)
|
||||
restore_socket(wsh->sock);
|
||||
|
||||
if (wsh->close_sock && wsh->sock != ws_sock_invalid) {
|
||||
#ifndef WIN32
|
||||
close(wsh->sock);
|
||||
#else
|
||||
closesocket(wsh->sock);
|
||||
#endif
|
||||
}
|
||||
|
||||
wsh->sock = ws_sock_invalid;
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -26,7 +26,9 @@
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
#define snprintf _snprintf
|
||||
#ifdef _WIN64
|
||||
#define WS_SSIZE_T __int64
|
||||
@@ -48,8 +50,12 @@ struct ws_globals_s {
|
||||
|
||||
extern struct ws_globals_s ws_globals;
|
||||
|
||||
#ifndef WIN32
|
||||
typedef int ws_socket_t;
|
||||
#define ws_sock_invalid -1
|
||||
#else
|
||||
typedef SOCKET ws_socket_t;
|
||||
#endif
|
||||
#define ws_sock_invalid (ws_socket_t)-1
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
# Licensed under LGPL. See file COPYING.
|
||||
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Header paths
|
||||
|
||||
@@ -28,7 +30,7 @@ libs2_a_SOURCES = s2check.h s2tcase.c \
|
||||
# ----------------------------------------------------------------------
|
||||
# Install and distribution rules
|
||||
|
||||
EXTRA_DIST = exit77.c
|
||||
EXTRA_DIST =
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
AUTOMAKE_OPTIONS = gnu subdir-objects
|
||||
AM_CFLAGS = $(new_AM_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/crypto/include
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
AM_LDFLAGS = $(new_AM_LDFLAGS) -L$(srcdir) -lsrtp
|
||||
|
||||
@@ -174,8 +174,6 @@ struct switch_core_session {
|
||||
uint32_t soft_lock;
|
||||
switch_ivr_dmachine_t *dmachine[2];
|
||||
plc_state_t *plc;
|
||||
uint8_t recur_buffer[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
switch_size_t recur_buffer_len;
|
||||
|
||||
switch_media_handle_t *media_handle;
|
||||
uint32_t decoder_errors;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
|
||||
* Joseph Sullivan <jossulli@amazon.com>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
* switch_core.h -- Core Library
|
||||
*
|
||||
@@ -2437,6 +2438,13 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_
|
||||
const char *file, const char *func, int line);
|
||||
#define switch_cache_db_get_db_handle_dsn(_a, _b) _switch_cache_db_get_db_handle_dsn(_a, _b, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
/*!
|
||||
\brief Executes the create schema sql
|
||||
\param [in] dbh The handle
|
||||
\param [in] sql - sql to run
|
||||
\param [out] err - Error if it exists
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err);
|
||||
/*!
|
||||
\brief Executes the sql and returns the result as a string
|
||||
\param [in] dbh The handle
|
||||
|
||||
@@ -1338,6 +1338,7 @@ typedef enum {
|
||||
CF_WINNER,
|
||||
CF_CONTROLLED,
|
||||
CF_PROXY_MODE,
|
||||
CF_PROXY_OFF,
|
||||
CF_SUSPEND,
|
||||
CF_EVENT_PARSE,
|
||||
CF_GEN_RINGBACK,
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_URL_UNSAFE "\r\n \"#%&+:;<=>?@[\\]^`{|}"
|
||||
|
||||
|
||||
/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
|
||||
http://www.azillionmonkeys.com/qed/asmexample.html
|
||||
*/
|
||||
@@ -971,6 +974,29 @@ SWITCH_DECLARE(char *) switch_util_quote_shell_arg_pool(const char *string, swit
|
||||
|
||||
|
||||
#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK || status == SWITCH_STATUS_INUSE)
|
||||
|
||||
static inline int switch_needs_url_encode(const char *s)
|
||||
{
|
||||
const char hex[] = "0123456789ABCDEF";
|
||||
const char *p, *e = end_of_p(s);
|
||||
|
||||
|
||||
for(p = s; p && *p; p++) {
|
||||
if (*p == '%' && e-p > 1) {
|
||||
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(SWITCH_URL_UNSAFE, *p)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len);
|
||||
SWITCH_DECLARE(char *) switch_url_decode(char *s);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
||||
|
||||
@@ -3173,8 +3173,13 @@ SWITCH_STANDARD_JSON_API(json_stats_function)
|
||||
audio_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(tsession));
|
||||
video_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_VIDEO, switch_core_session_get_pool(tsession));
|
||||
|
||||
jsonify_stats(reply, "audio", audio_stats);
|
||||
jsonify_stats(reply, "video", video_stats);
|
||||
if (audio_stats) {
|
||||
jsonify_stats(reply, "audio", audio_stats);
|
||||
}
|
||||
|
||||
if (video_stats) {
|
||||
jsonify_stats(reply, "video", video_stats);
|
||||
}
|
||||
|
||||
if (true_enough(cdata) && switch_ivr_generate_json_cdr(tsession, &jevent, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
cJSON_AddItemToObject(reply, "channelData", jevent);
|
||||
|
||||
@@ -2578,6 +2578,7 @@ static void conference_set_floor_holder(conference_obj_t *conference, conference
|
||||
}
|
||||
|
||||
if (conference->floor_holder) {
|
||||
conference_add_event_member_data(conference->floor_holder, event);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-ID", "%d", conference->floor_holder->id);
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "New-ID", "none");
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* Mathieu Rene <mathieu.rene@gmail.com>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
* mod_db.c -- Implements simple db API, group support, and limit db backend
|
||||
*
|
||||
@@ -325,7 +326,7 @@ static switch_status_t do_config()
|
||||
switch_cache_db_test_reactive(dbh, "select * from group_data", NULL, group_sql);
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_cache_db_execute_sql(dbh, indexes[x], NULL);
|
||||
switch_cache_db_create_schema(dbh, indexes[x], NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
|
||||
@@ -149,6 +149,8 @@ static struct {
|
||||
hash_node_t *hash_root;
|
||||
hash_node_t *hash_tail;
|
||||
switch_hash_t *profile_hash;
|
||||
switch_hash_t *request_hash;
|
||||
switch_mutex_t *request_mutex;
|
||||
switch_hash_t *parse_hash;
|
||||
char cache_path[128];
|
||||
int debug;
|
||||
@@ -170,7 +172,6 @@ struct http_file_context {
|
||||
char *cache_file;
|
||||
char *cache_file_base;
|
||||
char *meta_file;
|
||||
char *lock_file;
|
||||
char *metadata;
|
||||
time_t expires;
|
||||
switch_file_t *lock_fd;
|
||||
@@ -192,6 +193,9 @@ struct http_file_context {
|
||||
char *name;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
} write;
|
||||
|
||||
switch_mutex_t *mutex;
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
};
|
||||
|
||||
typedef struct http_file_context http_file_context_t;
|
||||
@@ -2381,7 +2385,6 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
|
||||
|
||||
context->cache_file_base = switch_core_sprintf(context->pool, "%s%s%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
|
||||
context->meta_file = switch_core_sprintf(context->pool, "%s%s%s.meta", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
|
||||
context->lock_file = switch_core_sprintf(context->pool, "%s%s%s.lock", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
|
||||
|
||||
if (switch_file_exists(context->meta_file, context->pool) == SWITCH_STATUS_SUCCESS && ((fd = open(context->meta_file, O_RDONLY, 0)) > -1)) {
|
||||
if ((bytes = read(fd, meta_buffer, sizeof(meta_buffer))) > 0) {
|
||||
@@ -2416,24 +2419,31 @@ static size_t save_file_callback(void *ptr, size_t size, size_t nmemb, void *dat
|
||||
{
|
||||
register unsigned int realsize = (unsigned int) (size * nmemb);
|
||||
client_t *client = data;
|
||||
int x;
|
||||
int x, wrote = 0, sanity = 1000;
|
||||
unsigned char *buffer = (unsigned char *) ptr;
|
||||
|
||||
client->bytes += realsize;
|
||||
|
||||
|
||||
|
||||
if (client->bytes > client->max_bytes) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) client->bytes);
|
||||
client->err = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = write(client->fd, ptr, realsize);
|
||||
do {
|
||||
x = write(client->fd, buffer + wrote, realsize - wrote);
|
||||
if (x > 0) {
|
||||
wrote += x;
|
||||
} else {
|
||||
switch_cond_next();
|
||||
}
|
||||
} while (wrote != realsize && (x == -1 && (errno == EAGAIN || errno == EINTR)) && --sanity);
|
||||
|
||||
if (x != (int) realsize) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write! %d out of %d\n", x, realsize);
|
||||
if (wrote != (int) realsize) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write! fd:%d %d out of %d [%s]\n", client->fd, wrote, realsize, strerror(errno));
|
||||
}
|
||||
return x;
|
||||
|
||||
return wrote;
|
||||
}
|
||||
|
||||
|
||||
@@ -2447,7 +2457,7 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
char *dup_creds = NULL, *dynamic_url = NULL, *use_url;
|
||||
char *ua = NULL;
|
||||
const char *profile_name = NULL;
|
||||
|
||||
int tries = 10;
|
||||
|
||||
if (context->url_params) {
|
||||
profile_name = switch_event_get_header(context->url_params, "profile_name");
|
||||
@@ -2465,9 +2475,15 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
client->fd = -1;
|
||||
|
||||
if (save_path) {
|
||||
if ((client->fd = open(save_path, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
|
||||
while(--tries && (client->fd == 0 || client->fd == -1)) {
|
||||
client->fd = open(save_path, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
if (client->fd < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "ERROR OPENING FILE %s [%s]\n", save_path, strerror(errno));
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -2600,6 +2616,7 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
|
||||
if (client->fd > -1) {
|
||||
close(client->fd);
|
||||
client->fd = -1;
|
||||
}
|
||||
|
||||
if (headers && client->headers) {
|
||||
@@ -2699,34 +2716,28 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t lock_file(http_file_context_t *context, switch_bool_t lock)
|
||||
static void lock_file(http_file_context_t *context, switch_bool_t lock)
|
||||
{
|
||||
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
void *x = NULL;
|
||||
|
||||
if (lock) {
|
||||
if (switch_file_open(&context->lock_fd,
|
||||
context->lock_file,
|
||||
SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
|
||||
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, context->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
do {
|
||||
switch_mutex_lock(globals.request_mutex);
|
||||
if ((x = switch_core_hash_find(globals.request_hash, context->dest_url))) {
|
||||
switch_mutex_unlock(globals.request_mutex);
|
||||
switch_yield(100000);
|
||||
}
|
||||
} while(x);
|
||||
|
||||
|
||||
if (switch_file_lock(context->lock_fd, SWITCH_FLOCK_EXCLUSIVE) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_core_hash_insert(globals.request_hash, context->dest_url, (void *)1);
|
||||
switch_mutex_unlock(globals.request_mutex);
|
||||
} else {
|
||||
if (context->lock_fd){
|
||||
switch_file_close(context->lock_fd);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
unlink(context->lock_file);
|
||||
switch_mutex_lock(globals.request_mutex);
|
||||
switch_core_hash_delete(globals.request_hash, context->dest_url);
|
||||
switch_mutex_unlock(globals.request_mutex);
|
||||
}
|
||||
|
||||
return status;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2745,8 +2756,6 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
lock_file(context, SWITCH_TRUE);
|
||||
|
||||
if (context->url_params) {
|
||||
ext = switch_event_get_header(context->url_params, "ext");
|
||||
}
|
||||
@@ -2837,8 +2846,6 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
unlink(context->cache_file);
|
||||
}
|
||||
|
||||
lock_file(context, SWITCH_FALSE);
|
||||
|
||||
switch_event_destroy(&headers);
|
||||
|
||||
return status;
|
||||
@@ -2953,10 +2960,14 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
context->read.ext = switch_event_get_header(context->url_params, "ext");
|
||||
}
|
||||
|
||||
if ((status = locate_url_file(context, context->dest_url)) != SWITCH_STATUS_SUCCESS) {
|
||||
lock_file(context, SWITCH_TRUE);
|
||||
status = locate_url_file(context, context->dest_url);
|
||||
lock_file(context, SWITCH_FALSE);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
if ((status = switch_core_file_open(&context->fh,
|
||||
context->cache_file,
|
||||
handle->channels,
|
||||
@@ -2965,7 +2976,6 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid cache file %s opening url %s Discarding file.\n", context->cache_file, path);
|
||||
unlink(context->cache_file);
|
||||
unlink(context->meta_file);
|
||||
unlink(context->lock_file);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -3041,7 +3051,6 @@ static switch_status_t http_file_file_close(switch_file_handle_t *handle)
|
||||
if (context->cache_file) {
|
||||
unlink(context->cache_file);
|
||||
unlink(context->meta_file);
|
||||
unlink(context->lock_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3105,6 +3114,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
|
||||
globals.cache_ttl = 300;
|
||||
globals.not_found_expires = 300;
|
||||
|
||||
switch_mutex_init(&globals.request_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
|
||||
http_file_supported_formats[0] = "http";
|
||||
|
||||
@@ -3133,6 +3143,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
|
||||
|
||||
|
||||
switch_core_hash_init(&globals.profile_hash);
|
||||
switch_core_hash_init(&globals.request_hash);
|
||||
switch_core_hash_init_case(&globals.parse_hash, SWITCH_FALSE);
|
||||
|
||||
bind_parser("execute", parse_execute);
|
||||
|
||||
@@ -782,7 +782,7 @@ static vm_profile_t *load_profile(const char *profile_name)
|
||||
|
||||
for (x = 0; vm_index_list[x]; x++) {
|
||||
errmsg = NULL;
|
||||
switch_cache_db_execute_sql(dbh, vm_index_list[x], &errmsg);
|
||||
switch_cache_db_create_schema(dbh, vm_index_list[x], &errmsg);
|
||||
switch_safe_free(errmsg);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
include $(top_srcdir)/build/modmake.rulesam
|
||||
MODNAME=mod_flite
|
||||
|
||||
FLITE=flite-1.5.4
|
||||
FLITE=flite-2.0.0
|
||||
|
||||
FLITE_DIR=$(switch_srcdir)/libs/$(FLITE)-current
|
||||
FLITE_BUILDDIR=$(switch_builddir)/libs/$(FLITE)-current
|
||||
FLITE_DIR=$(switch_srcdir)/libs/$(FLITE)-release
|
||||
FLITE_BUILDDIR=$(switch_builddir)/libs/$(FLITE)-release
|
||||
|
||||
FLITE_LIBDIR=$(FLITE_BUILDDIR)/build/libs
|
||||
FLITE_A=$(FLITE_LIBDIR)/libflite_cmu_us_awb.a \
|
||||
@@ -23,7 +23,7 @@ mod_flite_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
||||
BUILT_SOURCES= $(FLITE_A)
|
||||
|
||||
$(FLITE_DIR):
|
||||
$(GETLIB) $(FLITE)-current.tar.bz2
|
||||
$(GETLIB) $(FLITE)-release.tar.bz2
|
||||
|
||||
$(FLITE_BUILDDIR)/.stamp-configure: $(FLITE_DIR)
|
||||
mkdir -p $(FLITE_BUILDDIR)
|
||||
|
||||
@@ -672,11 +672,6 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch
|
||||
rtmp_set_channel_variables(*newsession);
|
||||
|
||||
switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock);
|
||||
|
||||
if (switch_core_session_thread_launch(tech_pvt->session) == SWITCH_STATUS_FALSE) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't spawn thread\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (rsession) {
|
||||
rtmp_session_rwunlock(rsession);
|
||||
|
||||
@@ -2066,6 +2066,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
|
||||
char *cid = generate_pai_str(tech_pvt);
|
||||
|
||||
/* Set sip_to_tag to local tag for inbound channels. */
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||
const char* to_tag = "";
|
||||
to_tag = switch_str_nil(nta_leg_get_tag(tech_pvt->nh->nh_ds->ds_leg));
|
||||
if(to_tag) {
|
||||
switch_channel_set_variable(channel, "sip_to_tag", to_tag);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ring_ready_val) {
|
||||
|
||||
case SWITCH_RING_READY_QUEUED:
|
||||
@@ -4238,6 +4247,54 @@ static switch_status_t sofia_manage(char *relative_oid, switch_management_action
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void protect_dest_uri(switch_caller_profile_t *cp)
|
||||
{
|
||||
char *p = cp->destination_number, *o = p;
|
||||
char *q = NULL, *e = NULL, *qenc = NULL;
|
||||
switch_size_t enclen = 0;
|
||||
|
||||
while((p = strchr(p, '/'))) {
|
||||
q = p++;
|
||||
}
|
||||
|
||||
if (q) {
|
||||
const char *i;
|
||||
int go = 0;
|
||||
|
||||
for (i = q+1; i && *i && *i != '@'; i++) {
|
||||
if (strchr(SWITCH_URL_UNSAFE, *i)) {
|
||||
go = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!go) return;
|
||||
|
||||
*q++ = '\0';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncasecmp(q, "sips:", 5)) {
|
||||
q += 5;
|
||||
} else if (!strncasecmp(q, "sip:", 4)) {
|
||||
q += 4;
|
||||
}
|
||||
|
||||
if (!(e = strchr(q, '@'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
*e++ = '\0';
|
||||
|
||||
if (switch_needs_url_encode(q)) {
|
||||
enclen = (strlen(q) * 2) + 2;
|
||||
qenc = switch_core_alloc(cp->pool, enclen);
|
||||
switch_url_encode(q, qenc, enclen);
|
||||
}
|
||||
|
||||
cp->destination_number = switch_core_sprintf(cp->pool, "%s/%s@%s", o, qenc ? qenc : q, e);
|
||||
}
|
||||
|
||||
static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session,
|
||||
switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
|
||||
@@ -4263,6 +4320,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!switch_true(switch_event_get_header(var_event, "sofia_suppress_url_encoding"))) {
|
||||
protect_dest_uri(outbound_profile);
|
||||
}
|
||||
|
||||
if (!(nsession = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND,
|
||||
flags, pool, switch_event_get_header(var_event, "origination_uuid")))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
|
||||
|
||||
@@ -2271,7 +2271,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
free(test_sql);
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_cache_db_execute_sql(dbh, indexes[x], NULL);
|
||||
switch_cache_db_create_schema(dbh, indexes[x], NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
|
||||
@@ -3906,8 +3906,8 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
|
||||
if (strstr(buf, "fs_path=") && !strstr(contact_str, "fs_path=")) {
|
||||
char *e = strchr(buf,';');
|
||||
size_t l = e ? buf-e : strlen(buf);
|
||||
if (strncmp(contact_str,buf,l)) {
|
||||
size_t l = e ? e-buf : strlen(buf);
|
||||
if (!strncmp(contact_str,buf,l)) {
|
||||
contact = buf;
|
||||
}
|
||||
}
|
||||
@@ -4283,9 +4283,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
"full_via,expires,user_agent,accept,profile_name,network_ip"
|
||||
" from sip_subscriptions where hostname='%q' and profile_name='%q' and "
|
||||
"event='message-summary' and sub_to_user='%q' "
|
||||
"and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
"and (sip_host='%q' or presence_hosts like '%%%q%%') and call_id='%q'",
|
||||
to_host, mod_sofia_globals.hostname, profile->name,
|
||||
to_user, to_host, to_host))) {
|
||||
to_user, to_host, to_host, call_id))) {
|
||||
|
||||
if (mod_sofia_globals.debug_presence > 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
|
||||
@@ -305,6 +305,8 @@ static uint32_t jsock_unsub_head(jsock_t *jsock, jsock_sub_node_head_t *head)
|
||||
return x;
|
||||
}
|
||||
|
||||
static void detach_calls(jsock_t *jsock);
|
||||
|
||||
static void unsub_all_jsock(void)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
@@ -1059,8 +1061,30 @@ static jsock_t *get_jsock(const char *uuid)
|
||||
|
||||
static void attach_jsock(jsock_t *jsock)
|
||||
{
|
||||
jsock_t *jp;
|
||||
int proceed = 1;
|
||||
|
||||
switch_mutex_lock(globals.jsock_mutex);
|
||||
switch_core_hash_insert(globals.jsock_hash, jsock->uuid_str, jsock);
|
||||
|
||||
if ((jp = switch_core_hash_find(globals.jsock_hash, jsock->uuid_str))) {
|
||||
if (jp == jsock) {
|
||||
proceed = 0;
|
||||
} else {
|
||||
cJSON *params = NULL;
|
||||
cJSON *msg = NULL;
|
||||
msg = jrpc_new_req("verto.punt", NULL, ¶ms);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "New connection for session %s dropping previous connection.\n", jsock->uuid_str);
|
||||
switch_core_hash_delete(globals.jsock_hash, jsock->uuid_str);
|
||||
ws_write_json(jp, &msg, SWITCH_TRUE);
|
||||
cJSON_Delete(msg);
|
||||
jp->drop = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (proceed) {
|
||||
switch_core_hash_insert(globals.jsock_hash, jsock->uuid_str, jsock);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.jsock_mutex);
|
||||
}
|
||||
|
||||
@@ -2179,7 +2203,7 @@ static void verto_set_media_options(verto_pvt_t *tech_pvt, verto_profile_t *prof
|
||||
profile->rtpip_cur = 0;
|
||||
}
|
||||
|
||||
tech_pvt->mparams->extrtpip = profile->extrtpip;
|
||||
tech_pvt->mparams->extrtpip = tech_pvt->mparams->extsipip = profile->extrtpip;
|
||||
|
||||
//tech_pvt->mparams->dtmf_type = tech_pvt->profile->dtmf_type;
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_TRACKABLE);
|
||||
@@ -3558,11 +3582,15 @@ static switch_bool_t jsapi_func(const char *method, cJSON *params, jsock_t *jsoc
|
||||
}
|
||||
|
||||
if (jsock->allowed_fsapi && !strcmp(function, "fsapi")) {
|
||||
cJSON *cmd = cJSON_GetObjectItem(params, "cmd");
|
||||
cJSON *arg = cJSON_GetObjectItem(params, "arg");
|
||||
cJSON *data = cJSON_GetObjectItem(params, "data");
|
||||
if (data) {
|
||||
cJSON *cmd = cJSON_GetObjectItem(data, "cmd");
|
||||
cJSON *arg = cJSON_GetObjectItem(data, "arg");
|
||||
|
||||
if (cmd->type == cJSON_String && cmd->valuestring && !auth_api_command(jsock, cmd->valuestring, arg ? arg->valuestring : NULL)) {
|
||||
return SWITCH_FALSE;
|
||||
if (cmd && cmd->type == cJSON_String && cmd->valuestring &&
|
||||
!auth_api_command(jsock, cmd->valuestring, arg ? arg->valuestring : NULL)) {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3584,7 +3612,7 @@ static switch_bool_t fsapi_func(const char *method, cJSON *params, jsock_t *jsoc
|
||||
arg = cJSON_GetObjectItem(params, "arg");
|
||||
|
||||
|
||||
if (jsock->allowed_fsapi) {
|
||||
if (cmd && jsock->allowed_fsapi) {
|
||||
if (cmd->type == cJSON_String && cmd->valuestring && !auth_api_command(jsock, cmd->valuestring, arg ? arg->valuestring : NULL)) {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,10 @@ int ws_handshake(wsh_t *wsh)
|
||||
proto_buf);
|
||||
respond[511] = 0;
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
if (ws_raw_write(wsh, respond, strlen(respond)) != strlen(respond)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
wsh->handshake = 1;
|
||||
|
||||
return 0;
|
||||
@@ -400,13 +403,19 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block)
|
||||
|
||||
ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
{
|
||||
size_t r;
|
||||
ssize_t r;
|
||||
int sanity = 2000;
|
||||
int ssl_err = 0;
|
||||
ssize_t wrote = 0;
|
||||
|
||||
if (wsh->ssl) {
|
||||
do {
|
||||
r = SSL_write(wsh->ssl, data, bytes);
|
||||
r = SSL_write(wsh->ssl, (void *)((unsigned char *)data + wrote), bytes - wrote);
|
||||
|
||||
if (r > 0) {
|
||||
wrote += r;
|
||||
}
|
||||
|
||||
if (sanity < 2000) {
|
||||
ms_sleep(1);
|
||||
}
|
||||
@@ -415,7 +424,7 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
ssl_err = SSL_get_error(wsh->ssl, r);
|
||||
}
|
||||
|
||||
} while (--sanity > 0 && r == -1 && ssl_err == SSL_ERROR_WANT_WRITE);
|
||||
} while (--sanity > 0 && ((r == -1 && ssl_err == SSL_ERROR_WANT_WRITE) || (wsh->block && wrote < bytes)));
|
||||
|
||||
if (ssl_err) {
|
||||
r = ssl_err * -1;
|
||||
@@ -425,12 +434,18 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
|
||||
}
|
||||
|
||||
do {
|
||||
r = send(wsh->sock, data, bytes, 0);
|
||||
r = send(wsh->sock, (void *)((unsigned char *)data + wrote), bytes - wrote, 0);
|
||||
|
||||
if (r > 0) {
|
||||
wrote += r;
|
||||
}
|
||||
|
||||
if (sanity < 2000) {
|
||||
ms_sleep(1);
|
||||
}
|
||||
} while (--sanity > 0 && r == -1 && xp_is_blocking(xp_errno()));
|
||||
|
||||
|
||||
} while (--sanity > 0 && ((r == -1 && xp_is_blocking(xp_errno())) || (wsh->block && wrote < bytes)));
|
||||
|
||||
//if (r<0) {
|
||||
//printf("wRITE FAIL: %s\n", strerror(errno));
|
||||
//}
|
||||
|
||||
@@ -359,19 +359,19 @@ static switch_status_t my_on_reporting_cb(switch_core_session_t *session, cdr_pr
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
|
||||
}
|
||||
|
||||
if (profile->ssl_cert_file) {
|
||||
if (!zstr(profile->ssl_cert_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, profile->ssl_cert_file);
|
||||
}
|
||||
|
||||
if (profile->ssl_key_file) {
|
||||
if (!zstr(profile->ssl_key_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, profile->ssl_key_file);
|
||||
}
|
||||
|
||||
if (profile->ssl_key_password) {
|
||||
if (!zstr(profile->ssl_key_password)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, profile->ssl_key_password);
|
||||
}
|
||||
|
||||
if (profile->ssl_version) {
|
||||
if (!zstr(profile->ssl_version)) {
|
||||
if (!strcasecmp(profile->ssl_version, "SSLv3")) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
|
||||
} else if (!strcasecmp(profile->ssl_version, "TLSv1")) {
|
||||
@@ -379,7 +379,7 @@ static switch_status_t my_on_reporting_cb(switch_core_session_t *session, cdr_pr
|
||||
}
|
||||
}
|
||||
|
||||
if (profile->ssl_cacert_file) {
|
||||
if (!zstr(profile->ssl_cacert_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, profile->ssl_cacert_file);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,19 +337,19 @@ static void process_cdr(cdr_data_t *data)
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
|
||||
}
|
||||
|
||||
if (globals.ssl_cert_file) {
|
||||
if (!zstr(globals.ssl_cert_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, globals.ssl_cert_file);
|
||||
}
|
||||
|
||||
if (globals.ssl_key_file) {
|
||||
if (!zstr(globals.ssl_key_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, globals.ssl_key_file);
|
||||
}
|
||||
|
||||
if (globals.ssl_key_password) {
|
||||
if (!zstr(globals.ssl_key_password)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, globals.ssl_key_password);
|
||||
}
|
||||
|
||||
if (globals.ssl_version) {
|
||||
if (!zstr(globals.ssl_version)) {
|
||||
if (!strcasecmp(globals.ssl_version, "SSLv3")) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
|
||||
} else if (!strcasecmp(globals.ssl_version, "TLSv1")) {
|
||||
@@ -357,7 +357,7 @@ static void process_cdr(cdr_data_t *data)
|
||||
}
|
||||
}
|
||||
|
||||
if (globals.ssl_cacert_file) {
|
||||
if (!zstr(globals.ssl_cacert_file)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
|
||||
}
|
||||
|
||||
@@ -399,8 +399,9 @@ static void process_cdr(cdr_data_t *data)
|
||||
switch_assert(globals.url_count <= MAX_URLS);
|
||||
if (globals.url_index >= globals.url_count) {
|
||||
globals.url_index = 0;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_ERROR, "Retry will be with url [%s]\n", globals.urls[globals.url_index]);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_ERROR, "Retry will be with url [%s]\n", globals.urls[globals.url_index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<param name="offer-uri" value="true"/>
|
||||
<!-- if true, channel variables are added to rayo client offer -->
|
||||
<param name="add-variables-to-offer" value="false"/>
|
||||
<!-- if true, channel variables are added to offer, ringing, answered, and end events sent to rayo clients -->
|
||||
<param name="add-variables-to-events" value="false"/>
|
||||
</settings>
|
||||
|
||||
<!-- record component params -->
|
||||
|
||||
@@ -235,6 +235,8 @@ static struct {
|
||||
int offline_logged;
|
||||
/** if true, channel variables are added to offer */
|
||||
int add_variables_to_offer;
|
||||
/** if true, channel variables are added to answered, ringing, end events */
|
||||
int add_variables_to_events;
|
||||
} globals;
|
||||
|
||||
/**
|
||||
@@ -471,6 +473,54 @@ static void add_header(iks *node, const char *name, const char *value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SIP <header>s to node
|
||||
* @param node to add <header> to
|
||||
* @param event source
|
||||
* @param add_variables true if channel variables should be added
|
||||
*/
|
||||
static void add_headers_to_event(iks *node, switch_event_t *event, int add_variables)
|
||||
{
|
||||
switch_event_header_t *header;
|
||||
/* get all variables prefixed with sip_h_ */
|
||||
for (header = event->headers; header; header = header->next) {
|
||||
if (!strncmp("variable_sip_h_", header->name, 15)) {
|
||||
if (!zstr(header->name)) {
|
||||
add_header(node, header->name + 15, header->value);
|
||||
}
|
||||
} else if (add_variables && !strncmp("variable_", header->name, 9)) {
|
||||
if (!zstr(header->name)) {
|
||||
char header_name[1024];
|
||||
snprintf(header_name, 1024, "variable-%s", header->name + 9);
|
||||
add_header(node, header_name, header->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SIP <header>s to node
|
||||
* @param node to add <header> to
|
||||
* @param add_variables true if channel variables should be added
|
||||
*/
|
||||
static void add_channel_headers_to_event(iks *node, switch_channel_t *channel, int add_variables)
|
||||
{
|
||||
switch_event_header_t *var;
|
||||
|
||||
/* add all SIP header variables and (if configured) all other variables */
|
||||
for (var = switch_channel_variable_first(channel); var; var = var->next) {
|
||||
if (!strncmp("sip_h_", var->name, 6)) {
|
||||
add_header(node, var->name + 6, var->value);
|
||||
}
|
||||
if (add_variables) {
|
||||
char var_name[1024];
|
||||
snprintf(var_name, 1024, "variable-%s", var->name);
|
||||
add_header(node, var_name, var->value);
|
||||
}
|
||||
}
|
||||
switch_channel_variable_last(channel);
|
||||
}
|
||||
|
||||
static void pause_inbound_calling(void)
|
||||
{
|
||||
int32_t arg = 1;
|
||||
@@ -1093,13 +1143,7 @@ static void rayo_call_send_end(struct rayo_call *call, switch_event_t *event, in
|
||||
|
||||
/* add signaling headers */
|
||||
if (event) {
|
||||
switch_event_header_t *header;
|
||||
/* get all variables prefixed with sip_h_ */
|
||||
for (header = event->headers; header; header = header->next) {
|
||||
if (!strncmp("variable_sip_h_", header->name, 15)) {
|
||||
add_header(end, header->name + 15, header->value);
|
||||
}
|
||||
}
|
||||
add_headers_to_event(end, event, globals.add_variables_to_events);
|
||||
}
|
||||
|
||||
/* send <end> to all offered clients */
|
||||
@@ -3403,6 +3447,7 @@ static void on_call_answer_event(struct rayo_client *rclient, switch_event_t *ev
|
||||
iks *revent = iks_new_presence("answered", RAYO_NS,
|
||||
switch_event_get_header(event, "variable_rayo_call_jid"),
|
||||
switch_event_get_header(event, "variable_rayo_dcp_jid"));
|
||||
add_headers_to_event(iks_find(revent, "answered"), event, globals.add_variables_to_events);
|
||||
RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent);
|
||||
} else if (!call->answer_event) {
|
||||
/* delay sending this event until the rayo APP has started */
|
||||
@@ -3429,6 +3474,7 @@ static void on_call_ringing_event(struct rayo_client *rclient, switch_event_t *e
|
||||
iks *revent = iks_new_presence("ringing", RAYO_NS,
|
||||
switch_event_get_header(event, "variable_rayo_call_jid"),
|
||||
switch_event_get_header(event, "variable_rayo_dcp_jid"));
|
||||
add_headers_to_event(iks_find(revent, "ringing"), event, globals.add_variables_to_events);
|
||||
call->ringing_sent = 1;
|
||||
RAYO_SEND_MESSAGE(call, RAYO_JID(rclient), revent);
|
||||
}
|
||||
@@ -3710,26 +3756,10 @@ static iks *rayo_create_offer(struct rayo_call *call, switch_core_session_t *ses
|
||||
iks_insert_attrib(offer, "to", profile->destination_number);
|
||||
}
|
||||
|
||||
/* add headers to offer */
|
||||
{
|
||||
switch_event_header_t *var;
|
||||
add_header(offer, "from", switch_channel_get_variable(channel, "sip_full_from"));
|
||||
add_header(offer, "to", switch_channel_get_variable(channel, "sip_full_to"));
|
||||
add_header(offer, "via", switch_channel_get_variable(channel, "sip_full_via"));
|
||||
|
||||
/* add all SIP header variables and (if configured) all other variables */
|
||||
for (var = switch_channel_variable_first(channel); var; var = var->next) {
|
||||
if (!strncmp("sip_h_", var->name, 6)) {
|
||||
add_header(offer, var->name + 6, var->value);
|
||||
}
|
||||
if (globals.add_variables_to_offer) {
|
||||
char var_name[1024];
|
||||
snprintf(var_name, 1024, "variable-%s", var->name);
|
||||
add_header(offer, var_name, var->value);
|
||||
}
|
||||
}
|
||||
switch_channel_variable_last(channel);
|
||||
}
|
||||
add_header(offer, "from", switch_channel_get_variable(channel, "sip_full_from"));
|
||||
add_header(offer, "to", switch_channel_get_variable(channel, "sip_full_to"));
|
||||
add_header(offer, "via", switch_channel_get_variable(channel, "sip_full_via"));
|
||||
add_channel_headers_to_event(offer, channel, globals.add_variables_to_offer);
|
||||
|
||||
return presence;
|
||||
}
|
||||
@@ -4127,6 +4157,7 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_
|
||||
globals.offer_uri = 1;
|
||||
globals.pause_when_offline = 0;
|
||||
globals.add_variables_to_offer = 0;
|
||||
globals.add_variables_to_events = 0;
|
||||
|
||||
/* get params */
|
||||
{
|
||||
@@ -4167,6 +4198,11 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_
|
||||
if (switch_true(val)) {
|
||||
globals.add_variables_to_offer = 1;
|
||||
}
|
||||
} else if (!strcasecmp(var, "add-variables-to-events")) {
|
||||
if (switch_true(val)) {
|
||||
globals.add_variables_to_offer = 1;
|
||||
globals.add_variables_to_events = 1;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ struct sndfile_context {
|
||||
|
||||
typedef struct sndfile_context sndfile_context;
|
||||
|
||||
static switch_status_t sndfile_perform_open(sndfile_context *context, const char *path, int mode, switch_file_handle_t *handle);
|
||||
|
||||
static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const char *path)
|
||||
{
|
||||
sndfile_context *context;
|
||||
@@ -181,7 +183,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
ldup = strdup(last);
|
||||
switch_assert(ldup);
|
||||
switch_snprintf(last, alt_len - (last - alt_path), "%d%s%s", handle->samplerate, SWITCH_PATH_SEPARATOR, ldup);
|
||||
if ((context->handle = sf_open(alt_path, mode, &context->sfinfo))) {
|
||||
if (sndfile_perform_open(context, alt_path, mode, handle) == SWITCH_STATUS_SUCCESS) {
|
||||
path = alt_path;
|
||||
} else {
|
||||
/* Try to find the file at the highest rate possible if we can't find one that matches the exact rate.
|
||||
@@ -189,7 +191,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
*/
|
||||
for (i = 3; i >= 0; i--) {
|
||||
switch_snprintf(last, alt_len - (last - alt_path), "%d%s%s", rates[i], SWITCH_PATH_SEPARATOR, ldup);
|
||||
if ((context->handle = sf_open(alt_path, mode, &context->sfinfo))) {
|
||||
if (sndfile_perform_open(context, alt_path, mode, handle) == SWITCH_STATUS_SUCCESS) {
|
||||
path = alt_path;
|
||||
break;
|
||||
}
|
||||
@@ -198,7 +200,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
}
|
||||
|
||||
if (!context->handle) {
|
||||
if ((context->handle = sf_open(path, mode, &context->sfinfo)) == 0) {
|
||||
if (sndfile_perform_open(context, path, mode, handle) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s] [%s]\n", path, sf_strerror(context->handle));
|
||||
status = SWITCH_STATUS_GENERR;
|
||||
goto end;
|
||||
@@ -236,6 +238,25 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t sndfile_perform_open(sndfile_context *context, const char *path, int mode, switch_file_handle_t *handle) {
|
||||
if ((mode == SFM_WRITE) || (mode == SFM_RDWR)) {
|
||||
if (switch_file_exists(path, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_file_t *newfile;
|
||||
unsigned int flags = SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE;
|
||||
if ((switch_file_open(&newfile, path, flags, SWITCH_FPROT_OS_DEFAULT, handle->memory_pool) != SWITCH_STATUS_SUCCESS)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
if ((switch_file_close(newfile) != SWITCH_STATUS_SUCCESS)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((context->handle = sf_open(path, mode, &context->sfinfo)) == 0) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t sndfile_file_truncate(switch_file_handle_t *handle, int64_t offset)
|
||||
{
|
||||
sndfile_context *context = handle->private_info;
|
||||
|
||||
@@ -3,26 +3,26 @@ include $(top_srcdir)/build/modmake.rulesam
|
||||
|
||||
MODNAME=mod_lua
|
||||
|
||||
LUA_DIR=$(switch_srcdir)/src/mod/languages/mod_lua/lua
|
||||
LIBLUA_A=$(LUA_DIR)/liblua.a
|
||||
|
||||
AM_CFLAGS += $(CFLAGS) -D_GNU_SOURCE
|
||||
mod_LTLIBRARIES = mod_lua.la
|
||||
mod_lua_la_SOURCES = mod_lua.cpp freeswitch_lua.cpp mod_lua_wrap.cpp lua/lapi.c lua/lcode.c lua/lctype.c lua/ldebug.c lua/ldo.c lua/ldump.c lua/lfunc.c lua/lgc.c lua/llex.c lua/lmem.c lua/lobject.c lua/lopcodes.c lua/lparser.c lua/lstate.c lua/lstring.c lua/ltable.c lua/ltm.c lua/lundump.c lua/lvm.c lua/lzio.c lua/lauxlib.c lua/lbaselib.c lua/lbitlib.c lua/lcorolib.c lua/ldblib.c lua/liolib.c lua/lmathlib.c lua/loslib.c lua/lstrlib.c lua/ltablib.c lua/loadlib.c lua/linit.c
|
||||
mod_lua_la_SOURCES = mod_lua.cpp freeswitch_lua.cpp mod_lua_wrap.cpp
|
||||
|
||||
if SYSTEM_LUA
|
||||
mod_lua_la_CXXFLAGS = $(AM_CPPFLAGS) $(LUA_CFLAGS) $(CPPFLAGS)
|
||||
mod_lua_la_CFLAGS = $(AM_CPPFLAGS) $(LUA_CFLAGS) $(CPPFLAGS)
|
||||
else
|
||||
mod_lua_la_SOURCES += lua/lapi.c lua/lcode.c lua/lctype.c lua/ldebug.c lua/ldo.c lua/ldump.c lua/lfunc.c lua/lgc.c lua/llex.c lua/lmem.c lua/lobject.c lua/lopcodes.c lua/lparser.c lua/lstate.c lua/lstring.c lua/ltable.c lua/ltm.c lua/lundump.c lua/lvm.c lua/lzio.c lua/lauxlib.c lua/lbaselib.c lua/lbitlib.c lua/lcorolib.c lua/ldblib.c lua/liolib.c lua/lmathlib.c lua/loslib.c lua/lstrlib.c lua/ltablib.c lua/loadlib.c lua/linit.c
|
||||
LUA_DIR=$(switch_srcdir)/src/mod/languages/mod_lua/lua
|
||||
mod_lua_la_CXXFLAGS = -I$(LUA_DIR) $(AM_CPPFLAGS) -DLUA_USE_LINUX
|
||||
mod_lua_la_CFLAGS = -I$(LUA_DIR) $(AM_CPPFLAGS) -DLUA_USE_LINUX
|
||||
mod_lua_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||
mod_lua_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lm $(AM_LDFLAGS) $(SOLINK) #$(LIBLUA_A)
|
||||
endif
|
||||
|
||||
#BUILT_SOURCES = $(LIBLUA_A)
|
||||
#$(mod_lua_la_SOURCES) : $(BUILT_SOURCES)
|
||||
#
|
||||
#$(LIBLUA_A):
|
||||
# cd $(LUA_DIR) && $(MAKE) CC="$(CC)" AR="$(AR) rcu" CFLAGS="$(AM_CFLAGS) -DLUA_USE_LINUX -w" liblua.a
|
||||
#luaclean:
|
||||
# cd $(LUA_DIR) && $(MAKE) clean
|
||||
#
|
||||
#allclean: clean luaclean
|
||||
mod_lua_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||
mod_lua_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lm $(AM_LDFLAGS) $(SOLINK)
|
||||
|
||||
if SYSTEM_LUA
|
||||
mod_lua_la_LDFLAGS += $(LUA_LIBS)
|
||||
endif
|
||||
|
||||
reswig: swigclean lua_wrap
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ extern "C" {
|
||||
}
|
||||
#include <switch_cpp.h>
|
||||
|
||||
#ifndef lua_pushglobaltable
|
||||
#define lua_pushglobaltable(L) lua_pushvalue(L,LUA_GLOBALSINDEX)
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
lua_State* L;
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <sqlite3.h>
|
||||
#ifdef HAVE_SYS_PRCTL_H
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
|
||||
@@ -1029,6 +1032,12 @@ SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to change uid!\n");
|
||||
return -1;
|
||||
}
|
||||
#ifdef HAVE_SYS_PRCTL_H
|
||||
if (prctl(PR_SET_DUMPABLE, 1) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to enable core dumps!\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
@@ -319,6 +319,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_se
|
||||
if (session->read_impl.codec_id) {
|
||||
*impp = session->read_impl;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
memset(impp, 0, sizeof(*impp));
|
||||
impp->number_of_channels = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -329,6 +332,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_co
|
||||
if (session->real_read_impl.codec_id) {
|
||||
*impp = session->real_read_impl;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
memset(impp, 0, sizeof(*impp));
|
||||
impp->number_of_channels = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -339,6 +345,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_s
|
||||
if (session->write_impl.codec_id) {
|
||||
*impp = session->write_impl;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
memset(impp, 0, sizeof(*impp));
|
||||
impp->number_of_channels = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -349,6 +358,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_c
|
||||
if (session->video_read_impl.codec_id) {
|
||||
*impp = session->video_read_impl;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
memset(impp, 0, sizeof(*impp));
|
||||
impp->number_of_channels = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -359,6 +371,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_
|
||||
if (session->video_write_impl.codec_id) {
|
||||
*impp = session->video_write_impl;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
memset(impp, 0, sizeof(*impp));
|
||||
impp->number_of_channels = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
+16
-8
@@ -2926,6 +2926,11 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
|
||||
|
||||
engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
|
||||
engine->cur_payload_map->remote_sdp_port = (switch_port_t) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port;
|
||||
|
||||
if (!smh->mparams->remote_ip) {
|
||||
smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
|
||||
}
|
||||
|
||||
if (engine->remote_rtcp_port) {
|
||||
engine->remote_rtcp_port = engine->cur_payload_map->remote_sdp_port;
|
||||
}
|
||||
@@ -3916,7 +3921,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||
const char *rm_encoding;
|
||||
const switch_codec_implementation_t *mimp = NULL;
|
||||
int vmatch = 0, i;
|
||||
|
||||
|
||||
nm_idx = 0;
|
||||
m_idx = 0;
|
||||
memset(matches, 0, sizeof(matches[0]) * MAX_MATCHES);
|
||||
@@ -3991,7 +3996,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||
if (!(rm_encoding = map->rm_encoding)) {
|
||||
rm_encoding = "";
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < total_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = codec_array[i];
|
||||
|
||||
@@ -4078,7 +4083,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||
pmap->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
|
||||
|
||||
pmap->agreed_pt = (switch_payload_t) map->rm_pt;
|
||||
|
||||
|
||||
smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp;
|
||||
|
||||
#if 0
|
||||
if (j == 0 && (!switch_true(mirror) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND)) {
|
||||
@@ -5875,10 +5881,7 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
|
||||
//port, secure ? "S" : "", switch_channel_test_flag(session->channel, CF_WEBRTC) ? "F" : "");
|
||||
|
||||
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d %s", port,
|
||||
get_media_profile_name(session,
|
||||
(secure && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
|
||||
a_engine->crypto_type != CRYPTO_INVALID));
|
||||
|
||||
get_media_profile_name(session, secure || a_engine->crypto_type != CRYPTO_INVALID));
|
||||
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
@@ -6301,6 +6304,12 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
|
||||
switch_channel_clear_flag(smh->session->channel, CF_DTLS);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(session->channel, CF_PROXY_OFF) && (tmp = switch_channel_get_variable(smh->session->channel, "uuid_media_secure_media"))) {
|
||||
switch_channel_set_variable(smh->session->channel, "rtp_secure_media", tmp);
|
||||
switch_core_session_parse_crypto_prefs(session);
|
||||
switch_core_session_check_outgoing_crypto(session);
|
||||
}
|
||||
|
||||
if (is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING) ||
|
||||
switch_channel_test_flag(session->channel, CF_3PCC)) {
|
||||
if (!switch_channel_test_flag(session->channel, CF_WEBRTC) &&
|
||||
@@ -6718,7 +6727,6 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
|
||||
|
||||
mult = switch_channel_get_variable(session->channel, "sdp_m_per_ptime");
|
||||
|
||||
|
||||
if (switch_channel_test_flag(session->channel, CF_WEBRTC) || (mult && switch_false(mult))) {
|
||||
char *bp = buf;
|
||||
int both = (switch_channel_test_flag(session->channel, CF_WEBRTC) || switch_channel_test_flag(session->channel, CF_DTLS)) ? 0 : 1;
|
||||
|
||||
+11
-20
@@ -372,7 +372,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
|
||||
}
|
||||
|
||||
frame->datalen = (uint32_t)bytes;
|
||||
frame->samples = (uint32_t)(bytes / sizeof(int16_t));
|
||||
frame->samples = (uint32_t)(bytes / sizeof(int16_t) / read_impl.number_of_channels);
|
||||
frame->rate = read_impl.actual_samples_per_second;
|
||||
frame->codec = NULL;
|
||||
|
||||
@@ -380,22 +380,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
|
||||
frame->datalen *= 2;
|
||||
frame->channels = 2;
|
||||
} else {
|
||||
frame->channels = 1;
|
||||
}
|
||||
|
||||
memcpy(bug->session->recur_buffer, frame->data, frame->datalen);
|
||||
bug->session->recur_buffer_len = frame->datalen;
|
||||
|
||||
if (has_read) {
|
||||
switch_mutex_lock(bug->read_mutex);
|
||||
do_read = switch_buffer_inuse(bug->raw_read_buffer);
|
||||
switch_mutex_unlock(bug->read_mutex);
|
||||
}
|
||||
|
||||
if (has_write) {
|
||||
switch_mutex_lock(bug->write_mutex);
|
||||
do_write = switch_buffer_inuse(bug->raw_write_buffer);
|
||||
switch_mutex_unlock(bug->write_mutex);
|
||||
frame->channels = read_impl.number_of_channels;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -589,11 +574,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch
|
||||
|
||||
if (orig_session->bugs) {
|
||||
switch_channel_t *new_channel = switch_core_session_get_channel(new_session);
|
||||
const char *save = switch_channel_get_variable(new_channel, "record_append");
|
||||
|
||||
switch_channel_t *orig_channel = switch_core_session_get_channel(orig_session);
|
||||
const char *save_append = switch_channel_get_variable(new_channel, "record_append");
|
||||
const char *save_stereo = switch_channel_get_variable(new_channel, "record_stereo");
|
||||
const char *orig_stereo = switch_channel_get_variable(orig_channel, "record_stereo");
|
||||
const char *new_stereo = orig_stereo;
|
||||
|
||||
switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
|
||||
|
||||
switch_channel_set_variable(new_channel, "record_append", "true");
|
||||
switch_channel_set_variable(new_channel, "record_stereo", new_stereo);
|
||||
|
||||
for (bp = orig_session->bugs; bp; bp = bp->next) {
|
||||
if (!strcmp(bp->function, "session_record")) {
|
||||
@@ -614,7 +604,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch
|
||||
switch_ivr_record_session(new_session, list[i], stop_times[i], NULL);
|
||||
}
|
||||
|
||||
switch_channel_set_variable(new_channel, "record_append", save);
|
||||
switch_channel_set_variable(new_channel, "record_append", save_append);
|
||||
switch_channel_set_variable(new_channel, "record_stereo", save_stereo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -808,6 +808,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit
|
||||
switch_channel_clear_flag(session->channel, CF_EARLY_MEDIA);
|
||||
}
|
||||
|
||||
if (message->message_id == SWITCH_MESSAGE_INDICATE_MEDIA) {
|
||||
switch_channel_set_flag(session->channel, CF_PROXY_OFF);
|
||||
}
|
||||
|
||||
if (message->message_id == SWITCH_MESSAGE_INDICATE_DISPLAY) {
|
||||
char *arg = NULL;
|
||||
|
||||
@@ -914,6 +918,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit
|
||||
|
||||
end:
|
||||
|
||||
if (message->message_id == SWITCH_MESSAGE_INDICATE_MEDIA) {
|
||||
switch_channel_clear_flag(session->channel, CF_PROXY_OFF);
|
||||
}
|
||||
|
||||
switch_core_session_free_message(&message);
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
|
||||
+42
-28
@@ -26,6 +26,7 @@
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Michael Jerris <mike@jerris.com>
|
||||
* Paul D. Tinsley <pdt at jackhammer.org>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
*
|
||||
*
|
||||
* switch_core_sqldb.c -- Main Core Library (statistics tracker)
|
||||
@@ -1267,6 +1268,19 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback_err(switch_
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err)
|
||||
{
|
||||
switch_status_t r = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
|
||||
if (switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) {
|
||||
r = switch_cache_db_execute_sql(dbh, sql, err);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Performs test_sql and if it fails performs drop_sql and reactive_sql.
|
||||
*
|
||||
@@ -3399,10 +3413,10 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
||||
|
||||
|
||||
switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from recovery", "DROP TABLE recovery", recovery_sql);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery1 on recovery(technology)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery2 on recovery(profile_name)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery3 on recovery(uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index recovery3 on recovery(runtime_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery1 on recovery(technology)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery2 on recovery(profile_name)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery3 on recovery(uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index recovery3 on recovery(runtime_uuid)", NULL);
|
||||
|
||||
|
||||
|
||||
@@ -3536,30 +3550,30 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, sql, NULL);
|
||||
}
|
||||
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index tasks1 on tasks (hostname,task_id)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete1 on complete (a1,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete2 on complete (a2,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete3 on complete (a3,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete4 on complete (a4,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete5 on complete (a5,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete6 on complete (a6,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete7 on complete (a7,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete8 on complete (a8,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete9 on complete (a9,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete10 on complete (a10,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index complete11 on complete (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index nat_map_port_proto on nat (port,proto,hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index channels1 on channels(hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index calls1 on calls(hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index chidx1 on channels (hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index uuindex on channels (uuid, hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index uuindex2 on channels (call_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index callsidx1 on calls (hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eruuindex on calls (caller_uuid, hostname)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eeuuindex on calls (callee_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index eeuuindex2 on calls (call_uuid)", NULL);
|
||||
switch_cache_db_execute_sql(sql_manager.dbh, "create index regindex1 on registrations (reg_user,realm,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index tasks1 on tasks (hostname,task_id)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete1 on complete (a1,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete2 on complete (a2,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete3 on complete (a3,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete4 on complete (a4,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete5 on complete (a5,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete6 on complete (a6,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete7 on complete (a7,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete8 on complete (a8,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete9 on complete (a9,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete10 on complete (a10,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index complete11 on complete (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index nat_map_port_proto on nat (port,proto,hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index channels1 on channels(hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index calls1 on calls(hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index chidx1 on channels (hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index uuindex on channels (uuid, hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index uuindex2 on channels (call_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index callsidx1 on calls (hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eruuindex on calls (caller_uuid, hostname)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eeuuindex on calls (callee_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index eeuuindex2 on calls (call_uuid)", NULL);
|
||||
switch_cache_db_create_schema(sql_manager.dbh, "create index regindex1 on registrations (reg_user,realm,hostname)", NULL);
|
||||
|
||||
|
||||
skip:
|
||||
|
||||
+3
-3
@@ -240,15 +240,15 @@ static int switch_events_match(switch_event_t *event, switch_event_node_t *node)
|
||||
if (!strncasecmp(node->subclass_name, "file:", 5)) {
|
||||
char *file_header;
|
||||
if ((file_header = switch_event_get_header(event, "file")) != 0) {
|
||||
match = strstr(node->subclass_name + 5, file_header) ? 1 : 0;
|
||||
match = !strcmp(node->subclass_name + 5, file_header) ? 1 : 0;
|
||||
}
|
||||
} else if (!strncasecmp(node->subclass_name, "func:", 5)) {
|
||||
char *func_header;
|
||||
if ((func_header = switch_event_get_header(event, "function")) != 0) {
|
||||
match = strstr(node->subclass_name + 5, func_header) ? 1 : 0;
|
||||
match = !strcmp(node->subclass_name + 5, func_header) ? 1 : 0;
|
||||
}
|
||||
} else if (event->subclass_name && node->subclass_name) {
|
||||
match = strstr(event->subclass_name, node->subclass_name) ? 1 : 0;
|
||||
match = !strcmp(event->subclass_name, node->subclass_name) ? 1 : 0;
|
||||
}
|
||||
} else if ((event->subclass_name && !node->subclass_name) || (!event->subclass_name && !node->subclass_name)) {
|
||||
match = 1;
|
||||
|
||||
@@ -1653,6 +1653,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_SECURE)) {
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
|
||||
"Cannot bypass %s due to secure connection.\n", switch_channel_get_name(channel));
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
|
||||
switch_core_session_rwunlock(session);
|
||||
return SWITCH_STATUS_INUSE;
|
||||
|
||||
+19
-12
@@ -1121,8 +1121,8 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void *
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
struct record_helper *rh;
|
||||
switch_size_t bsize = SWITCH_RECOMMENDED_BUFFER_SIZE, samples = 0, inuse = 0;
|
||||
unsigned char *data = switch_core_session_alloc(session, bsize);
|
||||
int channels = switch_core_media_bug_test_flag(bug, SMBF_STEREO) ? 2 : 1;
|
||||
unsigned char *data;
|
||||
int channels = 1;
|
||||
|
||||
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
@@ -1132,6 +1132,9 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void *
|
||||
switch_buffer_create_dynamic(&rh->thread_buffer, 1024 * 512, 1024 * 64, 0);
|
||||
rh->thread_ready = 1;
|
||||
|
||||
channels = switch_core_media_bug_test_flag(bug, SMBF_STEREO) ? 2 : rh->read_impl.number_of_channels;
|
||||
data = switch_core_session_alloc(session, bsize);
|
||||
|
||||
while(switch_test_flag(rh->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_mutex_lock(rh->buffer_mutex);
|
||||
inuse = switch_buffer_inuse(rh->thread_buffer);
|
||||
@@ -1141,9 +1144,10 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void *
|
||||
switch_yield(20000);
|
||||
continue;
|
||||
} else if ((!rh->thread_ready || switch_channel_down_nosig(channel)) && !inuse) {
|
||||
switch_mutex_unlock(rh->buffer_mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
samples = switch_buffer_read(rh->thread_buffer, data, bsize) / 2 / channels;
|
||||
switch_mutex_unlock(rh->buffer_mutex);
|
||||
|
||||
@@ -2124,16 +2128,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
|
||||
flags |= SMBF_READ_STREAM;
|
||||
}
|
||||
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_STEREO")) && switch_true(p)) {
|
||||
flags |= SMBF_STEREO;
|
||||
flags &= ~SMBF_STEREO_SWAP;
|
||||
channels = 2;
|
||||
}
|
||||
if (channels == 1) { /* if leg is already stereo this feature is not available */
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_STEREO")) && switch_true(p)) {
|
||||
flags |= SMBF_STEREO;
|
||||
flags &= ~SMBF_STEREO_SWAP;
|
||||
channels = 2;
|
||||
}
|
||||
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_STEREO_SWAP")) && switch_true(p)) {
|
||||
flags |= SMBF_STEREO;
|
||||
flags |= SMBF_STEREO_SWAP;
|
||||
channels = 2;
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_STEREO_SWAP")) && switch_true(p)) {
|
||||
flags |= SMBF_STEREO;
|
||||
flags |= SMBF_STEREO_SWAP;
|
||||
channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
|
||||
@@ -2229,6 +2235,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
|
||||
|
||||
if ((ext = strrchr(file, '.'))) {
|
||||
ext++;
|
||||
|
||||
if (switch_core_file_open(fh, file, channels, read_impl.actual_samples_per_second, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file);
|
||||
if (hangup_on_error) {
|
||||
|
||||
@@ -1655,13 +1655,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
||||
|
||||
for (i = 0; i < x_argc; i++) {
|
||||
|
||||
if (channel) {
|
||||
switch_channel_handle_cause(channel, handles[i].cause);
|
||||
}
|
||||
|
||||
if (hp == &handles[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (channel && handles[i].cause && handles[i].cause != SWITCH_CAUSE_SUCCESS) {
|
||||
switch_channel_handle_cause(channel, handles[i].cause);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(handles[i].mutex);
|
||||
|
||||
if (getcause && *cause != handles[i].cause && handles[i].cause != SWITCH_CAUSE_LOSE_RACE && handles[i].cause != SWITCH_CAUSE_NO_PICKUP) {
|
||||
@@ -1753,11 +1754,7 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
|
||||
switch_core_session_t *session = originate_status[i].peer_session;
|
||||
switch_channel_t *channel = originate_status[i].peer_channel;
|
||||
|
||||
if (!session) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!channel || !switch_channel_up(channel)) {
|
||||
if (!session || !channel || !switch_channel_up(channel)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1836,7 +1833,7 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
|
||||
switch_core_session_t *session = originate_status[i].peer_session;
|
||||
switch_channel_t *channel = originate_status[i].peer_channel;
|
||||
|
||||
if (!session) break;
|
||||
if (!session) continue;
|
||||
|
||||
if (switch_core_codec_ready((&read_codecs[i]))) {
|
||||
switch_core_codec_destroy(&read_codecs[i]);
|
||||
|
||||
+30
-11
@@ -235,6 +235,7 @@ typedef struct {
|
||||
uint8_t rready;
|
||||
int missed_count;
|
||||
char last_sent_id[13];
|
||||
switch_time_t last_ok;
|
||||
} switch_rtp_ice_t;
|
||||
|
||||
struct switch_rtp;
|
||||
@@ -378,6 +379,7 @@ struct switch_rtp {
|
||||
switch_mutex_t *flag_mutex;
|
||||
switch_mutex_t *read_mutex;
|
||||
switch_mutex_t *write_mutex;
|
||||
switch_mutex_t *ice_mutex;
|
||||
switch_timer_t timer;
|
||||
uint8_t ready;
|
||||
uint8_t cn;
|
||||
@@ -841,6 +843,8 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||
return;
|
||||
}
|
||||
|
||||
switch_mutex_lock(rtp_session->ice_mutex);
|
||||
|
||||
READ_INC(rtp_session);
|
||||
WRITE_INC(rtp_session);
|
||||
|
||||
@@ -1013,8 +1017,11 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||
|
||||
//ice->ice_params->cands[ice->ice_params->chosen][ice->proto].priority;
|
||||
for (j = 0; j < 2; j++) {
|
||||
if (!icep[j] || !icep[j]->ice_params) {
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < icep[j]->ice_params->cand_idx; i++) {
|
||||
if (icep[j]->ice_params->cands[i][icep[j]->proto].priority == *pri) {
|
||||
if (icep[j]->ice_params && icep[j]->ice_params->cands[i][icep[j]->proto].priority == *pri) {
|
||||
if (j == IPR_RTP) {
|
||||
icep[j]->ice_params->chosen[j] = i;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "Change candidate index to %d\n", i);
|
||||
@@ -1099,6 +1106,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||
switch_sockaddr_t *from_addr = rtp_session->from_addr;
|
||||
switch_socket_t *sock_output = rtp_session->sock_output;
|
||||
uint8_t hosts_set = 0;
|
||||
switch_time_t now = switch_micro_time_now();
|
||||
|
||||
if (is_rtcp) {
|
||||
from_addr = rtp_session->rtcp_from_addr;
|
||||
@@ -1120,12 +1128,16 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||
remote_ip = switch_get_addr(ipbuf, sizeof(ipbuf), from_addr);
|
||||
switch_stun_packet_attribute_add_xor_binded_address(rpacket, (char *) remote_ip, switch_sockaddr_get_port(from_addr));
|
||||
|
||||
if (!switch_cmp_addr(from_addr, ice->addr)) {
|
||||
hosts_set++;
|
||||
host = switch_get_addr(buf, sizeof(buf), from_addr);
|
||||
port = switch_sockaddr_get_port(from_addr);
|
||||
host2 = switch_get_addr(buf2, sizeof(buf2), ice->addr);
|
||||
port2 = switch_sockaddr_get_port(ice->addr);
|
||||
if (switch_cmp_addr(from_addr, ice->addr)) {
|
||||
ice->last_ok = now;
|
||||
} else {
|
||||
if (!ice->last_ok || (now - ice->last_ok) > 3000000) {
|
||||
hosts_set++;
|
||||
host = switch_get_addr(buf, sizeof(buf), from_addr);
|
||||
port = switch_sockaddr_get_port(from_addr);
|
||||
host2 = switch_get_addr(buf2, sizeof(buf2), ice->addr);
|
||||
port2 = switch_sockaddr_get_port(ice->addr);
|
||||
}
|
||||
}
|
||||
|
||||
if ((ice->type & ICE_VANILLA)) {
|
||||
@@ -1204,7 +1216,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
|
||||
|
||||
|
||||
end:
|
||||
|
||||
switch_mutex_unlock(rtp_session->ice_mutex);
|
||||
READ_DEC(rtp_session);
|
||||
WRITE_DEC(rtp_session);
|
||||
}
|
||||
@@ -3490,6 +3502,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
|
||||
switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
switch_mutex_init(&rtp_session->read_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
switch_mutex_init(&rtp_session->write_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
switch_mutex_init(&rtp_session->ice_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
switch_queue_create(&rtp_session->dtmf_data.dtmf_queue, 100, rtp_session->pool);
|
||||
switch_queue_create(&rtp_session->dtmf_data.dtmf_inqueue, 100, rtp_session->pool);
|
||||
@@ -3938,6 +3951,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
|
||||
switch_port_t port = 0;
|
||||
char bufc[30];
|
||||
|
||||
switch_mutex_lock(rtp_session->ice_mutex);
|
||||
|
||||
if (proto == IPR_RTP) {
|
||||
ice = &rtp_session->ice;
|
||||
@@ -4006,6 +4020,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
|
||||
switch_rtp_break(rtp_session);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(rtp_session->ice_mutex);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -6618,11 +6634,13 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
||||
srtp_dealloc(rtp_session->send_ctx[rtp_session->srtp_idx_rtp]);
|
||||
rtp_session->send_ctx[rtp_session->srtp_idx_rtp] = NULL;
|
||||
if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &rtp_session->send_policy[rtp_session->srtp_idx_rtp]))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP SEND\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
|
||||
"Error! RE-Activating %s Secure RTP SEND\n", rtp_type(rtp_session));
|
||||
ret = -1;
|
||||
goto end;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "RE-Activating Secure RTP SEND\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
|
||||
"RE-Activating %s Secure RTP SEND\n", rtp_type(rtp_session));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6630,7 +6648,8 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
||||
stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &send_msg->header, &sbytes);
|
||||
|
||||
if (stat) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error: SRTP protection failed with code %d\n", stat);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
|
||||
"Error: %s SRTP protection failed with code %d\n", rtp_type(rtp_session), stat);
|
||||
}
|
||||
|
||||
bytes = sbytes;
|
||||
|
||||
+11
-3
@@ -2923,9 +2923,8 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
|
||||
|
||||
SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
|
||||
{
|
||||
const char *p;
|
||||
const char *p, *e = end_of_p(url);
|
||||
size_t x = 0;
|
||||
const char urlunsafe[] = "\r\n \"#%&+:;<=>?@[\\]^`{|}";
|
||||
const char hex[] = "0123456789ABCDEF";
|
||||
|
||||
if (!buf) {
|
||||
@@ -2939,10 +2938,19 @@ SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
|
||||
len--;
|
||||
|
||||
for (p = url; *p; p++) {
|
||||
int ok = 0;
|
||||
|
||||
if (x >= len) {
|
||||
break;
|
||||
}
|
||||
if (*p < ' ' || *p > '~' || strchr(urlunsafe, *p)) {
|
||||
|
||||
if (*p == '%' && e-p > 1) {
|
||||
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok && (*p < ' ' || *p > '~' || strchr(SWITCH_URL_UNSAFE, *p))) {
|
||||
if ((x + 3) > len) {
|
||||
break;
|
||||
}
|
||||
|
||||
+17
-3
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# /etc/profile: system-wide defaults for bash(1) login shells
|
||||
# FreeSWITCH Dev .bashrc
|
||||
#
|
||||
export UNAME=`uname -s`
|
||||
|
||||
@@ -40,7 +40,8 @@ if [ ! -f ~/.inputrc ]; then
|
||||
fi
|
||||
|
||||
set -o emacs
|
||||
|
||||
export PROMPT_COMMAND="history -a; history -c; history -r; ${PROMPT_COMMAND}"
|
||||
export HISTSIZE=5000
|
||||
export TERM=xterm-256color
|
||||
export LESSCHARSET="latin1"
|
||||
export LESS="-R"
|
||||
@@ -59,7 +60,6 @@ alias mecas='emacs'
|
||||
alias bgit='git commit --author "Brian West <brian@freeswitch.org>"'
|
||||
alias mgit='git commit --author "Mike Jerris <mike@freeswitch.org>"'
|
||||
alias tgit='git commit --author "Anthony Minessale <anthm@freeswitch.org>"'
|
||||
alias igit='git commit --author "Raymond Chandler <intralanman@freeswitch.org>"'
|
||||
alias dp='emacs /usr/local/freeswitch/conf/dialplan/default.xml'
|
||||
alias go='/usr/local/freeswitch/bin/freeswitch -nonat'
|
||||
alias fstop='top -p `cat /usr/local/freeswitch/run/freeswitch.pid`'
|
||||
@@ -68,4 +68,18 @@ alias fscore='gdb /usr/local/freeswitch/bin/freeswitch `ls -rt core.* | tail -n1
|
||||
alias emacs='emacs -nw'
|
||||
alias jitteron='tc qdisc add dev eth0 root handle 1: netem delay 40ms 20ms ; tc qdisc add dev eth0 parent 1:1 pfifo limit 1000'
|
||||
alias jitteroff='tc qdisc del dev eth0 root netem'
|
||||
|
||||
# Auto Update the .bashrc if hostname contains freeswitch.org
|
||||
if [[ $(hostname) =~ "freeswitch.org" ]]; then
|
||||
if [ -f /usr/src/freeswitch.git/support-d/.bashrc ]; then
|
||||
/usr/bin/diff --brief <(sort /usr/src/freeswitch.git/support-d/.bashrc) <(sort ~/.bashrc) >/dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
/bin/cp -f /usr/src/freeswitch.git/support-d/.bashrc ~/
|
||||
echo ".bashrc updated."
|
||||
source ~/.bashrc
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# End Auto Update
|
||||
|
||||
# End of file
|
||||
|
||||
+3
-1
@@ -29,14 +29,16 @@ define hash_it_str
|
||||
set $i = 0
|
||||
set $idx = 0
|
||||
set $len = $arg0->tablelength
|
||||
printf "len: %d\n", $arg0->tablelength
|
||||
|
||||
while($idx < $len)
|
||||
set $x=$arg0->table->[$idx]
|
||||
set $x = $arg0->table[$idx]
|
||||
while($x != 0x0)
|
||||
printf "key: %s valueptr: %p\n", $x->k, $x->v
|
||||
set $x = $x->next
|
||||
set $i = $i + 1
|
||||
end
|
||||
set $idx = $idx + 1
|
||||
end
|
||||
end
|
||||
document hash_it_str
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
gdb /usr/local/freeswitch/bin/freeswitch $1 \
|
||||
--eval-command='set pagination off' \
|
||||
--eval-command='thread apply all bt' \
|
||||
--eval-command='quit'
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2007-2014, Anthony Minessale II
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the original author; nor the names of any contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Contributors:
|
||||
#
|
||||
# btgrep - Search for regex in backtraces
|
||||
#
|
||||
|
||||
$| = 0;
|
||||
$/ = undef;
|
||||
|
||||
my $file = shift;
|
||||
open I, $file or die;
|
||||
my $i = <I>;
|
||||
close I;
|
||||
|
||||
my @all = $i =~ /Thread \d.*?\n\n/smg;
|
||||
|
||||
foo:
|
||||
foreach my $m (@all) {
|
||||
|
||||
foreach (@ARGV) {
|
||||
my $arg;
|
||||
my $neg = 0;
|
||||
|
||||
if (/^\-(.*)$/) {
|
||||
$arg = $1;
|
||||
$neg = 1;
|
||||
} else {
|
||||
$arg = $_;
|
||||
}
|
||||
|
||||
if ($neg) {
|
||||
next foo if($m =~ /$arg/);
|
||||
} else {
|
||||
next foo unless($m =~ /$arg/);
|
||||
}
|
||||
}
|
||||
|
||||
print "Match: $m";
|
||||
}
|
||||
|
||||
# For Emacs:
|
||||
# Local Variables:
|
||||
# mode:perl
|
||||
# indent-tabs-mode:t
|
||||
# tab-width:4
|
||||
# c-basic-offset:4
|
||||
# End:
|
||||
# For VIM:
|
||||
# vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2007-2014, Anthony Minessale II
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the original author; nor the names of any contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Contributors:
|
||||
#
|
||||
# hashfinder - Find origin of a particular line of code
|
||||
#
|
||||
|
||||
|
||||
my $file = shift;
|
||||
my $regex = shift;
|
||||
my $delim = " ";
|
||||
|
||||
$file and $regex or die "missing params. Syntax: <file> <regex>";
|
||||
|
||||
sub doit($$) {
|
||||
my $rev = shift;
|
||||
my $pattern = shift;
|
||||
my $loops = shift || 0;
|
||||
my $linematch = 0;
|
||||
|
||||
if ($pattern =~ /^\~(.*)/) {
|
||||
$pattern = $1;
|
||||
} else {
|
||||
$pattern = quotemeta $pattern;
|
||||
}
|
||||
|
||||
if ($pattern =~ /^(\d+)$/) {
|
||||
$linematch = 1;
|
||||
}
|
||||
|
||||
open GIT, "git blame -n $file $rev|";
|
||||
|
||||
my $mc = 0;
|
||||
my @matches = ();
|
||||
|
||||
while (<GIT>) {
|
||||
my $matched = 0;
|
||||
|
||||
if ($linematch) {
|
||||
$matched = (/^\S+\s+$pattern\s+/);
|
||||
} else {
|
||||
$matched = (/$pattern/);
|
||||
}
|
||||
|
||||
if ($matched) {
|
||||
s/[\r\n]//g;
|
||||
push @matches, $_;
|
||||
$mc++;
|
||||
}
|
||||
}
|
||||
|
||||
close(GIT);
|
||||
|
||||
|
||||
if ($mc > 5) {
|
||||
print $delim x $loops;
|
||||
print "$mc matches; Maybe more specific?\n";
|
||||
|
||||
foreach (@matches) {
|
||||
print "$_\n";
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
my $x = 0;
|
||||
|
||||
foreach (@matches) {
|
||||
my ($hash, $lno, $author, $line);
|
||||
my $done = 0;
|
||||
|
||||
if (/$file/) {
|
||||
($hash, $lno, $author, $line) = /(\S+)\s+\S+\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
||||
$done = 1;
|
||||
} else {
|
||||
($hash, $lno, $author, $line) = /(\S+)\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
||||
}
|
||||
|
||||
if ($hash) {
|
||||
$line =~ s/^\s+//g;
|
||||
|
||||
print "\n";
|
||||
print $delim x $loops;
|
||||
my $msg = `git log -1 --pretty=format:%B $hash`;
|
||||
print "[$hash] [$lno] [$author] [$line]\n";
|
||||
print $delim x $loops;
|
||||
print ":: $msg\n";
|
||||
doit("$hash" . "^", $line, $loops+1);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
last if $done;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
doit(undef, $regex);
|
||||
|
||||
|
||||
# For Emacs:
|
||||
# Local Variables:
|
||||
# mode:perl
|
||||
# indent-tabs-mode:t
|
||||
# tab-width:4
|
||||
# c-basic-offset:4
|
||||
# End:
|
||||
# For VIM:
|
||||
# vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
my $start = 8;
|
||||
my $i = $start;
|
||||
my $step = "4";
|
||||
my $wr = 0;
|
||||
|
||||
printf "%s %0.4d START $list[4]\n", " " x $i, $i;
|
||||
|
||||
while(<>) {
|
||||
my $sub = 0;
|
||||
my $indent = 0;
|
||||
|
||||
next unless /ERR/;
|
||||
|
||||
@list = split;
|
||||
|
||||
if ($list[9] eq "ACQUIRED") {
|
||||
|
||||
if ($list[7] eq "Read") {
|
||||
$mark = "READLOCK ";
|
||||
$i += $step;
|
||||
$indent = $i;
|
||||
} else {
|
||||
$mark = "WRITELOCK";
|
||||
$wr = 1;
|
||||
$indent = 0;
|
||||
}
|
||||
|
||||
} elsif($list[9] eq "CLEARED") {
|
||||
if ($wr && $i <= $start) {
|
||||
$mark = "WRCLEARED";
|
||||
$indent = 0;
|
||||
} else {
|
||||
$sub = $step;
|
||||
$mark = "CLEARED ";
|
||||
$indent = $i;
|
||||
}
|
||||
} elsif($list[9] eq "FAIL") {
|
||||
$mark = "FAIL ";
|
||||
$indent = $i;
|
||||
}
|
||||
|
||||
printf "%s %0.4d $mark $list[4]\n", " " x $indent, $indent;
|
||||
|
||||
if ($sub) {
|
||||
$i -= $sub;
|
||||
$sub = 0;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable
+657
@@ -0,0 +1,657 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 Matt Martz
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__version__ = '0.2.4'
|
||||
|
||||
# Some global variables we use
|
||||
source = None
|
||||
shutdown_event = None
|
||||
|
||||
import math
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import re
|
||||
import signal
|
||||
import socket
|
||||
|
||||
# Used for bound_interface
|
||||
socket_socket = socket.socket
|
||||
|
||||
try:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
try:
|
||||
import xml.etree.ElementTree as ET
|
||||
except ImportError:
|
||||
from xml.dom import minidom as DOM
|
||||
ET = None
|
||||
|
||||
# Begin import game to handle Python 2 and Python 3
|
||||
try:
|
||||
from urllib2 import urlopen, Request, HTTPError, URLError
|
||||
except ImportError:
|
||||
from urllib.request import urlopen, Request, HTTPError, URLError
|
||||
|
||||
try:
|
||||
from Queue import Queue
|
||||
except ImportError:
|
||||
from queue import Queue
|
||||
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
from urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
from urlparse import parse_qs
|
||||
except ImportError:
|
||||
try:
|
||||
from urllib.parse import parse_qs
|
||||
except ImportError:
|
||||
from cgi import parse_qs
|
||||
|
||||
try:
|
||||
from hashlib import md5
|
||||
except ImportError:
|
||||
from md5 import md5
|
||||
|
||||
try:
|
||||
from argparse import ArgumentParser as ArgParser
|
||||
except ImportError:
|
||||
from optparse import OptionParser as ArgParser
|
||||
|
||||
try:
|
||||
import builtins
|
||||
except ImportError:
|
||||
def print_(*args, **kwargs):
|
||||
"""The new-style print function taken from
|
||||
https://pypi.python.org/pypi/six/
|
||||
|
||||
"""
|
||||
fp = kwargs.pop("file", sys.stdout)
|
||||
if fp is None:
|
||||
return
|
||||
|
||||
def write(data):
|
||||
if not isinstance(data, basestring):
|
||||
data = str(data)
|
||||
fp.write(data)
|
||||
|
||||
want_unicode = False
|
||||
sep = kwargs.pop("sep", None)
|
||||
if sep is not None:
|
||||
if isinstance(sep, unicode):
|
||||
want_unicode = True
|
||||
elif not isinstance(sep, str):
|
||||
raise TypeError("sep must be None or a string")
|
||||
end = kwargs.pop("end", None)
|
||||
if end is not None:
|
||||
if isinstance(end, unicode):
|
||||
want_unicode = True
|
||||
elif not isinstance(end, str):
|
||||
raise TypeError("end must be None or a string")
|
||||
if kwargs:
|
||||
raise TypeError("invalid keyword arguments to print()")
|
||||
if not want_unicode:
|
||||
for arg in args:
|
||||
if isinstance(arg, unicode):
|
||||
want_unicode = True
|
||||
break
|
||||
if want_unicode:
|
||||
newline = unicode("\n")
|
||||
space = unicode(" ")
|
||||
else:
|
||||
newline = "\n"
|
||||
space = " "
|
||||
if sep is None:
|
||||
sep = space
|
||||
if end is None:
|
||||
end = newline
|
||||
for i, arg in enumerate(args):
|
||||
if i:
|
||||
write(sep)
|
||||
write(arg)
|
||||
write(end)
|
||||
else:
|
||||
print_ = getattr(builtins, 'print')
|
||||
del builtins
|
||||
|
||||
|
||||
def bound_socket(*args, **kwargs):
|
||||
"""Bind socket to a specified source IP address"""
|
||||
|
||||
global source
|
||||
sock = socket_socket(*args, **kwargs)
|
||||
sock.bind((source, 0))
|
||||
return sock
|
||||
|
||||
|
||||
def distance(origin, destination):
|
||||
"""Determine distance between 2 sets of [lat,lon] in km"""
|
||||
|
||||
lat1, lon1 = origin
|
||||
lat2, lon2 = destination
|
||||
radius = 6371 # km
|
||||
|
||||
dlat = math.radians(lat2 - lat1)
|
||||
dlon = math.radians(lon2 - lon1)
|
||||
a = (math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1))
|
||||
* math.cos(math.radians(lat2)) * math.sin(dlon / 2)
|
||||
* math.sin(dlon / 2))
|
||||
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
|
||||
d = radius * c
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class FileGetter(threading.Thread):
|
||||
"""Thread class for retrieving a URL"""
|
||||
|
||||
def __init__(self, url, start):
|
||||
self.url = url
|
||||
self.result = None
|
||||
self.starttime = start
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def run(self):
|
||||
self.result = [0]
|
||||
try:
|
||||
if (time.time() - self.starttime) <= 10:
|
||||
f = urlopen(self.url)
|
||||
while 1 and not shutdown_event.isSet():
|
||||
self.result.append(len(f.read(10240)))
|
||||
if self.result[-1] == 0:
|
||||
break
|
||||
f.close()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
|
||||
def downloadSpeed(files, quiet=False):
|
||||
"""Function to launch FileGetter threads and calculate download speeds"""
|
||||
|
||||
start = time.time()
|
||||
|
||||
def producer(q, files):
|
||||
for file in files:
|
||||
thread = FileGetter(file, start)
|
||||
thread.start()
|
||||
q.put(thread, True)
|
||||
if not quiet and not shutdown_event.isSet():
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
|
||||
finished = []
|
||||
|
||||
def consumer(q, total_files):
|
||||
while len(finished) < total_files:
|
||||
thread = q.get(True)
|
||||
while thread.isAlive():
|
||||
thread.join(timeout=0.1)
|
||||
finished.append(sum(thread.result))
|
||||
del thread
|
||||
|
||||
q = Queue(6)
|
||||
prod_thread = threading.Thread(target=producer, args=(q, files))
|
||||
cons_thread = threading.Thread(target=consumer, args=(q, len(files)))
|
||||
start = time.time()
|
||||
prod_thread.start()
|
||||
cons_thread.start()
|
||||
while prod_thread.isAlive():
|
||||
prod_thread.join(timeout=0.1)
|
||||
while cons_thread.isAlive():
|
||||
cons_thread.join(timeout=0.1)
|
||||
return (sum(finished) / (time.time() - start))
|
||||
|
||||
|
||||
class FilePutter(threading.Thread):
|
||||
"""Thread class for putting a URL"""
|
||||
|
||||
def __init__(self, url, start, size):
|
||||
self.url = url
|
||||
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
data = chars * (int(round(int(size) / 36.0)))
|
||||
self.data = ('content1=%s' % data[0:int(size) - 9]).encode()
|
||||
del data
|
||||
self.result = None
|
||||
self.starttime = start
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if ((time.time() - self.starttime) <= 10 and
|
||||
not shutdown_event.isSet()):
|
||||
f = urlopen(self.url, self.data)
|
||||
f.read(11)
|
||||
f.close()
|
||||
self.result = len(self.data)
|
||||
else:
|
||||
self.result = 0
|
||||
except IOError:
|
||||
self.result = 0
|
||||
|
||||
|
||||
def uploadSpeed(url, sizes, quiet=False):
|
||||
"""Function to launch FilePutter threads and calculate upload speeds"""
|
||||
|
||||
start = time.time()
|
||||
|
||||
def producer(q, sizes):
|
||||
for size in sizes:
|
||||
thread = FilePutter(url, start, size)
|
||||
thread.start()
|
||||
q.put(thread, True)
|
||||
if not quiet and not shutdown_event.isSet():
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
|
||||
finished = []
|
||||
|
||||
def consumer(q, total_sizes):
|
||||
while len(finished) < total_sizes:
|
||||
thread = q.get(True)
|
||||
while thread.isAlive():
|
||||
thread.join(timeout=0.1)
|
||||
finished.append(thread.result)
|
||||
del thread
|
||||
|
||||
q = Queue(6)
|
||||
prod_thread = threading.Thread(target=producer, args=(q, sizes))
|
||||
cons_thread = threading.Thread(target=consumer, args=(q, len(sizes)))
|
||||
start = time.time()
|
||||
prod_thread.start()
|
||||
cons_thread.start()
|
||||
while prod_thread.isAlive():
|
||||
prod_thread.join(timeout=0.1)
|
||||
while cons_thread.isAlive():
|
||||
cons_thread.join(timeout=0.1)
|
||||
return (sum(finished) / (time.time() - start))
|
||||
|
||||
|
||||
def getAttributesByTagName(dom, tagName):
|
||||
"""Retrieve an attribute from an XML document and return it in a
|
||||
consistent format
|
||||
|
||||
Only used with xml.dom.minidom, which is likely only to be used
|
||||
with python versions older than 2.5
|
||||
"""
|
||||
elem = dom.getElementsByTagName(tagName)[0]
|
||||
return dict(list(elem.attributes.items()))
|
||||
|
||||
|
||||
def getConfig():
|
||||
"""Download the speedtest.net configuration and return only the data
|
||||
we are interested in
|
||||
"""
|
||||
|
||||
uh = urlopen('http://www.speedtest.net/speedtest-config.php')
|
||||
configxml = []
|
||||
while 1:
|
||||
configxml.append(uh.read(10240))
|
||||
if len(configxml[-1]) == 0:
|
||||
break
|
||||
if int(uh.code) != 200:
|
||||
return None
|
||||
uh.close()
|
||||
try:
|
||||
root = ET.fromstring(''.encode().join(configxml))
|
||||
config = {
|
||||
'client': root.find('client').attrib,
|
||||
'times': root.find('times').attrib,
|
||||
'download': root.find('download').attrib,
|
||||
'upload': root.find('upload').attrib}
|
||||
except AttributeError:
|
||||
root = DOM.parseString(''.join(configxml))
|
||||
config = {
|
||||
'client': getAttributesByTagName(root, 'client'),
|
||||
'times': getAttributesByTagName(root, 'times'),
|
||||
'download': getAttributesByTagName(root, 'download'),
|
||||
'upload': getAttributesByTagName(root, 'upload')}
|
||||
del root
|
||||
del configxml
|
||||
return config
|
||||
|
||||
|
||||
def closestServers(client, all=False):
|
||||
"""Determine the 5 closest speedtest.net servers based on geographic
|
||||
distance
|
||||
"""
|
||||
|
||||
uh = urlopen('http://www.speedtest.net/speedtest-servers.php')
|
||||
serversxml = []
|
||||
while 1:
|
||||
serversxml.append(uh.read(10240))
|
||||
if len(serversxml[-1]) == 0:
|
||||
break
|
||||
if int(uh.code) != 200:
|
||||
return None
|
||||
uh.close()
|
||||
try:
|
||||
root = ET.fromstring(''.encode().join(serversxml))
|
||||
elements = root.getiterator('server')
|
||||
except AttributeError:
|
||||
root = DOM.parseString(''.join(serversxml))
|
||||
elements = root.getElementsByTagName('server')
|
||||
servers = {}
|
||||
for server in elements:
|
||||
try:
|
||||
attrib = server.attrib
|
||||
except AttributeError:
|
||||
attrib = dict(list(server.attributes.items()))
|
||||
d = distance([float(client['lat']), float(client['lon'])],
|
||||
[float(attrib.get('lat')), float(attrib.get('lon'))])
|
||||
attrib['d'] = d
|
||||
if d not in servers:
|
||||
servers[d] = [attrib]
|
||||
else:
|
||||
servers[d].append(attrib)
|
||||
del root
|
||||
del serversxml
|
||||
del elements
|
||||
|
||||
closest = []
|
||||
for d in sorted(servers.keys()):
|
||||
for s in servers[d]:
|
||||
closest.append(s)
|
||||
if len(closest) == 5 and not all:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
break
|
||||
|
||||
del servers
|
||||
return closest
|
||||
|
||||
|
||||
def getBestServer(servers):
|
||||
"""Perform a speedtest.net "ping" to determine which speedtest.net
|
||||
server has the lowest latency
|
||||
"""
|
||||
|
||||
results = {}
|
||||
for server in servers:
|
||||
cum = []
|
||||
url = os.path.dirname(server['url'])
|
||||
for i in range(0, 3):
|
||||
try:
|
||||
uh = urlopen('%s/latency.txt' % url)
|
||||
except HTTPError:
|
||||
cum.append(3600)
|
||||
continue
|
||||
start = time.time()
|
||||
text = uh.read(9)
|
||||
total = time.time() - start
|
||||
if int(uh.code) == 200 and text == 'test=test'.encode():
|
||||
cum.append(total)
|
||||
else:
|
||||
cum.append(3600)
|
||||
uh.close()
|
||||
avg = round((sum(cum) / 3) * 1000000, 3)
|
||||
results[avg] = server
|
||||
|
||||
fastest = sorted(results.keys())[0]
|
||||
best = results[fastest]
|
||||
best['latency'] = fastest
|
||||
|
||||
return best
|
||||
|
||||
|
||||
def ctrl_c(signum, frame):
|
||||
"""Catch Ctrl-C key sequence and set a shutdown_event for our threaded
|
||||
operations
|
||||
"""
|
||||
|
||||
global shutdown_event
|
||||
shutdown_event.set()
|
||||
raise SystemExit('\nCancelling...')
|
||||
|
||||
|
||||
def version():
|
||||
"""Print the version"""
|
||||
|
||||
raise SystemExit(__version__)
|
||||
|
||||
|
||||
def speedtest():
|
||||
"""Run the full speedtest.net test"""
|
||||
|
||||
global shutdown_event, source
|
||||
shutdown_event = threading.Event()
|
||||
|
||||
signal.signal(signal.SIGINT, ctrl_c)
|
||||
|
||||
description = (
|
||||
'Command line interface for testing internet bandwidth using '
|
||||
'speedtest.net.\n'
|
||||
'------------------------------------------------------------'
|
||||
'--------------\n'
|
||||
'https://github.com/sivel/speedtest-cli')
|
||||
|
||||
parser = ArgParser(description=description)
|
||||
# Give optparse.OptionParser an `add_argument` method for
|
||||
# compatibility with argparse.ArgumentParser
|
||||
try:
|
||||
parser.add_argument = parser.add_option
|
||||
except AttributeError:
|
||||
pass
|
||||
parser.add_argument('--share', action='store_true',
|
||||
help='Generate and provide a URL to the speedtest.net '
|
||||
'share results image')
|
||||
parser.add_argument('--simple', action='store_true',
|
||||
help='Suppress verbose output, only show basic '
|
||||
'information')
|
||||
parser.add_argument('--list', action='store_true',
|
||||
help='Display a list of speedtest.net servers '
|
||||
'sorted by distance')
|
||||
parser.add_argument('--server', help='Specify a server ID to test against')
|
||||
parser.add_argument('--mini', help='URL of the Speedtest Mini server')
|
||||
parser.add_argument('--source', help='Source IP address to bind to')
|
||||
parser.add_argument('--version', action='store_true',
|
||||
help='Show the version number and exit')
|
||||
|
||||
options = parser.parse_args()
|
||||
if isinstance(options, tuple):
|
||||
args = options[0]
|
||||
else:
|
||||
args = options
|
||||
del options
|
||||
|
||||
# Print the version and exit
|
||||
if args.version:
|
||||
version()
|
||||
|
||||
# If specified bind to a specific IP address
|
||||
if args.source:
|
||||
source = args.source
|
||||
socket.socket = bound_socket
|
||||
|
||||
if not args.simple:
|
||||
print_('Retrieving speedtest.net configuration...')
|
||||
try:
|
||||
config = getConfig()
|
||||
except URLError:
|
||||
print_('Cannot retrieve speedtest configuration')
|
||||
sys.exit(1)
|
||||
|
||||
if not args.simple:
|
||||
print_('Retrieving speedtest.net server list...')
|
||||
if args.list or args.server:
|
||||
servers = closestServers(config['client'], True)
|
||||
if args.list:
|
||||
serverList = []
|
||||
for server in servers:
|
||||
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
||||
'[%(d)0.2f km]' % server)
|
||||
serverList.append(line)
|
||||
# Python 2.7 and newer seem to be ok with the resultant encoding
|
||||
# from parsing the XML, but older versions have some issues.
|
||||
# This block should detect whether we need to encode or not
|
||||
try:
|
||||
unicode()
|
||||
print_('\n'.join(serverList).encode('utf-8', 'ignore'))
|
||||
except NameError:
|
||||
print_('\n'.join(serverList))
|
||||
except IOError:
|
||||
pass
|
||||
sys.exit(0)
|
||||
else:
|
||||
servers = closestServers(config['client'])
|
||||
|
||||
if not args.simple:
|
||||
print_('Testing from %(isp)s (%(ip)s)...' % config['client'])
|
||||
|
||||
if args.server:
|
||||
try:
|
||||
best = getBestServer(filter(lambda x: x['id'] == args.server,
|
||||
servers))
|
||||
except IndexError:
|
||||
print_('Invalid server ID')
|
||||
sys.exit(1)
|
||||
elif args.mini:
|
||||
name, ext = os.path.splitext(args.mini)
|
||||
if ext:
|
||||
url = os.path.dirname(args.mini)
|
||||
else:
|
||||
url = args.mini
|
||||
urlparts = urlparse(url)
|
||||
try:
|
||||
f = urlopen(args.mini)
|
||||
except:
|
||||
print_('Invalid Speedtest Mini URL')
|
||||
sys.exit(1)
|
||||
else:
|
||||
text = f.read()
|
||||
f.close()
|
||||
extension = re.findall('upload_extension: "([^"]+)"', text.decode())
|
||||
if not urlparts or not extension:
|
||||
print_('Please provide the full URL of your Speedtest Mini server')
|
||||
sys.exit(1)
|
||||
servers = [{
|
||||
'sponsor': 'Speedtest Mini',
|
||||
'name': urlparts[1],
|
||||
'd': 0,
|
||||
'url': '%s/speedtest/upload.%s' % (url.rstrip('/'), extension[0]),
|
||||
'latency': 0,
|
||||
'id': 0
|
||||
}]
|
||||
try:
|
||||
best = getBestServer(servers)
|
||||
except:
|
||||
best = servers[0]
|
||||
else:
|
||||
if not args.simple:
|
||||
print_('Selecting best server based on ping...')
|
||||
best = getBestServer(servers)
|
||||
|
||||
if not args.simple:
|
||||
# Python 2.7 and newer seem to be ok with the resultant encoding
|
||||
# from parsing the XML, but older versions have some issues.
|
||||
# This block should detect whether we need to encode or not
|
||||
try:
|
||||
unicode()
|
||||
print_(('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
||||
'%(latency)s ms' % best).encode('utf-8', 'ignore'))
|
||||
except NameError:
|
||||
print_('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
||||
'%(latency)s ms' % best)
|
||||
else:
|
||||
print_('Ping: %(latency)s ms' % best)
|
||||
|
||||
sizes = [350, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000]
|
||||
urls = []
|
||||
for size in sizes:
|
||||
for i in range(0, 4):
|
||||
urls.append('%s/random%sx%s.jpg' %
|
||||
(os.path.dirname(best['url']), size, size))
|
||||
if not args.simple:
|
||||
print_('Testing download speed', end='')
|
||||
dlspeed = downloadSpeed(urls, args.simple)
|
||||
if not args.simple:
|
||||
print_()
|
||||
print_('Download: %0.2f Mbit/s' % ((dlspeed / 1000 / 1000) * 8))
|
||||
|
||||
sizesizes = [int(.25 * 1000 * 1000), int(.5 * 1000 * 1000)]
|
||||
sizes = []
|
||||
for size in sizesizes:
|
||||
for i in range(0, 25):
|
||||
sizes.append(size)
|
||||
if not args.simple:
|
||||
print_('Testing upload speed', end='')
|
||||
ulspeed = uploadSpeed(best['url'], sizes, args.simple)
|
||||
if not args.simple:
|
||||
print_()
|
||||
print_('Upload: %0.2f Mbit/s' % ((ulspeed / 1000 / 1000) * 8))
|
||||
|
||||
if args.share and args.mini:
|
||||
print_('Cannot generate a speedtest.net share results image while '
|
||||
'testing against a Speedtest Mini server')
|
||||
elif args.share:
|
||||
dlspeedk = int(round((dlspeed / 1000) * 8, 0))
|
||||
ping = int(round(best['latency'], 0))
|
||||
ulspeedk = int(round((ulspeed / 1000) * 8, 0))
|
||||
|
||||
# Build the request to send results back to speedtest.net
|
||||
# We use a list instead of a dict because the API expects parameters
|
||||
# in a certain order
|
||||
apiData = [
|
||||
'download=%s' % dlspeedk,
|
||||
'ping=%s' % ping,
|
||||
'upload=%s' % ulspeedk,
|
||||
'promo=',
|
||||
'startmode=%s' % 'pingselect',
|
||||
'recommendedserverid=%s' % best['id'],
|
||||
'accuracy=%s' % 1,
|
||||
'serverid=%s' % best['id'],
|
||||
'hash=%s' % md5(('%s-%s-%s-%s' %
|
||||
(ping, ulspeedk, dlspeedk, '297aae72'))
|
||||
.encode()).hexdigest()]
|
||||
|
||||
req = Request('http://www.speedtest.net/api/api.php',
|
||||
data='&'.join(apiData).encode())
|
||||
req.add_header('Referer', 'http://c.speedtest.net/flash/speedtest.swf')
|
||||
f = urlopen(req)
|
||||
response = f.read()
|
||||
code = f.code
|
||||
f.close()
|
||||
|
||||
if int(code) != 200:
|
||||
print_('Could not submit results to speedtest.net')
|
||||
sys.exit(1)
|
||||
|
||||
qsargs = parse_qs(response.decode())
|
||||
resultid = qsargs.get('resultid')
|
||||
if not resultid or len(resultid) != 1:
|
||||
print_('Could not submit results to speedtest.net')
|
||||
sys.exit(1)
|
||||
|
||||
print_('Share results: http://www.speedtest.net/result/%s.png' %
|
||||
resultid[0])
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
speedtest()
|
||||
except KeyboardInterrupt:
|
||||
print_('\nCancelling...')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
# vim:ts=4:sw=4:expandtab
|
||||
Reference in New Issue
Block a user