Merge branch 'master' into v1.6

This commit is contained in:
Ken Rice 2016-06-12 21:53:47 -05:00
commit 608c65c0d3
81 changed files with 2729 additions and 1680 deletions

View File

@ -1122,6 +1122,8 @@ elif test "$ac_cv_sizeof_long" = "8"; then
case "$host" in
*pc-solaris2*)
;;
sparc-*-solaris2*)
;;
*-solaris2*|*apple-darwin*|*-openbsd*)
if test "$ac_cv_sizeof_long_long" = "8"; then
int64_t_fmt='#define SWITCH_INT64_T_FMT "lld"'

1
debian/bootstrap.sh vendored
View File

@ -608,6 +608,7 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}),
freeswitch-mod-memcache (= \${binary:Version}),
freeswitch-mod-nibblebill (= \${binary:Version}),
freeswitch-mod-oreka (= \${binary:Version}),
freeswitch-mod-png (= \${binary:Version}),
freeswitch-mod-redis (= \${binary:Version}),
freeswitch-mod-rss (= \${binary:Version}),
freeswitch-mod-sms (= \${binary:Version}),

View File

@ -19,7 +19,7 @@ Group=daemon
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
LimitSTACK=240K
LimitSTACK=250000
LimitRTPRIO=infinity
LimitRTTIME=7000000
IOSchedulingClass=realtime

2
debian/util.sh vendored
View File

@ -199,7 +199,7 @@ create_dsc () {
m) modules_list="$OPTARG";;
p) modules_add="$modules_add $OPTARG";;
s) speed="$OPTARG";;
u) suite_postfix="$OPTARG"; suite_postfix_p=true; ;;
u) suite_postfix="$OPTARG"; suite_postfix_p=true;;
z) zl="$OPTARG";;
esac
done

View File

@ -1543,7 +1543,7 @@ LOGGERS_MODULES="loggers/mod_console loggers/mod_graylog2 loggers/mod_logfile lo
# Phrase engine language modules
#
######################################################################################################################
SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_he say/mod_say_ru say/mod_say_sv"
SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_es say/mod_say_pt say/mod_say_fr say/mod_say_he say/mod_say_ru say/mod_say_sv"
######################################################################################################################
#
@ -2442,7 +2442,7 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/es/demo/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/es/vm/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/es/dir/*.xml
%{MODINSTDIR}/mod_say_en.so*
%{MODINSTDIR}/mod_say_es.so*
%files lang-pt
%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/pt
@ -2453,7 +2453,7 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/pt/demo/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/pt/vm/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/lang/pt/dir/*.xml
%{MODINSTDIR}/mod_say_en.so*
%{MODINSTDIR}/mod_say_pt.so*
%files lang-sv
%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/lang/sv

View File

@ -6,12 +6,13 @@ function getCodecPayloadType(sdpLine){var pattern=new RegExp('a=rtpmap:(\\d+) \\
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,localVideo:null,screenShare:false,useCamera:"any",iceServers:false,videoParams:{},audioParams:{},callbacks:{onICEComplete:function(){},onICE:function(){},onOfferSDP:function(){}},},options);this.enabled=true;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,}};}
$.FSRTC=function(options){this.options=$.extend({useVideo:null,useStereo:false,userData:null,localVideo:null,screenShare:false,useCamera:"any",iceServers:false,videoParams:{},audioParams:{},callbacks:{onICEComplete:function(){},onICE:function(){},onOfferSDP:function(){}},},options);this.audioEnabled=true;this.videoEnabled=true;this.mediaData={SDP:null,profile:{},candidateList:[]};if(moz){this.constraints={offerToReceiveAudio:this.options.useSpeak==="none"?false:true,offerToReceiveVideo:this.options.useVideo?true:false,};}else{this.constraints={optional:[{'DtlsSrtpKeyAgreement':'true'}],mandatory:{OfferToReceiveAudio:this.options.useSpeak==="none"?false:true,OfferToReceiveVideo:this.options.useVideo?true:false,}};}
if(self.options.useVideo){self.options.useVideo.style.display='none';}
setCompat();checkCompat();};$.FSRTC.validRes=[];$.FSRTC.prototype.useVideo=function(obj,local){var self=this;if(obj){self.options.useVideo=obj;self.options.localVideo=local;if(moz){self.constraints.offerToReceiveVideo=true;}else{self.constraints.mandatory.OfferToReceiveVideo=true;}}else{self.options.useVideo=null;self.options.localVideo=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;}}
var sdpLines=sdp.split('\r\n');var opusIndex=findLine(sdpLines,'a=rtpmap','opus/48000'),opusPayload;if(!opusIndex){return sdp;}else{opusPayload=getCodecPayloadType(sdpLines[opusIndex]);}
var fmtpLineIndex=findLine(sdpLines,'a=fmtp:'+opusPayload.toString());if(fmtpLineIndex===null){sdpLines[opusIndex]=sdpLines[opusIndex]+'\r\na=fmtp:'+opusPayload.toString()+" stereo=1; sprop-stereo=1"}else{sdpLines[fmtpLineIndex]=sdpLines[fmtpLineIndex].concat('; stereo=1; sprop-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,e){console.log('There has been a problem retrieving the streams - did you allow access? Check Device Resolution',e);doCallback(self,"onError",e);}
@ -27,29 +28,36 @@ function onRemoteStream(self,stream){if(self.options.useVideo){self.options.useV
var element=self.options.useAudio;console.log("REMOTE STREAM",stream,element);if(typeof element.srcObject!=='undefined'){element.srcObject=stream;}else if(typeof element.mozSrcObject!=='undefined'){element.mozSrcObject=stream;}else if(typeof element.src!=='undefined'){element.src=URL.createObjectURL(stream);}else{console.error('Error attaching stream to element.');}
self.options.useAudio.play();self.remoteStream=stream;}
function onOfferSDP(self,sdp){self.mediaData.SDP=self.stereoHack(sdp.sdp);console.log("Offer SDP");doCallback(self,"onOfferSDP");}
$.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(moz){self.options.useVideo['mozSrcObject']=null;}else{self.options.useVideo['src']='';}}
if(self.localStream){self.localStream.stop();self.localStream=null;}
$.FSRTC.prototype.answer=function(sdp,onSuccess,onError){this.peer.addAnswerSDP({type:"answer",sdp:sdp},onSuccess,onError);};$.FSRTC.prototype.stopPeer=function(){if(self.peer){console.log("stopping peer");self.peer.stop();}}
$.FSRTC.prototype.stop=function(){var self=this;if(self.options.useVideo){self.options.useVideo.style.display='none';if(moz){self.options.useVideo['mozSrcObject']=null;}else{self.options.useVideo['src']='';}}
if(self.localStream){if(typeof self.localStream.stop=='function'){self.localStream.stop();}else{if(self.localStream.active){var tracks=self.localStream.getTracks();console.error(tracks);tracks.forEach(function(track,index){console.log(track);track.stop();})}}
self.localStream=null;}
if(self.options.localVideo){self.options.localVideo.style.display='none';if(moz){self.options.localVideo['mozSrcObject']=null;}else{self.options.localVideo['src']='';}}
if(self.options.localVideoStream){self.options.localVideoStream.stop();}
if(self.peer){console.log("stopping peer");self.peer.stop();}};$.FSRTC.prototype.getMute=function(){var self=this;return self.enabled;}
if(self.options.localVideoStream){if(typeof self.options.localVideoStream.stop=='function'){self.options.localVideoStream.stop();}else{if(self.options.localVideoStream.active){var tracks=self.options.localVideoStream.getTracks();console.error(tracks);tracks.forEach(function(track,index){console.log(track);track.stop();})}}}
if(self.peer){console.log("stopping peer");self.peer.stop();}};$.FSRTC.prototype.getMute=function(){var self=this;return self.audioEnabled;}
$.FSRTC.prototype.setMute=function(what){var self=this;var audioTracks=self.localStream.getAudioTracks();for(var i=0,len=audioTracks.length;i<len;i++){switch(what){case"on":audioTracks[i].enabled=true;break;case"off":audioTracks[i].enabled=false;break;case"toggle":audioTracks[i].enabled=!audioTracks[i].enabled;default:break;}
self.enabled=audioTracks[i].enabled;}
return!self.enabled;}
self.audioEnabled=audioTracks[i].enabled;}
return!self.audioEnabled;}
$.FSRTC.prototype.getVideoMute=function(){var self=this;return self.videoEnabled;}
$.FSRTC.prototype.setVideoMute=function(what){var self=this;var videoTracks=self.localStream.getVideoTracks();for(var i=0,len=videoTracks.length;i<len;i++){switch(what){case"on":videoTracks[i].enabled=true;break;case"off":videoTracks[i].enabled=false;break;case"toggle":videoTracks[i].enabled=!videoTracks[i].enabled;default:break;}
self.videoEnabled=videoTracks[i].enabled;}
return!self.videoEnabled;}
$.FSRTC.prototype.createAnswer=function(params){var self=this;self.type="answer";self.remoteSDP=params.sdp;console.debug("inbound sdp: ",params.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(e){onStreamError(self,e);}
var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);if(self.options.useVideo&&self.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:self.options.videoParams,optional:[]},},localVideo:self.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:obj.options.audioParams,optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}}
getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};function getMediaParams(obj){var audio;if(obj.options.useMic&&obj.options.useMic==="none"){console.log("Microphone Disabled");audio=false;}else if(obj.options.videoParams&&obj.options.screenShare){console.error("SCREEN SHARE");audio=false;}else{audio={mandatory:{},optional:[]};if(obj.options.useMic!=="any"){audio.optional=[{sourceId:obj.options.useMic}]}
if(obj.options.audioParams){for(var key in obj.options.audioParams){var con={};con[key]=obj.options.audioParams[key];audio.optional.push(con);}}}
if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audio:false,video:{mandatory:obj.options.videoParams,optional:[]},},localVideo:obj.options.localVideo,onsuccess:function(e){self.options.localVideoStream=e;console.log("local video ready");},onerror:function(e){console.error("local video error!");}});}
var video={};var bestFrameRate=obj.options.videoParams.vertoBestFrameRate;delete obj.options.videoParams.vertoBestFrameRate;if(window.moz){video=obj.options.videoParams;if(!video.width)video.width=video.minWidth;if(!video.height)video.height=video.minHeight;if(!video.frameRate)video.frameRate=video.minFrameRate;}else{video={mandatory:obj.options.videoParams,optional:[]}}
var video={};var bestFrameRate=obj.options.videoParams.vertoBestFrameRate;delete obj.options.videoParams.vertoBestFrameRate;video={mandatory:obj.options.videoParams,optional:[]}
var useVideo=obj.options.useVideo;if(useVideo&&obj.options.useCamera&&obj.options.useCamera!=="none"){if(!video.optional){video.optional=[];}
if(obj.options.useCamera!=="any"){video.optional.push({sourceId:obj.options.useCamera});}
if(bestFrameRate&&!window.moz){video.optional.push({minFrameRate:bestFrameRate});}}else{video=false;useVideo=false;}
if(bestFrameRate){video.optional.push({minFrameRate:bestFrameRate});video.optional.push({maxFrameRate:bestFrameRate});}}else{console.log("Camera Disabled");video=false;useVideo=false;}
return{audio:audio,video:video,useVideo:useVideo};}
$.FSRTC.prototype.call=function(profile){checkCompat();var self=this;var screen=false;self.type="offer";if(self.options.videoParams&&self.options.screenShare){screen=true;}
function onSuccess(stream){self.localStream=stream;if(screen){if(moz){self.constraints.OfferToReceiveVideo=false;}else{self.constraints.mandatory.OfferToReceiveVideo=false;}}
self.peer=RTCPeerConnection({type:self.type,attachStream:self.localStream,onICE:function(candidate){return onICE(self,candidate);},onICEComplete:function(){return onICEComplete(self);},onRemoteStream:screen?function(stream){}: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,stream);}
function onError(e){onStreamError(self,e);}
var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});};window.moz=!!navigator.mozGetUserMedia;function RTCPeerConnection(options){var gathering=false,done=false;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 iceServers=null;if(options.iceServers){var tmp=options.iceServers;if(typeof(tmp)==="boolean"){tmp=null;}
var mediaParams=getMediaParams(self);console.log("Audio constraints",mediaParams.audio);console.log("Video constraints",mediaParams.video);if(mediaParams.audio||mediaParams.video){getUserMedia({constraints:{audio:mediaParams.audio,video:mediaParams.video},video:mediaParams.useVideo,onsuccess:onSuccess,onerror:onError});}else{onSuccess(null);}};window.moz=!!navigator.mozGetUserMedia;function RTCPeerConnection(options){var gathering=false,done=false;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 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){iceServers.iceServers=[STUN];}}
var optional={optional:[]};if(!moz){optional.optional=[{DtlsSrtpKeyAgreement:true},{RtpDataChannels:options.onChannelMessage?true:false}];}
@ -74,7 +82,7 @@ function useless(){log('Error in fake:true');}
function onSdpSuccess(){}
function onSdpError(e){if(options.onChannelError){options.onChannelError(e);}
console.error('sdp error:',e);}
return{addAnswerSDP:function(sdp,cbSuccess,cbError){peer.setRemoteDescription(new SessionDescription(sdp),cbSuccess?cbSuccess:onSdpSuccess,cbError?cbError:onSdpError);},addICE:function(candidate){peer.addIceCandidate(new IceCandidate({sdpMLineIndex:candidate.sdpMLineIndex,candidate:candidate.candidate}));},peer:peer,channel:channel,sendData:function(message){if(channel){channel.send(message);}},stop:function(){peer.close();if(options.attachStream){options.attachStream.stop();}}};}
return{addAnswerSDP:function(sdp,cbSuccess,cbError){peer.setRemoteDescription(new SessionDescription(sdp),cbSuccess?cbSuccess:onSdpSuccess,cbError?cbError:onSdpError);},addICE:function(candidate){peer.addIceCandidate(new IceCandidate({sdpMLineIndex:candidate.sdpMLineIndex,candidate:candidate.candidate}));},peer:peer,channel:channel,sendData:function(message){if(channel){channel.send(message);}},stop:function(){peer.close();if(options.attachStream){if(typeof options.attachStream.stop=='function'){options.attachStream.stop();}else{options.attachStream.active=false;}}}};}
var video_constraints={mandatory:{},optional:[]};function getUserMedia(options){var n=navigator,media;n.getMedia=n.webkitGetUserMedia||n.mozGetUserMedia;n.getMedia(options.constraints||{audio:true,video:video_constraints},streaming,options.onerror||function(e){console.error(e);});function streaming(stream){if(options.localVideo){options.localVideo[moz?'mozSrcObject':'src']=moz?stream:window.webkitURL.createObjectURL(stream);options.localVideo.style.display='block';}
if(options.onsuccess){options.onsuccess(stream);}
media=stream;}
@ -86,13 +94,14 @@ return[w,h];}
var resList=[[320,180],[320,240],[640,360],[640,480],[1280,720],[1920,1080]];var resI=0;var ttl=0;var checkRes=function(cam,func){if(resI>=resList.length){var res={'validRes':$.FSRTC.validRes,'bestResSupported':$.FSRTC.bestResSupported()};localStorage.setItem("res_"+cam,$.toJSON(res));if(func)return func(res);return;}
var video={mandatory:{},optional:[]}
if(cam){video.optional=[{sourceId:cam}];}
w=resList[resI][0];h=resList[resI][1];resI++;video.mandatory={"minWidth":w,"minHeight":h,"maxWidth":w,"maxHeight":h};if(window.moz){video=video.mandatory;if(!video.width)video.width=video.minWidth;if(!video.height)video.height=video.minHeight;if(!video.frameRate)video.frameRate=video.minFrameRate;}
getUserMedia({constraints:{audio:ttl++==0,video:video},onsuccess:function(e){e.stop();console.info(w+"x"+h+" supported.");$.FSRTC.validRes.push([w,h]);checkRes(cam,func);},onerror:function(e){console.error(w+"x"+h+" not supported.");checkRes(cam,func);}});}
w=resList[resI][0];h=resList[resI][1];resI++;video.mandatory={"minWidth":w,"minHeight":h,"maxWidth":w,"maxHeight":h};getUserMedia({constraints:{audio:ttl++==0,video:video},onsuccess:function(e){e.getTracks().forEach(function(track){track.stop();});console.info(w+"x"+h+" supported.");$.FSRTC.validRes.push([w,h]);checkRes(cam,func);},onerror:function(e){console.error(w+"x"+h+" not supported.");checkRes(cam,func);}});}
$.FSRTC.getValidRes=function(cam,func){var used=[];var cached=localStorage.getItem("res_"+cam);if(cached){var cache=$.parseJSON(cached);if(cache){$.FSRTC.validRes=cache.validRes;console.log("CACHED RES FOR CAM "+cam,cache);}else{console.error("INVALID CACHE");}
return func?func(cache):null;}
$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
$.FSRTC.checkPerms=function(runtime,check_audio,check_video){getUserMedia({constraints:{audio:check_audio,video:check_video,},onsuccess:function(e){e.stop();console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true)}},onerror:function(e){if(check_video&&check_audio){console.error("error, retesting with audio params only");return $.FSRTC.checkPerms(runtime,check_audio,false);}
console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
$.FSRTC.checkPerms=function(runtime,check_audio,check_video){getUserMedia({constraints:{audio:check_audio,video:check_video,},onsuccess:function(e){e.getTracks().forEach(function(track){track.stop();});console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true);}},onerror:function(e){if(check_video&&check_audio){console.error("error, retesting with audio params only");return $.FSRTC.checkPerms(runtime,check_audio,false);}
console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.speedTest=function(bytes,cb){var socket=this.options.getSocket(this.wsOnMessage);if(socket!==null){this.speedCB=cb;this.speedBytes=bytes;socket.send("#SPU "+bytes);var loops=bytes/1024;var rem=bytes%1024;var i;var data=new Array(1024).join(".");for(i=0;i<loops;i++){socket.send("#SPB "+data);}
if(rem){socket.send("#SPB "+data);}
socket.send("#SPE");}};$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
if(this.options.sessid){params.sessid=this.options.sessid;}
var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
@ -110,7 +119,9 @@ console.error("Websocket Lost "+self.ws_cnt+" sleep: "+self.ws_sleep+"msec");sel
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,loginParams:self.options.loginParams,userVariables:self.options.userVariables},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('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;if(event.data[0]=="#"&&event.data[1]=="S"&&event.data[2]=="P"){if(event.data[3]=="U"){this.up_dur=parseInt(event.data.substring(4));}else if(this.speedCB&&event.data[3]=="D"){this.down_dur=parseInt(event.data.substring(4));var up_kps=(((this.speedBytes*8)/(this.up_dur/1000))/1024).toFixed(0);var down_kps=(((this.speedBytes*8)/(this.down_dur/1000))/1024).toFixed(0);console.info("Speed Test: Up: "+up_kps+" Down: "+down_kps);this.speedCB(event,{upDur:this.up_dur,downDur:this.down_dur,upKPS:up_kps,downKPS:down_kps});this.speedCB=null;}
return;}
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,loginParams:self.options.loginParams,userVariables:self.options.userVariables},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;}
if(typeof this.options.onmessage==='function'){event.eventData=response;if(!event.eventData){event.eventData={};}
@ -125,12 +136,13 @@ for(i=0;i<this._requests.length;i++){call=this._requests[i];batch_request.push(c
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 sources=[];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,localTag:null,videoParams:{},audioParams:{},loginParams:{},deviceParams:{onResCheck:null},userVariables:{},iceServers:false,ringSleep:6000,sessid:null},options);if(verto.options.deviceParams.useCamera){$.FSRTC.getValidRes(verto.options.deviceParams.useCamera,verto.options.deviceParams.onResCheck);}else{verto.options.deviceParams.useCamera="any";$.FSRTC.getValidRes(undefined,undefined);}
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,localTag:null,videoParams:{},audioParams:{},loginParams:{},deviceParams:{onResCheck:null},userVariables:{},iceServers:false,ringSleep:6000,sessid:null},options);if(verto.options.deviceParams.useCamera){$.FSRTC.getValidRes(verto.options.deviceParams.useCamera,verto.options.deviceParams.onResCheck);}
if(!verto.options.deviceParams.useMic){verto.options.deviceParams.useMic="any";}
if(!verto.options.deviceParams.useSpeak){verto.options.deviceParams.useSpeak="any";}
if(verto.options.sessid){verto.sessid=verto.options.sessid;}else{verto.sessid=localStorage.getItem("verto_session_uuid")||generateGUID();localStorage.setItem("verto_session_uuid",verto.sessid);}
verto.dialogs={};verto.callbacks=callbacks||{};verto.eventSUBS={};verto.rpcClient=new $.JsonRpcClient({login:verto.options.login,passwd:verto.options.passwd,socketUrl:verto.options.socketUrl,loginParams:verto.options.loginParams,userVariables:verto.options.userVariables,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.purge();}});var tag=verto.options.tag;if(typeof(tag)==="function"){tag=tag();}
if(verto.options.ringFile&&verto.options.tag){verto.ringer=$("#"+tag);}
verto.rpcClient.call('login',{});};$.verto.prototype.deviceParams=function(obj){var verto=this;for(var i in obj){verto.options.deviceParams[i]=obj[i];}
if(obj.useCamera){$.FSRTC.getValidRes(verto.options.deviceParams.useCamera,obj?obj.onResCheck:undefined);}};$.verto.prototype.videoParams=function(obj){var verto=this;for(var i in obj){verto.options.videoParams[i]=obj[i];}};$.verto.prototype.iceServers=function(obj){var verto=this;verto.options.iceServers=obj;};$.verto.prototype.loginData=function(params){var verto=this;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++;}
@ -190,47 +202,51 @@ break;case"clear":la.clear();break;case"reorder":la.reorder(packet.wireSerno,pac
break;}};if(la.context){binding=la.verto.subscribe(la.context,{handler:eventHandler,userData:la,subParams:config.subParams});}
la.destroy=function(){la._clear();la.verto.unsubscribe(binding);};la.sendCommand=function(cmd,obj){var self=la;self.broadcast(self.context,{liveArray:{command:cmd,context:self.context,name:self.name,obj:obj}});};la.bootstrap=function(obj){var self=la;la.sendCommand("bootstrap",obj);};la.changepage=function(obj){var self=la;self.clear();self.broadcast(self.context,{liveArray:{command:"changepage",context:la.context,name:la.name,obj:obj}});};la.heartbeat=function(obj){var self=la;var callback=function(){self.heartbeat.call(self,obj);};self.broadcast(self.context,{liveArray:{command:"heartbeat",context:self.context,name:self.name,obj:obj}});self.hb_pid=setTimeout(callback,30000);};la.bootstrap(la.user_obj);};$.verto.liveTable=function(verto,context,name,jq,config){var dt;var la=new $.verto.liveArray(verto,context,name,{subParams:config.subParams});var lt=this;lt.liveArray=la;lt.dataTable=dt;lt.verto=verto;lt.destroy=function(){if(dt){dt.fnDestroy();}
if(la){la.destroy();}
dt=null;la=null;};la.onErr=function(obj,args){console.error("Error: ",obj,args);};la.onChange=function(obj,args){var index=0;var iserr=0;if(!dt){if(!config.aoColumns){if(args.action!="init"){return;}
dt=null;la=null;};la.onErr=function(obj,args){console.error("Error: ",obj,args);};function genRow(data){if(typeof(data[4])==="string"&&data[4].indexOf("{")>-1){var tmp=$.parseJSON(data[4]);data[4]=tmp.oldStatus;data[5]=null;}
return data;}
function genArray(obj){var data=obj.asArray();for(var i in data){data[i]=genRow(data[i]);}
return data;}
la.onChange=function(obj,args){var index=0;var iserr=0;if(!dt){if(!config.aoColumns){if(args.action!="init"){return;}
config.aoColumns=[];for(var i in args.data){config.aoColumns.push({"sTitle":args.data[i]});}}
dt=jq.dataTable(config);}
if(dt&&(args.action=="del"||args.action=="modify")){index=args.index;if(index===undefined&&args.key){index=la.indexOf(args.key);}
if(index===undefined){console.error("INVALID PACKET Missing INDEX\n",args);return;}}
if(config.onChange){config.onChange(obj,args);}
try{switch(args.action){case"bootObj":if(!args.data){console.error("missing data");return;}
dt.fnClearTable();dt.fnAddData(obj.asArray());dt.fnAdjustColumnSizing();break;case"add":if(!args.data){console.error("missing data");return;}
if(args.redraw>-1){dt.fnClearTable();dt.fnAddData(obj.asArray());}else{dt.fnAddData(args.data);}
dt.fnClearTable();dt.fnAddData(genArray(obj));dt.fnAdjustColumnSizing();break;case"add":if(!args.data){console.error("missing data");return;}
if(args.redraw>-1){dt.fnClearTable();dt.fnAddData(genArray(obj));}else{dt.fnAddData(genRow(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++;}
dt.fnUpdate(genRow(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(genArray(obj));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.conf=function(verto,params){var conf=this;conf.params=$.extend({dialog:null,hasVid:false,laData:null,onBroadcast:null,onLaChange:null,onLaRow:null},params);conf.verto=verto;conf.serno=CONFMAN_SERNO++;createMainModeratorMethods();verto.subscribe(conf.params.laData.modChannel,{handler:function(v,e){if(conf.params.onBroadcast){conf.params.onBroadcast(verto,conf,e.data);}}});verto.subscribe(conf.params.laData.chatChannel,{handler:function(v,e){if(typeof(conf.params.chatCallback)==="function"){conf.params.chatCallback(v,e);}}});};$.verto.conf.prototype.modCommand=function(cmd,id,value){var conf=this;conf.verto.rpcClient.call("verto.broadcast",{"eventChannel":conf.params.laData.modChannel,"data":{"application":"conf-control","command":cmd,"id":id,"value":value}});};$.verto.conf.prototype.destroy=function(){var conf=this;conf.destroyed=true;conf.params.onBroadcast(conf.verto,conf,'destroy');if(conf.params.laData.modChannel){conf.verto.unsubscribe(conf.params.laData.modChannel);}
if(conf.params.laData.chatChannel){conf.verto.unsubscribe(conf.params.laData.chatChannel);}};function createMainModeratorMethods(){$.verto.conf.prototype.listVideoLayouts=function(){this.modCommand("list-videoLayouts",null,null);};$.verto.conf.prototype.play=function(file){this.modCommand("play",null,file);};$.verto.conf.prototype.stop=function(){this.modCommand("stop",null,"all");};$.verto.conf.prototype.record=function(file){this.modCommand("recording",null,["start",file]);};$.verto.conf.prototype.stopRecord=function(){this.modCommand("recording",null,["stop","all"]);};$.verto.conf.prototype.snapshot=function(file){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-write-png",null,file);};$.verto.conf.prototype.setVideoLayout=function(layout){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-layout",null,layout);};$.verto.conf.prototype.kick=function(memberID){this.modCommand("kick",parseInt(memberID));};$.verto.conf.prototype.muteMic=function(memberID){this.modCommand("tmute",parseInt(memberID));};$.verto.conf.prototype.muteVideo=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-write-png",null,file);};$.verto.conf.prototype.setVideoLayout=function(layout,canvasID){if(!this.params.hasVid){throw'Conference has no video';}
if(canvasID){this.modCommand("vid-layout",null,[layout,canvasID]);}else{this.modCommand("vid-layout",null,layout);}};$.verto.conf.prototype.kick=function(memberID){this.modCommand("kick",parseInt(memberID));};$.verto.conf.prototype.muteMic=function(memberID){this.modCommand("tmute",parseInt(memberID));};$.verto.conf.prototype.muteVideo=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("tvmute",parseInt(memberID));};$.verto.conf.prototype.presenter=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-res-id",parseInt(memberID),"presenter");};$.verto.conf.prototype.videoFloor=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-floor",parseInt(memberID),"force");};$.verto.conf.prototype.banner=function(memberID,text){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("vid-banner",parseInt(memberID),escape(text));};$.verto.conf.prototype.volumeDown=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("volume_in",parseInt(memberID),"down");};$.verto.conf.prototype.volumeUp=function(memberID){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("volume_in",parseInt(memberID),"up");};$.verto.conf.prototype.transfer=function(memberID,exten){if(!this.params.hasVid){throw'Conference has no video';}
this.modCommand("transfer",parseInt(memberID),exten);};$.verto.conf.prototype.sendChat=function(message,type){var conf=this;conf.verto.rpcClient.call("verto.broadcast",{"eventChannel":conf.params.laData.chatChannel,"data":{"action":"send","message":message,"type":type}});};}
this.modCommand("vid-banner",parseInt(memberID),escape(text));};$.verto.conf.prototype.volumeDown=function(memberID){this.modCommand("volume_out",parseInt(memberID),"down");};$.verto.conf.prototype.volumeUp=function(memberID){this.modCommand("volume_out",parseInt(memberID),"up");};$.verto.conf.prototype.gainDown=function(memberID){this.modCommand("volume_in",parseInt(memberID),"down");};$.verto.conf.prototype.gainUp=function(memberID){this.modCommand("volume_in",parseInt(memberID),"up");};$.verto.conf.prototype.transfer=function(memberID,exten){this.modCommand("transfer",parseInt(memberID),exten);};$.verto.conf.prototype.sendChat=function(message,type){var conf=this;conf.verto.rpcClient.call("verto.broadcast",{"eventChannel":conf.params.laData.chatChannel,"data":{"action":"send","message":message,"type":type}});};}
$.verto.modfuncs={};$.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++;confMan.canvasCount=confMan.params.laData.canvasCount;function genMainMod(jq){var play_id="play_"+confMan.serno;var stop_id="stop_"+confMan.serno;var recording_id="recording_"+confMan.serno;var snapshot_id="snapshot_"+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>"+
(confMan.params.hasVid?"<button class='ctlbtn' id='"+snapshot_id+"'>PNG Snapshot</button>":"")+"<br><br></div>";jq.html(html);$.verto.modfuncs.change_video_layout=function(id,canvas_id){var val=$("#"+id+" option:selected").text();if(val!=="none"){confMan.modCommand("vid-layout",null,[val,canvas_id]);}};if(confMan.params.hasVid){for(var j=0;j<confMan.canvasCount;j++){var vlayout_id="confman_vid_layout_"+j+"_"+confMan.serno;var vlselect_id="confman_vl_select_"+j+"_"+confMan.serno;var vlhtml="<div id='"+vlayout_id+"'><br>"+"<b>Video Layout Canvas "+(j+1)+"</b> <select onChange='$.verto.modfuncs.change_video_layout(\""+vlayout_id+"\", \""+j+"\")' id='"+vlselect_id+"'></select> "+"<br><br></div>";jq.append(vlhtml);}
(confMan.params.hasVid?"<button class='ctlbtn' id='"+snapshot_id+"'>PNG Snapshot</button>":"")+"<br><br></div>";jq.html(html);$.verto.modfuncs.change_video_layout=function(id,canvas_id){var val=$("#"+id+" option:selected").text();if(val!=="none"){confMan.modCommand("vid-layout",null,[val,canvas_id]);}};if(confMan.params.hasVid){for(var j=0;j<confMan.canvasCount;j++){var vlayout_id="confman_vid_layout_"+j+"_"+confMan.serno;var vlselect_id="confman_vl_select_"+j+"_"+confMan.serno;var vlhtml="<div id='"+vlayout_id+"'><br>"+"<b>Video Layout Canvas "+(j+1)+"</b> <select onChange='$.verto.modfuncs.change_video_layout(\""+vlayout_id+"\", \""+(j+1)+"\")' id='"+vlselect_id+"'></select> "+"<br><br></div>";jq.append(vlhtml);}
$("#"+snapshot_id).click(function(){var file=prompt("Please enter file name","");if(file){confMan.modCommand("vid-write-png",null,file);}});}
$("#"+play_id).click(function(){var file=prompt("Please enter file name","");if(file){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","");if(file){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 canvas_in_next_id="canvas_in_next_"+x;var canvas_in_prev_id="canvas_in_prev_"+x;var canvas_out_next_id="canvas_out_next_"+x;var canvas_out_prev_id="canvas_out_prev_"+x;var canvas_in_set_id="canvas_in_set_"+x;var canvas_out_set_id="canvas_out_set_"+x;var layer_set_id="layer_set_"+x;var layer_next_id="layer_next_"+x;var layer_prev_id="layer_prev_"+x;var tmute_id="tmute_"+x;var tvmute_id="tvmute_"+x;var vbanner_id="vbanner_"+x;var tvpresenter_id="tvpresenter_"+x;var tvfloor_id="tvfloor_"+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+"'>";html+="<b>General Controls</b><hr noshade>";html+="<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>";if(confMan.params.hasVid){html+="<br><br><b>Video Controls</b><hr noshade>";html+="<button class='ctlbtn' id='"+tvmute_id+"'>VMute</button>"+"<button class='ctlbtn' id='"+tvpresenter_id+"'>Presenter</button>"+"<button class='ctlbtn' id='"+tvfloor_id+"'>Vid Floor</button>"+"<button class='ctlbtn' id='"+vbanner_id+"'>Banner</button>";if(confMan.canvasCount>1){html+="<br><br><b>Canvas Controls</b><hr noshade>"+"<button class='ctlbtn' id='"+canvas_in_set_id+"'>Set Input Canvas</button>"+"<button class='ctlbtn' id='"+canvas_in_prev_id+"'>Prev Input Canvas</button>"+"<button class='ctlbtn' id='"+canvas_in_next_id+"'>Next Input Canvas</button>"+"<br>"+"<button class='ctlbtn' id='"+canvas_out_set_id+"'>Set Watching Canvas</button>"+"<button class='ctlbtn' id='"+canvas_out_prev_id+"'>Prev Watching Canvas</button>"+"<button class='ctlbtn' id='"+canvas_out_next_id+"'>Next Watching Canvas</button>";}
function genControls(jq,rowid){var x=parseInt(rowid);var kick_id="kick_"+x;var canvas_in_next_id="canvas_in_next_"+x;var canvas_in_prev_id="canvas_in_prev_"+x;var canvas_out_next_id="canvas_out_next_"+x;var canvas_out_prev_id="canvas_out_prev_"+x;var canvas_in_set_id="canvas_in_set_"+x;var canvas_out_set_id="canvas_out_set_"+x;var layer_set_id="layer_set_"+x;var layer_next_id="layer_next_"+x;var layer_prev_id="layer_prev_"+x;var tmute_id="tmute_"+x;var tvmute_id="tvmute_"+x;var vbanner_id="vbanner_"+x;var tvpresenter_id="tvpresenter_"+x;var tvfloor_id="tvfloor_"+x;var box_id="box_"+x;var gainup_id="gain_in_up"+x;var gaindn_id="gain_in_dn"+x;var volup_id="vol_in_up"+x;var voldn_id="vol_in_dn"+x;var transfer_id="transfer"+x;var html="<div id='"+box_id+"'>";html+="<b>General Controls</b><hr noshade>";html+="<button class='ctlbtn' id='"+kick_id+"'>Kick</button>"+"<button class='ctlbtn' id='"+tmute_id+"'>Mute</button>"+"<button class='ctlbtn' id='"+gainup_id+"'>Gain -</button>"+"<button class='ctlbtn' id='"+gaindn_id+"'>Gain +</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>";if(confMan.params.hasVid){html+="<br><br><b>Video Controls</b><hr noshade>";html+="<button class='ctlbtn' id='"+tvmute_id+"'>VMute</button>"+"<button class='ctlbtn' id='"+tvpresenter_id+"'>Presenter</button>"+"<button class='ctlbtn' id='"+tvfloor_id+"'>Vid Floor</button>"+"<button class='ctlbtn' id='"+vbanner_id+"'>Banner</button>";if(confMan.canvasCount>1){html+="<br><br><b>Canvas Controls</b><hr noshade>"+"<button class='ctlbtn' id='"+canvas_in_set_id+"'>Set Input Canvas</button>"+"<button class='ctlbtn' id='"+canvas_in_prev_id+"'>Prev Input Canvas</button>"+"<button class='ctlbtn' id='"+canvas_in_next_id+"'>Next Input Canvas</button>"+"<br>"+"<button class='ctlbtn' id='"+canvas_out_set_id+"'>Set Watching Canvas</button>"+"<button class='ctlbtn' id='"+canvas_out_prev_id+"'>Prev Watching Canvas</button>"+"<button class='ctlbtn' id='"+canvas_out_next_id+"'>Next Watching Canvas</button>";}
html+="<br>"+"<button class='ctlbtn' id='"+layer_set_id+"'>Set Layer</button>"+"<button class='ctlbtn' id='"+layer_prev_id+"'>Prev Layer</button>"+"<button class='ctlbtn' id='"+layer_next_id+"'>Next Layer</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");if(xten){confMan.modCommand("transfer",x,xten);}});$("#"+kick_id).click(function(){confMan.modCommand("kick",x);});$("#"+layer_set_id).click(function(){var cid=prompt("Please enter layer ID","");if(cid){confMan.modCommand("vid-layer",x,cid);}});$("#"+layer_next_id).click(function(){confMan.modCommand("vid-layer",x,"next");});$("#"+layer_prev_id).click(function(){confMan.modCommand("vid-layer",x,"prev");});$("#"+canvas_in_set_id).click(function(){var cid=prompt("Please enter canvas ID","");if(cid){confMan.modCommand("vid-canvas",x,cid);}});$("#"+canvas_out_set_id).click(function(){var cid=prompt("Please enter canvas ID","");if(cid){confMan.modCommand("vid-watching-canvas",x,cid);}});$("#"+canvas_in_next_id).click(function(){confMan.modCommand("vid-canvas",x,"next");});$("#"+canvas_in_prev_id).click(function(){confMan.modCommand("vid-canvas",x,"prev");});$("#"+canvas_out_next_id).click(function(){confMan.modCommand("vid-watching-canvas",x,"next");});$("#"+canvas_out_prev_id).click(function(){confMan.modCommand("vid-watching-canvas",x,"prev");});$("#"+tmute_id).click(function(){confMan.modCommand("tmute",x);});if(confMan.params.hasVid){$("#"+tvmute_id).click(function(){confMan.modCommand("tvmute",x);});$("#"+tvpresenter_id).click(function(){confMan.modCommand("vid-res-id",x,"presenter");});$("#"+tvfloor_id).click(function(){confMan.modCommand("vid-floor",x,"force");});$("#"+vbanner_id).click(function(){var text=prompt("Please enter text","");if(text){confMan.modCommand("vid-banner",x,escape(text));}});}
$("#"+volup_id).click(function(){confMan.modCommand("volume_in",x,"up");});$("#"+voldn_id).click(function(){confMan.modCommand("volume_in",x,"down");});return html;}
$("#"+gainup_id).click(function(){confMan.modCommand("volume_in",x,"up");});$("#"+gaindn_id).click(function(){confMan.modCommand("volume_in",x,"down");});$("#"+volup_id).click(function(){confMan.modCommand("volume_out",x,"up");});$("#"+voldn_id).click(function(){confMan.modCommand("volume_out",x,"down");});return html;}
var atitle="";var awidth=0;verto.subscribe(confMan.params.laData.chatChannel,{handler:function(v,e){if(typeof(confMan.params.chatCallback)==="function"){confMan.params.chatCallback(v,e);}}});if(confMan.params.laData.role==="moderator"){atitle="Action";awidth=600;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){if(confMan.params.onBroadcast){confMan.params.onBroadcast(verto,confMan,e.data);}
if(e.data["conf-command"]==="list-videoLayouts"){for(var j=0;j<confMan.canvasCount;j++){var vlselect_id="#confman_vl_select_"+j+"_"+confMan.serno;var vlayout_id="#confman_vid_layout_"+j+"_"+confMan.serno;var x=0;var options;$(vlselect_id).selectmenu({});$(vlselect_id).selectmenu("enable");$(vlselect_id).empty();$(vlselect_id).append(new Option("Choose a Layout","none"));if(e.data.responseData){options=e.data.responseData.sort();for(var i in options){$(vlselect_id).append(new Option(options[i],options[i]));x++;}}
if(e.data["conf-command"]==="list-videoLayouts"){for(var j=0;j<confMan.canvasCount;j++){var vlselect_id="#confman_vl_select_"+j+"_"+confMan.serno;var vlayout_id="#confman_vid_layout_"+j+"_"+confMan.serno;var x=0;var options;$(vlselect_id).selectmenu({});$(vlselect_id).selectmenu("enable");$(vlselect_id).empty();$(vlselect_id).append(new Option("Choose a Layout","none"));if(e.data.responseData){var rdata=[];for(var i in e.data.responseData){rdata.push(e.data.responseData[i].name);}
options=rdata.sort(function(a,b){var ga=a.substring(0,6)=="group:"?true:false;var gb=b.substring(0,6)=="group:"?true:false;if((ga||gb)&&ga!=gb){return ga?-1:1;}
return((a==b)?0:((a>b)?1:-1));});for(var i in options){$(vlselect_id).append(new Option(options[i],options[i]));x++;}}
if(x){$(vlselect_id).selectmenu('refresh',true);}else{$(vlayout_id).hide();}}}else{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);}}}});if(confMan.params.hasVid){confMan.modCommand("list-videoLayouts",null,null);}}
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","sWidth":"50"},{"sTitle":"Number","sWidth":"250"},{"sTitle":"Name","sWidth":"250"},{"sTitle":"Codec","sWidth":"100"},{"sTitle":"Status","sWidth":confMan.params.hasVid?"200px":"150px"},{"sTitle":atitle,"sWidth":awidth,}],"bAutoWidth":true,"bDestroy":true,"bSort":false,"bInfo":false,"bFilter":false,"bLengthChange":false,"bPaginate":false,"iDisplayLength":1400,"oLanguage":{"sEmptyTable":"The Conference is Empty....."},"fnRowCallback":row_callback});};$.verto.confMan.prototype.modCommand=function(cmd,id,value){var confMan=this;confMan.verto.rpcClient.call("verto.broadcast",{"eventChannel":confMan.params.laData.modChannel,"data":{"application":"conf-control","command":cmd,"id":id,"value":value}});};$.verto.confMan.prototype.sendChat=function(message,type){var confMan=this;confMan.verto.rpcClient.call("verto.broadcast",{"eventChannel":confMan.params.laData.chatChannel,"data":{"action":"send","message":message,"type":type}});};$.verto.confMan.prototype.destroy=function(){var confMan=this;confMan.destroyed=true;if(confMan.lt){confMan.lt.destroy();}
if(confMan.params.laData.chatChannel){confMan.verto.unsubscribe(confMan.params.laData.chatChannel);}
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,screenShare:false,useCamera:verto.options.deviceParams.useCamera,useMic:verto.options.deviceParams.useMic,useSpeak:verto.options.deviceParams.useSpeak,tag:verto.options.tag,localTag:verto.options.localTag,login:verto.options.login,videoParams:verto.options.videoParams},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;dialog.screenShare=params.screenShare||false;dialog.useCamera=dialog.params.useCamera;dialog.useMic=dialog.params.useMic;dialog.useSpeak=dialog.params.useSpeak;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;var tag=verto.options.tag;if(typeof(tag)==="function"){tag=tag();}
dialog.params=$.extend({useVideo:verto.options.useVideo,useStereo:verto.options.useStereo,screenShare:false,useCamera:verto.options.deviceParams.useCamera,useMic:verto.options.deviceParams.useMic,useSpeak:verto.options.deviceParams.useSpeak,tag:tag,localTag:verto.options.localTag,login:verto.options.login,videoParams:verto.options.videoParams},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;dialog.screenShare=params.screenShare||false;dialog.useCamera=dialog.params.useCamera;dialog.useMic=dialog.params.useMic;dialog.useSpeak=dialog.params.useSpeak;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;}}
if(dialog.params.localTag){dialog.localVideo=document.getElementById(dialog.params.localTag);}
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;}
@ -238,18 +254,24 @@ if(!dialog.params.remote_caller_id_name){dialog.params.remote_caller_id_name="No
if(!dialog.params.remote_caller_id_number){dialog.params.remote_caller_id_number="UNKNOWN";}
RTCcallbacks.onMessage=function(rtc,msg){console.debug(msg);};RTCcallbacks.onAnswerSDP=function(rtc,sdp){console.error("answer sdp",sdp);};}else{dialog.params.remote_caller_id_name="Outbound Call";dialog.params.remote_caller_id_number=dialog.params.destination_number;}
RTCcallbacks.onICESDP=function(rtc){console.log("RECV "+rtc.type+" SDP",rtc.mediaData.SDP);if(dialog.state==$.verto.enum.state.requesting||dialog.state==$.verto.enum.state.answering||dialog.state==$.verto.enum.state.active){location.reload();return;}
if(rtc.type=="offer"){if(dialog.state==$.verto.enum.state.active){dialog.setState($.verto.enum.state.requesting);dialog.sendMethod("verto.attach",{sdp:rtc.mediaData.SDP});}else{dialog.setState($.verto.enum.state.requesting);dialog.sendMethod("verto.invite",{sdp:rtc.mediaData.SDP});}}else{dialog.setState($.verto.enum.state.answering);dialog.sendMethod(dialog.attach?"verto.attach":"verto.answer",{sdp:dialog.rtc.mediaData.SDP});}};RTCcallbacks.onICE=function(rtc){if(rtc.type=="offer"){console.log("offer",rtc.mediaData.candidate);return;}};RTCcallbacks.onStream=function(rtc,stream){console.log("stream started");};RTCcallbacks.onError=function(e){console.error("ERROR:",e);dialog.hangup({cause:"Device or Permission Error"});};dialog.rtc=new $.FSRTC({callbacks:RTCcallbacks,localVideo:dialog.localVideo,useVideo:dialog.params.useVideo?dialog.videoStream:null,useAudio:dialog.audioStream,useStereo:dialog.params.useStereo,videoParams:dialog.params.videoParams,audioParams:verto.options.audioParams,iceServers:verto.options.iceServers,screenShare:dialog.screenShare,useCamera:dialog.useCamera,useMic:dialog.useMic,useSpeak:dialog.useSpeak});dialog.rtc.verto=dialog.verto;if(dialog.direction==$.verto.enum.direction.inbound){if(dialog.attach){dialog.answer();}else{dialog.ring();}}};$.verto.dialog.prototype.invite=function(){var dialog=this;dialog.rtc.call();};$.verto.dialog.prototype.sendMethod=function(method,obj){var dialog=this;obj.dialogParams={};for(var i in dialog.params){if(i=="sdp"&&method!="verto.invite"&&method!="verto.attach"){continue;}
if(rtc.type=="offer"){if(dialog.state==$.verto.enum.state.active){dialog.setState($.verto.enum.state.requesting);dialog.sendMethod("verto.attach",{sdp:rtc.mediaData.SDP});}else{dialog.setState($.verto.enum.state.requesting);dialog.sendMethod("verto.invite",{sdp:rtc.mediaData.SDP});}}else{dialog.setState($.verto.enum.state.answering);dialog.sendMethod(dialog.attach?"verto.attach":"verto.answer",{sdp:dialog.rtc.mediaData.SDP});}};RTCcallbacks.onICE=function(rtc){if(rtc.type=="offer"){console.log("offer",rtc.mediaData.candidate);return;}};RTCcallbacks.onStream=function(rtc,stream){console.log("stream started");};RTCcallbacks.onError=function(e){console.error("ERROR:",e);dialog.hangup({cause:"Device or Permission Error"});};dialog.rtc=new $.FSRTC({callbacks:RTCcallbacks,localVideo:dialog.screenShare?null:dialog.localVideo,useVideo:dialog.params.useVideo?dialog.videoStream:null,useAudio:dialog.audioStream,useStereo:dialog.params.useStereo,videoParams:dialog.params.videoParams,audioParams:verto.options.audioParams,iceServers:verto.options.iceServers,screenShare:dialog.screenShare,useCamera:dialog.useCamera,useMic:dialog.useMic,useSpeak:dialog.useSpeak});dialog.rtc.verto=dialog.verto;if(dialog.direction==$.verto.enum.direction.inbound){if(dialog.attach){dialog.answer();}else{dialog.ring();}}};$.verto.dialog.prototype.invite=function(){var dialog=this;dialog.rtc.call();};$.verto.dialog.prototype.sendMethod=function(method,obj){var dialog=this;obj.dialogParams={};for(var i in dialog.params){if(i=="sdp"&&method!="verto.invite"&&method!="verto.attach"){continue;}
obj.dialogParams[i]=dialog.params[i];}
dialog.verto.rpcClient.call(method,obj,function(e){dialog.processReply(method,true,e);},function(e){dialog.processReply(method,false,e);});};function checkStateChange(oldS,newS){if(newS==$.verto.enum.state.purge||$.verto.enum.states[oldS.name][newS.name]){return true;}
return false;}
function find_name(id){for(var i in $.verto.audioOutDevices){var source=$.verto.audioOutDevices[i];if(source.id===id){return(source.label);}}
return id;}
$.verto.dialog.prototype.setAudioPlaybackDevice=function(sinkId,callback,arg){var dialog=this;var element=dialog.audioStream;if(typeof element.sinkId!=='undefined'){var devname=find_name(sinkId);console.info("Dialog: "+dialog.callID+" Setting speaker:",element,devname);element.setSinkId(sinkId).then(function(){console.log("Dialog: "+dialog.callID+' Success, audio output device attached: '+sinkId);if(callback){callback(true,devname,arg);}}).catch(function(error){var errorMessage=error;if(error.name==='SecurityError'){errorMessage="Dialog: "+dialog.callID+' You need to use HTTPS for selecting audio output '+'device: '+error;}
if(callback){callback(false,null,arg);}
console.error(errorMessage);});}else{console.warn("Dialog: "+dialog.callID+' Browser does not support output device selection.');if(callback){callback(false,null,arg);}}}
$.verto.dialog.prototype.setState=function(state){var dialog=this;if(dialog.state==$.verto.enum.state.ringing){dialog.stopRinging();}
if(dialog.state==state||!checkStateChange(dialog.state,state)){console.error("Dialog "+dialog.callID+": INVALID state change from "+dialog.state.name+" to "+state.name);dialog.hangup();return false;}
console.log("Dialog "+dialog.callID+": state change from "+dialog.state.name+" to "+state.name);dialog.lastState=dialog.state;dialog.state=state;if(!dialog.causeCode){dialog.causeCode=16;}
if(!dialog.cause){dialog.cause="NORMAL CLEARING";}
if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
switch(dialog.state){case $.verto.enum.state.early:case $.verto.enum.state.active:var speaker=dialog.useSpeak;console.info("Using Speaker: ",speaker);if(speaker&&speaker!=="any"){var videoElement=dialog.audioStream;setTimeout(function(){console.info("Setting speaker:",videoElement,speaker);attachSinkId(videoElement,speaker);},500);}
switch(dialog.state){case $.verto.enum.state.early:case $.verto.enum.state.active:var speaker=dialog.useSpeak;console.info("Using Speaker: ",speaker);if(speaker&&speaker!=="any"&&speaker!=="none"){setTimeout(function(){dialog.setAudioPlaybackDevice(speaker);},500);}
break;case $.verto.enum.state.trying:setTimeout(function(){if(dialog.state==$.verto.enum.state.trying){dialog.setState($.verto.enum.state.hangup);}},30000);break;case $.verto.enum.state.purge:dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.hangup:if(dialog.lastState.val>$.verto.enum.state.requesting.val&&dialog.lastState.val<$.verto.enum.state.hangup.val){dialog.sendMethod("verto.bye",{});}
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:delete dialog.verto.dialogs[dialog.callID];if(!dialog.params.screenShare){dialog.rtc.stop();}
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:if(typeof(dialog.verto.options.tag)==="function"){$('#'+dialog.params.tag).remove();}
delete dialog.verto.dialogs[dialog.callID];if(dialog.params.screenShare){dialog.rtc.stopPeer();}else{dialog.rtc.stop();}
break;}
return true;};$.verto.dialog.prototype.processReply=function(method,success,e){var dialog=this;switch(method){case"verto.answer":case"verto.attach":if(success){dialog.setState($.verto.enum.state.active);}else{dialog.hangup();}
break;case"verto.invite":if(success){dialog.setState($.verto.enum.state.trying);}else{dialog.setState($.verto.enum.state.destroy);}
@ -258,7 +280,7 @@ if(success){}
break;default:break;}};$.verto.dialog.prototype.hangup=function(params){var dialog=this;if(params){if(params.causeCode){dialog.causeCode=params.causeCode;}
if(params.cause){dialog.cause=params.cause;}}
if(dialog.state.val>=$.verto.enum.state.new.val&&dialog.state.val<$.verto.enum.state.hangup.val){dialog.setState($.verto.enum.state.hangup);}else if(dialog.state.val<$.verto.enum.state.destroy){dialog.setState($.verto.enum.state.destroy);}};$.verto.dialog.prototype.stopRinging=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.stop();}};$.verto.dialog.prototype.indicateRing=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.attr("src",dialog.verto.options.ringFile)[0].play();setTimeout(function(){dialog.stopRinging();if(dialog.state==$.verto.enum.state.ringing){dialog.indicateRing();}},dialog.verto.options.ringSleep);}};$.verto.dialog.prototype.ring=function(){var dialog=this;dialog.setState($.verto.enum.state.ringing);dialog.indicateRing();};$.verto.dialog.prototype.useVideo=function(on){var dialog=this;dialog.params.useVideo=on;if(on){dialog.videoStream=dialog.audioStream;}else{dialog.videoStream=null;}
dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.prototype.setMute=function(what){var dialog=this;return dialog.rtc.setMute(what);};$.verto.dialog.prototype.getMute=function(){var dialog=this;return dialog.rtc.getMute();};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){dialog.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;}
dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.prototype.setMute=function(what){var dialog=this;return dialog.rtc.setMute(what);};$.verto.dialog.prototype.getMute=function(){var dialog=this;return dialog.rtc.getMute();};$.verto.dialog.prototype.setVideoMute=function(what){var dialog=this;return dialog.rtc.setVideoMute(what);};$.verto.dialog.prototype.getVideoMute=function(){var dialog=this;return dialog.rtc.getVideoMute();};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){dialog.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;dialog.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;}
if(!msg.body){console.error("Missing Body");err++;}
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){params={};}
@ -273,7 +295,8 @@ dialog.sendMessage($.verto.enum.message.display,{});};$.verto.dialog.prototype.h
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,hangup:1},requesting:{trying:1,hangup:1,active: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=[];$.verto.unloadJobs=[];$(window).bind('beforeunload',function(){for(var f in $.verto.unloadJobs){$.verto.unloadJobs[f]();}
for(var i in $.verto.saved){var verto=$.verto.saved[i];if(verto){verto.purge();verto.logout();}}
return $.verto.warnOnUnload;});$.verto.videoDevices=[];$.verto.audioInDevices=[];$.verto.audioOutDevices=[];var checkDevices=function(runtime){console.info("enumerating devices");var aud_in=[],aud_out=[],vid=[];if((!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices)&&MediaStreamTrack.getSources){MediaStreamTrack.getSources(function(media_sources){for(var i=0;i<media_sources.length;i++){if(media_sources[i].kind=='video'){vid.push(media_sources[i]);}else{aud_in.push(media_sources[i]);}}
$.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;console.info("Audio Devices",$.verto.audioInDevices);console.info("Video Devices",$.verto.videoDevices);runtime();});}else{if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){console.log("enumerateDevices() not supported.");return;}
navigator.mediaDevices.enumerateDevices().then(function(devices){devices.forEach(function(device){console.log(device);console.log(device.kind+": "+device.label+" id = "+device.deviceId);if(device.kind==="videoinput"){vid.push({id:device.deviceId,kind:"video",label:device.label});}else if(device.kind==="audioinput"){aud_in.push({id:device.deviceId,kind:"audio_in",label:device.label});}else if(device.kind==="audiooutput"){aud_out.push({id:device.deviceId,kind:"audio_out",label:device.label});}});$.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;$.verto.audioOutDevices=aud_out;console.info("Audio IN Devices",$.verto.audioInDevices);console.info("Audio Out Devices",$.verto.audioOutDevices);console.info("Video Devices",$.verto.videoDevices);runtime();}).catch(function(err){console.log(" Device Enumeration ERROR: "+err.name+": "+err.message);runtime();});}};$.verto.refreshDevices=function(runtime){checkDevices(runtime);}
$.verto.init=function(obj,runtime){$.FSRTC.checkPerms(function(){checkDevices(runtime);},true,true);}
$.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;console.info("Audio Devices",$.verto.audioInDevices);console.info("Video Devices",$.verto.videoDevices);runtime(true);});}else{if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){console.log("enumerateDevices() not supported.");return;}
navigator.mediaDevices.enumerateDevices().then(function(devices){devices.forEach(function(device){console.log(device);console.log(device.kind+": "+device.label+" id = "+device.deviceId);if(device.kind==="videoinput"){vid.push({id:device.deviceId,kind:"video",label:device.label});}else if(device.kind==="audioinput"){aud_in.push({id:device.deviceId,kind:"audio_in",label:device.label});}else if(device.kind==="audiooutput"){aud_out.push({id:device.deviceId,kind:"audio_out",label:device.label});}});$.verto.videoDevices=vid;$.verto.audioInDevices=aud_in;$.verto.audioOutDevices=aud_out;console.info("Audio IN Devices",$.verto.audioInDevices);console.info("Audio Out Devices",$.verto.audioOutDevices);console.info("Video Devices",$.verto.videoDevices);runtime(true);}).catch(function(err){console.log(" Device Enumeration ERROR: "+err.name+": "+err.message);runtime(false);});}};$.verto.refreshDevices=function(runtime){checkDevices(runtime);}
$.verto.init=function(obj,runtime){if(!obj){obj={};}
if(!obj.skipPermCheck&&!obj.skipDeviceCheck){$.FSRTC.checkPerms(function(status){checkDevices(runtime);},true,true);}else if(obj.skipPermCheck&&!obj.skipDeviceCheck){checkDevices(runtime);}else if(!obj.skipPermCheck&&obj.skipDeviceCheck){$.FSRTC.checkPerms(function(status){runtime(status);},true,true);}else{runtime(null);}}
$.verto.genUUID=function(){return generateGUID();}})(jQuery);

View File

@ -1,6 +1,6 @@
{
"name": "verto",
"version": "0.0.1",
"version": "0.0.2",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",

View File

@ -132,8 +132,13 @@
}
});
var tag = verto.options.tag;
if (typeof(tag) === "function") {
tag = tag();
}
if (verto.options.ringFile && verto.options.tag) {
verto.ringer = $("#" + verto.options.tag);
verto.ringer = $("#" + tag);
}
verto.rpcClient.call('login', {});
@ -1885,6 +1890,11 @@
$.verto.dialog = function(direction, verto, params) {
var dialog = this;
var tag = verto.options.tag;
if (typeof(tag) === "function") {
tag = tag();
}
dialog.params = $.extend({
useVideo: verto.options.useVideo,
useStereo: verto.options.useStereo,
@ -1892,7 +1902,7 @@
useCamera: verto.options.deviceParams.useCamera,
useMic: verto.options.deviceParams.useMic,
useSpeak: verto.options.deviceParams.useSpeak,
tag: verto.options.tag,
tag: tag,
localTag: verto.options.localTag,
login: verto.options.login,
videoParams: verto.options.videoParams
@ -2185,6 +2195,11 @@
dialog.setState($.verto.enum.state.destroy);
break;
case $.verto.enum.state.destroy:
if (typeof(dialog.verto.options.tag) === "function") {
$('#' + dialog.params.tag).remove();
}
delete dialog.verto.dialogs[dialog.callID];
if (dialog.params.screenShare) {
dialog.rtc.stopPeer();

View File

@ -45,7 +45,8 @@
"angular-bootstrap": "~0.14.3",
"bootstrap-material-design": "~0.3.0",
"angular-translate": "~2.10.0",
"angular-translate-loader-static-files": "~2.10.0"
"angular-translate-loader-static-files": "~2.10.0",
"angular-click-outside": "^2.8.3"
},
"resolutions": {
"angular": "~1.3.15",

View File

@ -99,6 +99,7 @@
<script src="bower_components/bootstrap-material-design/dist/js/ripples.js"></script>
<script src="bower_components/angular-translate/angular-translate.js"></script>
<script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script src="bower_components/angular-click-outside/clickoutside.directive.js"></script>
<!-- endbower -->
<!-- endbuild -->

View File

@ -149,5 +149,6 @@
"CHAT_GAIN_MINUS": "Gain -",
"CHAT_GAIN_PLUS": "Gain +",
"LANGUAGE": "Language:",
"BROWSER_LANGUAGE": "Browser Language"
"BROWSER_LANGUAGE": "Browser Language",
"FACTORY_RESET_SETTINGS": "Factory Reset Settings"
}

View File

@ -147,5 +147,6 @@
"CHAT_VOL_MINUS": "Vol -",
"CHAT_VOL_PLUS": "Vol +",
"CHAT_GAIN_MINUS": "Ganho -",
"CHAT_GAIN_PLUS": "Ganho +"
"CHAT_GAIN_PLUS": "Ganho +",
"FACTORY_RESET_SETTINGS": "Redefinir configurações"
}

View File

@ -1,4 +1,4 @@
<div id="settings" ng-controller="SettingsController">
<div id="settings" ng-controller="SettingsController" click-outside="$parent.closeSettings()">
<div class="content">
<div class="col-md-4">
@ -162,6 +162,7 @@
ng-options="item.id as item.label for item in verto.bandwidth"></select>
</div>
</div>
<button class="btn btn-danger pull-left btn-pull-left" ng-click="resetSettings()">{{ 'FACTORY_RESET_SETTINGS' | translate }}</button>
</div>
</div>
</div>

View File

@ -18,6 +18,7 @@
'ui.bootstrap',
'directive.g+signin',
'pascalprecht.translate',
'angular-click-outside',
]);
vertoApp.constant('configLanguages', {

View File

@ -290,6 +290,11 @@
$rootScope.$emit('toggledSettings', settingsEl.hasClass('toggled'));
};
$scope.closeSettings = function() {
var settingsEl = angular.element(document.querySelector('#settings'));
settingsEl.removeClass('toggled');
};
$scope.goFullscreen = function() {
if (storage.data.userStatus !== 'connected') {
return;

View File

@ -141,7 +141,8 @@ if(!verto.options.deviceParams.useMic){verto.options.deviceParams.useMic="any";}
if(!verto.options.deviceParams.useSpeak){verto.options.deviceParams.useSpeak="any";}
if(verto.options.sessid){verto.sessid=verto.options.sessid;}else{verto.sessid=localStorage.getItem("verto_session_uuid")||generateGUID();localStorage.setItem("verto_session_uuid",verto.sessid);}
verto.dialogs={};verto.callbacks=callbacks||{};verto.eventSUBS={};verto.rpcClient=new $.JsonRpcClient({login:verto.options.login,passwd:verto.options.passwd,socketUrl:verto.options.socketUrl,loginParams:verto.options.loginParams,userVariables:verto.options.userVariables,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.purge();}});var tag=verto.options.tag;if(typeof(tag)==="function"){tag=tag();}
if(verto.options.ringFile&&verto.options.tag){verto.ringer=$("#"+tag);}
verto.rpcClient.call('login',{});};$.verto.prototype.deviceParams=function(obj){var verto=this;for(var i in obj){verto.options.deviceParams[i]=obj[i];}
if(obj.useCamera){$.FSRTC.getValidRes(verto.options.deviceParams.useCamera,obj?obj.onResCheck:undefined);}};$.verto.prototype.videoParams=function(obj){var verto=this;for(var i in obj){verto.options.videoParams[i]=obj[i];}};$.verto.prototype.iceServers=function(obj){var verto=this;verto.options.iceServers=obj;};$.verto.prototype.loginData=function(params){var verto=this;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++;}
@ -244,7 +245,8 @@ var row_callback=null;if(confMan.params.laData.role==="moderator"){row_callback=
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","sWidth":"50"},{"sTitle":"Number","sWidth":"250"},{"sTitle":"Name","sWidth":"250"},{"sTitle":"Codec","sWidth":"100"},{"sTitle":"Status","sWidth":confMan.params.hasVid?"200px":"150px"},{"sTitle":atitle,"sWidth":awidth,}],"bAutoWidth":true,"bDestroy":true,"bSort":false,"bInfo":false,"bFilter":false,"bLengthChange":false,"bPaginate":false,"iDisplayLength":1400,"oLanguage":{"sEmptyTable":"The Conference is Empty....."},"fnRowCallback":row_callback});};$.verto.confMan.prototype.modCommand=function(cmd,id,value){var confMan=this;confMan.verto.rpcClient.call("verto.broadcast",{"eventChannel":confMan.params.laData.modChannel,"data":{"application":"conf-control","command":cmd,"id":id,"value":value}});};$.verto.confMan.prototype.sendChat=function(message,type){var confMan=this;confMan.verto.rpcClient.call("verto.broadcast",{"eventChannel":confMan.params.laData.chatChannel,"data":{"action":"send","message":message,"type":type}});};$.verto.confMan.prototype.destroy=function(){var confMan=this;confMan.destroyed=true;if(confMan.lt){confMan.lt.destroy();}
if(confMan.params.laData.chatChannel){confMan.verto.unsubscribe(confMan.params.laData.chatChannel);}
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,screenShare:false,useCamera:verto.options.deviceParams.useCamera,useMic:verto.options.deviceParams.useMic,useSpeak:verto.options.deviceParams.useSpeak,tag:verto.options.tag,localTag:verto.options.localTag,login:verto.options.login,videoParams:verto.options.videoParams},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;dialog.screenShare=params.screenShare||false;dialog.useCamera=dialog.params.useCamera;dialog.useMic=dialog.params.useMic;dialog.useSpeak=dialog.params.useSpeak;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;var tag=verto.options.tag;if(typeof(tag)==="function"){tag=tag();}
dialog.params=$.extend({useVideo:verto.options.useVideo,useStereo:verto.options.useStereo,screenShare:false,useCamera:verto.options.deviceParams.useCamera,useMic:verto.options.deviceParams.useMic,useSpeak:verto.options.deviceParams.useSpeak,tag:tag,localTag:verto.options.localTag,login:verto.options.login,videoParams:verto.options.videoParams},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;dialog.screenShare=params.screenShare||false;dialog.useCamera=dialog.params.useCamera;dialog.useMic=dialog.params.useMic;dialog.useSpeak=dialog.params.useSpeak;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;}}
if(dialog.params.localTag){dialog.localVideo=document.getElementById(dialog.params.localTag);}
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;}
@ -268,7 +270,8 @@ if(!dialog.cause){dialog.cause="NORMAL CLEARING";}
if(dialog.callbacks.onDialogState){dialog.callbacks.onDialogState(this);}
switch(dialog.state){case $.verto.enum.state.early:case $.verto.enum.state.active:var speaker=dialog.useSpeak;console.info("Using Speaker: ",speaker);if(speaker&&speaker!=="any"&&speaker!=="none"){setTimeout(function(){dialog.setAudioPlaybackDevice(speaker);},500);}
break;case $.verto.enum.state.trying:setTimeout(function(){if(dialog.state==$.verto.enum.state.trying){dialog.setState($.verto.enum.state.hangup);}},30000);break;case $.verto.enum.state.purge:dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.hangup:if(dialog.lastState.val>$.verto.enum.state.requesting.val&&dialog.lastState.val<$.verto.enum.state.hangup.val){dialog.sendMethod("verto.bye",{});}
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:delete dialog.verto.dialogs[dialog.callID];if(dialog.params.screenShare){dialog.rtc.stopPeer();}else{dialog.rtc.stop();}
dialog.setState($.verto.enum.state.destroy);break;case $.verto.enum.state.destroy:if(typeof(dialog.verto.options.tag)==="function"){$('#'+dialog.params.tag).remove();}
delete dialog.verto.dialogs[dialog.callID];if(dialog.params.screenShare){dialog.rtc.stopPeer();}else{dialog.rtc.stop();}
break;}
return true;};$.verto.dialog.prototype.processReply=function(method,success,e){var dialog=this;switch(method){case"verto.answer":case"verto.attach":if(success){dialog.setState($.verto.enum.state.active);}else{dialog.hangup();}
break;case"verto.invite":if(success){dialog.setState($.verto.enum.state.trying);}else{dialog.setState($.verto.enum.state.destroy);}

View File

@ -3403,7 +3403,7 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
//switch_core_strdup(pool, val);
const switch_codec_implementation_t *codec = NULL;
int num_codecs;
num_codecs = switch_loadable_module_get_codecs_sorted(&codec, 1, &val, 1);
num_codecs = switch_loadable_module_get_codecs_sorted(&codec, NULL, 1, &val, 1);
if (num_codecs != 1 || !codec) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Failed finding codec %s for unrestricted digital calls\n", val);

View File

@ -318,9 +318,19 @@ EOF
check_cflags() {
log check_cflags "$@"
case "$CC" in
*gcc*|*clang)
check_cc -Werror "$@" <<EOF
int x;
EOF
;;
*)
check_cc "$@" <<EOF
int x;
EOF
;;
esac
}
check_cxxflags() {

View File

@ -15,7 +15,8 @@ AM_CPPFLAGS = -I$(srcdir)/../bnf -I../bnf \
-I$(srcdir)/../http -I../http \
-I$(srcdir)/../url -I../url \
-I$(srcdir)/../sip -I../sip \
-I$(srcdir)/../su -I../su
-I$(srcdir)/../su -I../su \
-I$(srcdir)/include
# ----------------------------------------------------------------------
# Build targets

View File

@ -694,13 +694,13 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n,
/* SRC PORT */
hg->src_port.chunk.vendor_id = htons(0x0000);
hg->src_port.chunk.type_id = htons(0x0007);
hg->src_port.data = dst ? htons(su->su_port) : htons(su_self->su_port);
hg->src_port.data = dst ? su->su_port : su_self->su_port;
hg->src_port.chunk.length = htons(sizeof(hg->src_port));
/* DST PORT */
hg->dst_port.chunk.vendor_id = htons(0x0000);
hg->dst_port.chunk.type_id = htons(0x0008);
hg->dst_port.data = dst ? htons(su_self->su_port) : htons(su->su_port);
hg->dst_port.data = dst ? su_self->su_port : su->su_port;
hg->dst_port.chunk.length = htons(sizeof(hg->dst_port));

View File

@ -137,7 +137,6 @@ enum { tls_buffer_size = 16384 };
* Log the TLS error specified by the error code @a e and all the errors in
* the queue. The error code @a e implies no error, and it is not logged.
*/
static
void tls_log_errors(unsigned level, char const *s, unsigned long e)
{
if (e == 0)
@ -449,11 +448,21 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti)
void tls_free(tls_t *tls)
{
int ret;
if (!tls)
return;
if (tls->con != NULL) {
SSL_shutdown(tls->con);
do {
ret = SSL_shutdown(tls->con);
if (ret == -1) {
/* The return value -1 means that the connection wasn't actually established */
/* so it should be safe to not call shutdown again. We need to clear the eror */
/* queue for other connections though. */
tls_log_errors(3, "tls_free", 0);
ret = 1;
}
} while (ret != 1);
SSL_free(tls->con), tls->con = NULL;
}
@ -498,13 +507,18 @@ tls_t *tls_init_master(tls_issues_t *ti)
RAND_pseudo_bytes(sessionId, sizeof(sessionId));
SSL_CTX_set_session_id_context(tls->ctx,
if (!SSL_CTX_set_session_id_context(tls->ctx,
(void*) sessionId,
sizeof(sessionId));
sizeof(sessionId))) {
tls_log_errors(3, "tls_init_master", 0);
}
if (ti->CAfile != NULL)
if (ti->CAfile != NULL) {
SSL_CTX_set_client_CA_list(tls->ctx,
SSL_load_client_CA_file(ti->CAfile));
if (tls->ctx->client_CA == NULL)
tls_log_errors(3, "tls_init_master", 0);
}
#if 0
if (sock != -1) {
@ -576,6 +590,7 @@ int tls_post_connection_check(tport_t *self, tls_t *tls)
if (!tls) return -1;
if (!(cipher = SSL_get_current_cipher(tls->con))) {
tls_log_errors(3, "tls_post_connection_check", 0);
SU_DEBUG_7(("%s(%p): %s\n", __func__, (void*)self,
"OpenSSL failed to return an SSL_CIPHER object to us."));
return SSL_ERROR_SSL;

View File

@ -83,6 +83,7 @@ tls_t *tls_init_master(tls_issues_t *tls_issues);
tls_t *tls_init_secondary(tls_t *tls_master, int sock, int accept);
void tls_free(tls_t *tls);
int tls_get_socket(tls_t *tls);
void tls_log_errors(unsigned level, char const *s, unsigned long e);
ssize_t tls_read(tls_t *tls);
void *tls_read_buffer(tls_t *tls, size_t N);
int tls_want_read(tls_t *tls, int events);

View File

@ -385,22 +385,37 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri,
SSL_CTX_sess_set_remove_cb(wspri->ssl_ctx, NULL);
wspri->ws_secure = 1;
if ( !wspri->ssl_ctx ) goto done;
if (chain) {
SSL_CTX_use_certificate_chain_file(wspri->ssl_ctx, chain);
}
/* set the local certificate from CertFile */
SSL_CTX_use_certificate_file(wspri->ssl_ctx, cert, SSL_FILETYPE_PEM);
/* set the private key from KeyFile */
SSL_CTX_use_PrivateKey_file(wspri->ssl_ctx, key, SSL_FILETYPE_PEM);
/* verify private key */
if ( !SSL_CTX_check_private_key(wspri->ssl_ctx) ) {
if ( !wspri->ssl_ctx ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
goto done;
}
SSL_CTX_set_cipher_list(wspri->ssl_ctx, "!eNULL:!aNULL:!DSS:HIGH:@STRENGTH");
if (chain) {
if ( !SSL_CTX_use_certificate_chain_file(wspri->ssl_ctx, chain) ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
}
}
/* set the local certificate from CertFile */
if ( !SSL_CTX_use_certificate_file(wspri->ssl_ctx, cert, SSL_FILETYPE_PEM) ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
goto done;
}
/* set the private key from KeyFile */
if ( !SSL_CTX_use_PrivateKey_file(wspri->ssl_ctx, key, SSL_FILETYPE_PEM) ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
goto done;
}
/* verify private key */
if ( !SSL_CTX_check_private_key(wspri->ssl_ctx) ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
goto done;
}
if ( !SSL_CTX_set_cipher_list(wspri->ssl_ctx, "!eNULL:!aNULL:!DSS:HIGH:@STRENGTH") ) {
tls_log_errors(3, "tport_ws_init_primary_secure", 0);
goto done;
}
ret = tport_ws_init_primary(pri, tpn, ai, tags, return_culprit);

View File

@ -50,9 +50,12 @@ specification by other means.
#if !defined(_SPANDSP_G711_H_)
#define _SPANDSP_G711_H_
/*! The A-law alternate mark inversion mask */
#define G711_ALAW_AMI_MASK 0x55
/* The usual values to use on idle channels, to emulate silence */
/*! Idle value for A-law channels */
#define G711_ALAW_IDLE_OCTET 0x5D
#define G711_ALAW_IDLE_OCTET (0x80 ^ G711_ALAW_AMI_MASK)
/*! Idle value for u-law channels */
#define G711_ULAW_IDLE_OCTET 0xFF
@ -192,9 +195,6 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
* John Wiley & Sons, pps 98-111 and 472-476.
*/
/*! The A-law alternate mark inversion mask */
#define G711_ALAW_AMI_MASK 0x55
/*! \brief Encode a linear sample to A-law
\param linear The sample to encode.
\return The A-law value.

View File

@ -0,0 +1,136 @@
#!/usr/bin/perl
# analyze-debug-alloc.pl
# generate allocation report by processing log files
# Note that this script is only useful when run against freeswitch log files
# produced when server is running with DEBUG_ALLOC and DEBUG_ALLOC2 set.
# It's purely for diagnosing memory leaks.
use strict;
use JSON;
my $debug = 0;
my @logs = sort glob("freeswitch.log.*");
push( @logs, "freeswitch.log" );
my %pools = ();
foreach my $file (@logs) {
open( my $in, "<$file" );
while ( defined( my $line = <$in> ) ) {
if ( $line =~ /(0x[0-9A-Fa-f]+) DESTROY POOL$/o ) {
my $paddr = $1;
if ( !$pools{$paddr} ) {
$debug && print "WARN: No ref to pool $paddr.\n";
}
else {
foreach my $alloc ( @{ $pools{$paddr}->{allocs} } ) {
# debug, might not be needed
}
delete $pools{$paddr};
}
}
elsif ( $line =~ /(0x[0-9A-Fa-f]+) Free Pool/o ) {
my $paddr = $1;
if ( !$pools{$paddr} ) {
$debug && print "WARN: No ref to pool $paddr.\n";
}
else {
foreach my $alloc ( @{ $pools{$paddr}->{allocs} } ) {
# debug, might not be needed
}
delete $pools{$paddr};
}
}
elsif ( $line =~ /(0x[0-9A-Fa-f]+) New Pool (.*)$/o ) {
my $paddr = $1;
my $where = $2;
if ( $pools{$paddr} ) {
$debug && print "WARN: Duplicate pool $paddr at $where.\n";
}
$pools{$paddr}->{where} = $where;
if ( !$pools{$paddr}->{allocs} ) {
$pools{$paddr}->{allocs} = [];
}
}
elsif ( $line =~ /CONSOLE\] \s*(.*?:\d+) (0x[0-9A-Fa-f]+) Core Allocate (.*:\d+)\s+(\d+)$/o ) {
my $where = $1;
my $paddr = $2;
my $pwhere = $3;
my $size = $4;
if ( !$pools{$paddr} ) {
$debug && print "WARN: Missing pool ref for alloc of $size from $paddr at $where (pool $pwhere)\n";
}
$pools{$paddr}->{where} = $where;
push( @{ $pools{$paddr}->{allocs} }, { size => $size, where => $where } );
}
elsif ( $line =~ /CONSOLE\] \s*(.*?:\d+) (0x[0-9A-Fa-f]+) Core Strdup Allocate (.*:\d+)\s+(\d+)$/o ) {
my $where = $1;
my $paddr = $2;
my $pwhere = $3;
my $size = $4;
if ( !$pools{$paddr} ) {
$debug
&& print "WARN: Missing pool ref for strdup alloc of $size from $paddr at $where (pool $pwhere)\n";
}
$pools{$paddr}->{where} = $where;
push( @{ $pools{$paddr}->{allocs} }, { size => $size, where => $where } );
}
}
}
my $used = 0;
my $pcount = 0;
my $acount = 0;
my %pool_cnt_by_where = ();
my %alloc_size_by_where = ();
my %alloc_cnt_by_where = ();
foreach my $pool ( keys %pools ) {
my $where = $pools{$pool}->{where};
$pcount++;
$pool_cnt_by_where{$where}++;
foreach my $alloc ( @{ $pools{$pool}->{allocs} } ) {
my $sz = $alloc->{size};
my $where = $alloc->{where};
$acount++;
$alloc_size_by_where{$where} += $sz;
$alloc_cnt_by_where{$where}++;
$used += $sz;
}
}
print "Used: $used\n";
print "Pool Count: $pcount\n";
print "Alloc Count: $acount\n";
my $json = new JSON;
$json->pretty(1);
$json->canonical(1);
print "Pool Count by Where:\n";
foreach my $pool ( sort { $pool_cnt_by_where{$a} <=> $pool_cnt_by_where{$b} || $a cmp $b } keys %pool_cnt_by_where ) {
print $pool_cnt_by_where{$pool}, "\t", $pool, "\n";
}
print "\n";
print "Alloc Count by Where:\n";
foreach my $pool ( sort { $alloc_cnt_by_where{$a} <=> $alloc_cnt_by_where{$b} || $a cmp $b } keys %alloc_cnt_by_where )
{
print $alloc_cnt_by_where{$pool}, "\t", $pool, "\n";
}
print "\n";
print "Alloc Size by Where:\n";
foreach
my $pool ( sort { $alloc_size_by_where{$a} <=> $alloc_size_by_where{$b} || $a cmp $b } keys %alloc_size_by_where )
{
print $alloc_size_by_where{$pool}, "\t", $pool, "\n";
}
print "\n";

View File

@ -286,6 +286,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core
switch_media_type_t type,
const char *iananame,
uint32_t rate,
const char *fmtp_in,
switch_payload_t *ptP,
switch_payload_t *recv_ptP,
char **fmtpP);

View File

@ -117,7 +117,7 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin
*/
SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name, const char *modname);
SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname);
SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname, char **fmtp);
/*!
\brief Retrieve the dialplan interface by it's registered name
@ -272,7 +272,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
\return the number of elements added to the array
\note this function only considers codecs that are listed in the "prefs" array and ignores the rest.
*/
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen);
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, char fmtp_array[SWITCH_MAX_CODECS][MAX_FMTP_LEN], int arraylen, char **prefs, int preflen);
/*!
\brief Execute a registered API command

View File

@ -279,7 +279,7 @@ typedef intptr_t switch_ssize_t;
#endif
#if defined(__sun__) && defined(__x86_64)
#if defined(__sun__) && (defined(__x86_64) || defined(__arch64__))
#define SWITCH_TIME_T_FMT SWITCH_SIZE_T_FMT
#else
#define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT

View File

@ -234,6 +234,8 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_RTCP_AUDIO_INTERVAL_MSEC "5000"
#define SWITCH_RTCP_VIDEO_INTERVAL_MSEC "2000"
#define MAX_FMTP_LEN 256
/* Jitter */
#define JITTER_VARIANCE_THRESHOLD 400.0
/* IPDV */

View File

@ -1459,6 +1459,8 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo
if (context->video_st.st && (error = av_read_frame(context->fc, &pkt)) < 0) {
if (error == AVERROR_EOF) {
if (!context->has_video) break;
eof = 1;
/* just make sure*/
pkt.data = NULL;

View File

@ -5,8 +5,11 @@
#ifdef WIN32
#include <float.h>
#define ISNAN(x) (!!(_isnan(x)))
#define ISINF(x) (isinf(x))
#else
#define ISNAN(x) (isnan(x))
int __isnan(double);
#define ISNAN(x) (__isnan(x))
#define ISINF(x) (__isinf(x))
#endif
#include "avmd_buffer.h"
#include "avmd_desa2.h"

View File

@ -5,8 +5,11 @@
#ifdef WIN32
#include <float.h>
#define ISNAN(x) (!!(_isnan(x)))
#define ISINF(x) (isinf(x))
#else
#define ISNAN(x) (isnan(x))
int __isnan(double);
#define ISNAN(x) (__isnan(x))
#define ISINF(x) (__isinf(x))
#endif
#include "avmd_buffer.h"
#include "avmd_desa2_tweaked.h"
@ -48,7 +51,7 @@ avmd_desa2_tweaked(circ_buffer_t *b, size_t i)
we do simplified, modified for speed version : */
result = n/d;
if (isinf(result)) {
if (ISINF(result)) {
if (n < 0.0)
return -10.0;
else

View File

@ -14,40 +14,12 @@
#define __AVMD_OPTIONS_H__
/* define/undefine this to enable/disable printing of avmd
* intermediate computations to log */
/*#define AVMD_DEBUG*/
/* define/undef this to enable/disable reporting of beep
* detection status after session ended */
#define AVMD_REPORT_STATUS
/* define/undefine this to enable/disable faster computation
* of arcus cosine - table will be created mapping floats
* to integers and returning arc cos values given these integer
* indices into table */
/* #define AVMD_FAST_MATH */
/* define/undefine this to classify avmd beep detection as valid
* only when there is required number of consecutive elements
* in the SMA buffer without reset */
#define AVMD_REQUIRE_CONTINUOUS_STREAK
/* define number of samples to skip starting from the beginning
* of the frame and after reset */
#define AVMD_SAMLPE_TO_SKIP_N 6
/* define/undefine this to enable/disable simplified estimation
* of frequency based on approximation of sin(x) with (x)
* in the range x=[0,PI/2] */
#define AVMD_SIMPLIFIED_ESTIMATION
/* define/undefine to enable/disable avmd on internal channel */
/*#define AVMD_INBOUND_CHANNEL*/
/* define/undefine to enable/disable avmd on external channel */
#define AVMD_OUTBOUND_CHANNEL
#endif /* __AVMD_OPTIONS_H__ */

View File

@ -38,7 +38,7 @@
<!-- define number of samples to skip starting from the beginning
of the frame and after reset -->
<param name="sample_n_to_skeep" value="6"/>
<param name="sample_n_to_skip" value="6"/>
<!-- define/undefine this to enable/disable simplified estimation
of frequency based on approximation of sin(x) with (x)

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load);
*/
SWITCH_MODULE_DEFINITION(mod_callcenter, mod_callcenter_load, mod_callcenter_shutdown, NULL);
static switch_status_t load_agent(const char *agent_name, switch_event_t *params);
static switch_status_t load_tiers(switch_bool_t load_all, const char *queue_name, const char *agent_name, switch_event_t *params);
static const char *global_cf = "callcenter.conf";
struct cc_status_table {
@ -415,6 +417,8 @@ static struct {
char *odbc_dsn;
char *dbname;
switch_bool_t reserve_agents;
switch_bool_t truncate_tiers;
switch_bool_t truncate_agents;
int32_t threads;
int32_t running;
switch_mutex_t *mutex;
@ -674,10 +678,10 @@ end:
return ret;
}
static cc_queue_t *load_queue(const char *queue_name)
static cc_queue_t *load_queue(const char *queue_name, switch_bool_t request_agents, switch_bool_t request_tiers)
{
cc_queue_t *queue = NULL;
switch_xml_t x_queues, x_queue, cfg, xml;
switch_xml_t x_queues, x_queue, cfg, xml, x_agents, x_agent;
switch_event_t *event = NULL;
switch_event_t *params = NULL;
@ -735,6 +739,20 @@ static cc_queue_t *load_queue(const char *queue_name)
}
/* Importing from XML config Agents */
if (queue && request_agents && (x_agents = switch_xml_child(cfg, "agents"))) {
for (x_agent = switch_xml_child(x_agents, "agent"); x_agent; x_agent = x_agent->next) {
const char *agent = switch_xml_attr(x_agent, "name");
if (agent) {
load_agent(agent, params);
}
}
}
/* Importing from XML config Agent Tiers */
if (queue && request_tiers) {
load_tiers(SWITCH_TRUE, NULL, NULL, params);
}
end:
if (xml) {
@ -755,7 +773,7 @@ static cc_queue_t *get_queue(const char *queue_name)
switch_mutex_lock(globals.mutex);
if (!(queue = switch_core_hash_find(globals.queue_hash, queue_name))) {
queue = load_queue(queue_name);
queue = load_queue(queue_name, SWITCH_FALSE, SWITCH_FALSE);
}
if (queue) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "[%s] rwlock\n", queue->name);
@ -1255,11 +1273,10 @@ cc_status_t cc_tier_del(const char *queue_name, const char *agent)
return result;
}
static switch_status_t load_agent(const char *agent_name)
static switch_status_t load_agent(const char *agent_name, switch_event_t *params)
{
switch_xml_t x_agents, x_agent, cfg, xml;
if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) {
if (!(xml = switch_xml_open_cfg(global_cf, &cfg, params))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf);
return SWITCH_STATUS_FALSE;
}
@ -1348,12 +1365,12 @@ static switch_status_t load_tier(const char *queue, const char *agent, const cha
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t load_tiers(switch_bool_t load_all, const char *queue_name, const char *agent_name)
static switch_status_t load_tiers(switch_bool_t load_all, const char *queue_name, const char *agent_name, switch_event_t *params)
{
switch_xml_t x_tiers, x_tier, cfg, xml;
switch_status_t result = SWITCH_STATUS_FALSE;
if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) {
if (!(xml = switch_xml_open_cfg(global_cf, &cfg, params))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf);
return SWITCH_STATUS_FALSE;
}
@ -1413,8 +1430,12 @@ static switch_status_t load_config(void)
globals.dbname = strdup(val);
} else if (!strcasecmp(var, "odbc-dsn")) {
globals.odbc_dsn = strdup(val);
} else if(!strcasecmp(var, "reserve-agents")) {
} else if (!strcasecmp(var, "reserve-agents")) {
globals.reserve_agents = switch_true(val);
} else if (!strcasecmp(var, "truncate-tiers-on-load")) {
globals.truncate_tiers = switch_true(val);
} else if (!strcasecmp(var, "truncate-agents-on-load")) {
globals.truncate_agents = switch_true(val);
}
}
}
@ -1450,10 +1471,24 @@ static switch_status_t load_config(void)
cc_execute_sql(NULL, sql, NULL);
switch_safe_free(sql);
/* Truncating tiers if needed */
if (globals.truncate_tiers) {
sql = switch_mprintf("delete from tiers;");
cc_execute_sql(NULL, sql, NULL);
switch_safe_free(sql);
}
/* Truncating agents if needed */
if (globals.truncate_agents) {
sql = switch_mprintf("delete from agents;");
cc_execute_sql(NULL, sql, NULL);
switch_safe_free(sql);
}
/* Loading queue into memory struct */
if ((x_queues = switch_xml_child(cfg, "queues"))) {
for (x_queue = switch_xml_child(x_queues, "queue"); x_queue; x_queue = x_queue->next) {
load_queue(switch_xml_attr_soft(x_queue, "name"));
load_queue(switch_xml_attr_soft(x_queue, "name"), SWITCH_FALSE, SWITCH_FALSE);
}
}
@ -1462,13 +1497,13 @@ static switch_status_t load_config(void)
for (x_agent = switch_xml_child(x_agents, "agent"); x_agent; x_agent = x_agent->next) {
const char *agent = switch_xml_attr(x_agent, "name");
if (agent) {
load_agent(agent);
load_agent(agent, NULL);
}
}
}
/* Importing from XML config Agent Tiers */
load_tiers(SWITCH_TRUE, NULL, NULL);
load_tiers(SWITCH_TRUE, NULL, NULL, NULL);
end:
switch_mutex_unlock(globals.mutex);
@ -3158,7 +3193,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
goto done;
} else {
const char *agent = argv[0 + initial_argc];
switch (load_agent(agent)) {
switch (load_agent(agent, NULL)) {
case SWITCH_STATUS_SUCCESS:
stream->write_function(stream, "%s", "+OK\n");
break;
@ -3351,7 +3386,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
if (!strcasecmp(queue, "all")) {
load_all = SWITCH_TRUE;
}
switch (load_tiers(load_all, queue, agent)) {
switch (load_tiers(load_all, queue, agent, NULL)) {
case SWITCH_STATUS_SUCCESS:
stream->write_function(stream, "%s", "+OK\n");
break;
@ -3379,8 +3414,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
} else {
const char *queue_name = argv[0 + initial_argc];
cc_queue_t *queue = NULL;
if ((queue = get_queue(queue_name))) {
queue_rwunlock(queue);
if ((queue = load_queue(queue_name, SWITCH_TRUE, SWITCH_TRUE))) {
stream->write_function(stream, "%s", "+OK\n");
} else {
stream->write_function(stream, "%s", "-ERR Invalid Queue not found!\n");
@ -3406,8 +3440,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
const char *queue_name = argv[0 + initial_argc];
cc_queue_t *queue = NULL;
destroy_queue(queue_name);
if ((queue = get_queue(queue_name))) {
queue_rwunlock(queue);
if ((queue = load_queue(queue_name, SWITCH_TRUE, SWITCH_TRUE))) {
stream->write_function(stream, "%s", "+OK\n");
} else {
stream->write_function(stream, "%s", "-ERR Invalid Queue not found!\n");

View File

@ -5443,12 +5443,12 @@ SWITCH_STANDARD_API(show_function)
}
if (strchr(argv[2], '%')) {
sprintf(sql,
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' or presence_data like '%s' order by created_epoch",
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2]);
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' or presence_data like '%s' or accountcode like '%s' order by created_epoch",
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2], argv[2]);
} else {
sprintf(sql,
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' or presence_data like '%%%s%%' order by created_epoch",
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2]);
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' or presence_data like '%%%s%%' or accountcode like '%%%s%%' order by created_epoch",
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2], argv[2]);
}
if (argv[4] && !strcasecmp(argv[3], "as")) {
as = argv[4];

View File

@ -1079,10 +1079,6 @@ switch_status_t conference_api_sub_vid_personal(conference_obj_t *conference, sw
if (argv[2]) {
on = switch_true(argv[2]);
if (on) {
if (conference->record_count > 0) {
stream->write_function(stream, "-ERR conference is recording, not enabling vid-personal.\n");
return SWITCH_STATUS_SUCCESS;
}
conference_utils_set_flag(conference, CFLAG_PERSONAL_CANVAS);
} else {
conference_utils_clear_flag(conference, CFLAG_PERSONAL_CANVAS);
@ -2515,11 +2511,6 @@ switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_s
return SWITCH_STATUS_SUCCESS;
}
if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) {
stream->write_function(stream, "-ERR Personal Canvas enabled, recording not permitted.\n");
return SWITCH_STATUS_SUCCESS;
}
if (argv[3]) {
if (argv[3]) {
@ -2635,6 +2626,7 @@ switch_status_t conference_api_sub_recording(conference_obj_t *conference, switc
if (strcasecmp(argv[2], "start") == 0) {
argv[1] = argv[2];
argv[2] = argv[3];
argv[3] = argv[4];
return conference_api_sub_record(conference,stream,4,argv);
} else if (strcasecmp(argv[2], "stop") == 0) {
argv[1] = argv[2];

View File

@ -240,7 +240,7 @@ switch_status_t conference_file_play(conference_obj_t *conference, char *file, u
flags = SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT;
if (conference->members_with_video && conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
if (conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
flags |= SWITCH_FILE_FLAG_VIDEO;
}

View File

@ -65,11 +65,6 @@ void conference_record_launch_thread(conference_obj_t *conference, char *path, i
return;
}
if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Personal Canvas enabled, recording not permitted.\n");
return;
}
rec->conference = conference;
rec->path = switch_core_strdup(pool, path);
rec->pool = pool;
@ -235,9 +230,10 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
if (conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
flags |= SWITCH_FILE_FLAG_VIDEO;
if (canvas) {
char *orig_path = rec->path;
flags |= SWITCH_FILE_FLAG_VIDEO;
if (canvas) {
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels,
conference->rate,
@ -245,6 +241,15 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
canvas->height,
conference->video_fps.fps,
orig_path);
} else {
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels,
conference->rate,
conference->canvas_width,
conference->canvas_height,
conference->video_fps.fps,
orig_path);
}
}
@ -390,6 +395,7 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
switch_mutex_unlock(conference->mutex);
switch_core_file_close(&member->rec->fh);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recording of %s Stopped\n", rec->path);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_event_add_data(conference, event);

View File

@ -166,7 +166,7 @@ void conference_utils_set_cflags(const char *flags, conference_flag_t *f)
if (flags) {
char *dup = strdup(flags);
char *p;
char *argv[10] = { 0 };
char *argv[25] = { 0 };
int i, argc = 0;
for (p = dup; p && *p; p++) {

View File

@ -330,9 +330,13 @@ void conference_video_reset_image(switch_image_t *img, switch_rgb_color_t *color
void conference_video_clear_layer(mcu_layer_t *layer)
{
if (layer->canvas && layer->canvas->img) {
switch_img_fill(layer->canvas->img, layer->x_pos, layer->y_pos, layer->screen_w, layer->screen_h, &layer->canvas->bgcolor);
}
layer->banner_patched = 0;
layer->refresh = 1;
}
void conference_video_reset_layer(mcu_layer_t *layer)
@ -641,8 +645,7 @@ void conference_video_detach_video_layer(conference_member_t *member)
switch_mutex_lock(canvas->mutex);
if (member->video_layer_id < 0) {
switch_mutex_unlock(canvas->mutex);
return;
goto end;
}
layer = &canvas->layers[member->video_layer_id];
@ -676,6 +679,8 @@ void conference_video_detach_video_layer(conference_member_t *member)
conference_video_set_canvas_bgimg(canvas, NULL);
}
end:
switch_mutex_unlock(canvas->mutex);
conference_video_release_canvas(&canvas);
@ -1459,7 +1464,7 @@ void conference_video_canvas_set_fnode_layer(mcu_canvas_t *canvas, conference_fi
fnode->layer_id = idx;
fnode->canvas_id = canvas->canvas_id;
if (layer->member_id > -1) {
if (layer->member_id > 0) {
conference_member_t *member;
if ((member = conference_member_get(canvas->conference, layer->member_id))) {
@ -1480,7 +1485,7 @@ void conference_video_launch_muxing_write_thread(conference_member_t *member)
switch_mutex_lock(conference_globals.hash_mutex);
if (!member->video_muxing_write_thread) {
switch_threadattr_create(&thd_attr, member->pool);
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
//switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&member->video_muxing_write_thread, thd_attr, conference_video_muxing_write_thread_run, member, member->pool);
}
@ -1493,7 +1498,7 @@ void conference_video_launch_muxing_thread(conference_obj_t *conference, mcu_can
switch_mutex_lock(conference_globals.hash_mutex);
if (!canvas->video_muxing_thread) {
switch_threadattr_create(&thd_attr, conference->pool);
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
//switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
conference_utils_set_flag(conference, CFLAG_VIDEO_MUXING);
switch_thread_create(&canvas->video_muxing_thread, thd_attr,
@ -1609,7 +1614,7 @@ void conference_video_check_recording(conference_obj_t *conference, mcu_canvas_t
continue;
}
if (canvas && imember->canvas_id != canvas->canvas_id) {
if (!conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) && canvas && imember->canvas_id != canvas->canvas_id) {
continue;
}
@ -2118,6 +2123,7 @@ static void personal_attach(mcu_layer_t *layer, conference_member_t *member)
conference_api_sub_position(member, NULL, layer->geometry.audio_position);
}
if (member->channel) {
var = NULL;
if (member->video_banner_text ||
(var = switch_channel_get_variable_dup(member->channel, "video_banner_text", SWITCH_FALSE, -1))) {
@ -2130,6 +2136,7 @@ static void personal_attach(mcu_layer_t *layer, conference_member_t *member)
conference_video_layer_set_logo(member, layer, var);
}
}
}
layer->member_id = member->id;
}
@ -2158,6 +2165,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
int layout_applied = 0;
int files_playing = 0;
int last_personal = conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) ? 1 : 0;
int last_video_count = 0;
canvas->video_timer_reset = 1;
canvas->video_layout_group = conference->video_layout_group;
@ -2225,11 +2233,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
if (video_count != canvas->video_count) {
if (video_count != canvas->video_count || video_count != last_video_count) {
count_changed = 1;
}
canvas->video_count = video_count;
canvas->video_count = last_video_count = video_count;
switch_mutex_unlock(conference->member_mutex);
switch_core_timer_next(&canvas->timer);
@ -2309,7 +2318,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
members_with_avatar = conference->members_with_avatar;
if (conference_utils_test_flag(conference, CFLAG_VIDEO_BRIDGE_FIRST_TWO)) {
if (conference->members_with_video < 3) {
if (conference->members_seeing_video < 3) {
switch_yield(20000);
continue;
}
@ -2567,8 +2576,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
for (imember = conference->members; imember; imember = imember->next) {
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
@ -2586,13 +2596,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
layout_applied++;
}
if (switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
if (imember->channel && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
send_keyframe = SWITCH_TRUE;
}
if (count_changed) {
int total = conference->members_with_video;
int total = last_video_count;
int kps;
switch_vid_params_t vid_params = { 0 };
@ -2600,7 +2610,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
total += conference->members_with_avatar;
}
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
if (total > 0 &&
(!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
total--;
}
@ -2616,7 +2629,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
}
if (!switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
conference_utils_test_flag(conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE)) {
switch_core_media_get_vid_params(imember->session, &vid_params);
kps = switch_calc_bitrate(vid_params.width, vid_params.height, conference->video_quality, (int)(imember->conference->video_fps.fps));
@ -2624,12 +2637,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
}
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
if (imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
conference_video_pop_next_image(imember, &imember->pcanvas_img);
}
if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
}
if (conference->new_personal_vlayout && layout_applied) {
conference->new_personal_vlayout = NULL;
@ -2666,9 +2681,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
int i = 0;
mcu_layer_t *floor_layer = NULL;
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
(switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) ||
(switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
(switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS))) {
continue;
}
@ -2757,7 +2773,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (layer) {
if (conference_utils_member_test_flag(omember, MFLAG_CAN_BE_SEEN)) {
layer->mute_patched = 0;
} else {
} else if (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS)) {
if (!layer->mute_patched) {
switch_image_t *tmp;
conference_video_scale_and_patch(layer, omember->video_mute_img ? omember->video_mute_img : omember->pcanvas_img, SWITCH_FALSE);
@ -2790,8 +2806,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
}
if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
}
if (files_playing && !file_count) {
switch_img_free(&file_imgs[0]);
@ -2802,21 +2820,26 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
for (imember = conference->members; imember; imember = imember->next) {
switch_frame_t *dupframe;
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
if (need_refresh) {
if (need_refresh && imember->session) {
switch_core_session_request_video_refresh(imember->session);
}
if (send_keyframe) {
if (send_keyframe && imember->session) {
switch_core_media_gen_key_frame(imember->session);
}
switch_set_flag(&write_frame, SFF_RAW_RTP);
write_frame.img = imember->canvas->img;
if (imember->rec) {
switch_core_file_write_video(&imember->rec->fh, &write_frame);
} else {
switch_set_flag(&write_frame, SFF_RAW_RTP);
write_frame.packet = packet;
write_frame.data = ((uint8_t *)packet) + 12;
write_frame.datalen = 0;
@ -2827,9 +2850,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_queue_push(imember->mux_out_queue, dupframe);
dupframe = NULL;
}
}
if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
}
switch_mutex_unlock(conference->member_mutex);
} else {
@ -3724,7 +3750,7 @@ switch_status_t conference_video_thread_callback(switch_core_session_t *session,
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_BRIDGE_FIRST_TWO)) {
if (member->conference->members_with_video < 3) {
if (member->conference->members_seeing_video < 3) {
conference_video_write_frame(member->conference, member, frame);
conference_video_check_recording(member->conference, NULL, frame);
switch_thread_rwlock_unlock(member->conference->rwlock);

View File

@ -233,7 +233,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
while (conference_globals.running && !conference_utils_test_flag(conference, CFLAG_DESTRUCT)) {
switch_size_t file_sample_len = samples;
switch_size_t file_data_len = samples * 2 * conference->channels;
int has_file_data = 0, members_with_video = 0, members_with_avatar = 0;
int has_file_data = 0, members_with_video = 0, members_with_avatar = 0, members_seeing_video = 0;
uint32_t conference_energy = 0;
int nomoh = 0;
conference_member_t *floor_holder;
@ -288,6 +288,13 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
members_with_video++;
}
if (switch_channel_ready(channel) &&
switch_channel_test_flag(channel, CF_VIDEO_READY) &&
imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN)) {
members_seeing_video++;
}
if (imember->avatar_png_img && !switch_channel_test_flag(channel, CF_VIDEO)) {
members_with_avatar++;
}
@ -310,6 +317,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
}
conference->members_with_video = members_with_video;
conference->members_seeing_video = members_seeing_video;
conference->members_with_avatar = members_with_avatar;
if (floor_holder != conference->floor_holder) {

View File

@ -568,6 +568,7 @@ typedef struct conference_obj {
conference_video_mode_t conference_video_mode;
int video_quality;
int members_with_video;
int members_seeing_video;
int members_with_avatar;
uint32_t auto_kps_debounce;
switch_codec_settings_t video_codec_settings;

View File

@ -189,6 +189,19 @@ SWITCH_LIMIT_INCR(hiredis_limit_incr)
count = atoll(response ? response : "");
if (!interval && count > max ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s is already at max value (%d)\n", limit_key , max);
switch_safe_free(hashkey);
switch_safe_free(response);
hashkey = switch_mprintf("decr %s", limit_key);
if ( (status = hiredis_profile_execute_sync(profile, hashkey, &response, session)) != SWITCH_STATUS_SUCCESS ) {
if ( status == SWITCH_STATUS_SOCKERR && profile->ignore_connect_fail ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "hiredis: profile[%s] connection error executing [%s] with limit already reached\n", realm, hashkey);
switch_goto_status(SWITCH_STATUS_SUCCESS, done); // increment has been succesful but decrement have failed
}
}
}
if ( !count || count > max ) {
switch_goto_status(SWITCH_STATUS_GENERR, done);
}

View File

@ -44,7 +44,7 @@
<!-- OSP work mode, direct or indirect -->
<param name="work-mode" value="direct"/>
<!-- OSP service type, voice or npquery -->
<!-- OSP service type, voice, npquery or cnamquery -->
<param name="service-type" value="voice"/>
<!-- Max number of destinations -->
<param name="max-destinations" value="12"/>

View File

@ -43,7 +43,7 @@ OSP provider parameter names ane values cab be:
- http-retry-limit: HTTP retry times. The default is 2.
- http-timeout: HTTP timeout. The default is 10000 in ms.
- work-mode: OSP module work mode (direct and indirect). The default is "direct".
- service-type: OSP service type (voice and npquery). The default is "voice".
- service-type: OSP service type (voice, npquery and cnamquery (this option has not been implemented)). The default is "voice".
- max-destinations: Max destinations OSP server will return. It is up to 12. The default is 12.
3 OSP Applications
@ -54,7 +54,7 @@ The OSP applications are called in dial plan like this:
*PROFILE* is an OSP service provider profile name configured in osp.conf.xml. If data attribute is not provided or its value is empty, profile name "default" is used.
3.1 OSPLookup Application
osplookup application does OSP authorization request and gets first supported destination for inbound calls. It exports a set channel variables for FreeSWITCH dial plan logic.
osplookup application does OSP authorization request and gets first supported destination for inbound calls. It exports a set of channel variables for FreeSWITCH dial plan logic.
osplookup application accepts two sets of channel variables that are used to pass additional inbound call information and outbound control parameters to OSP module. It also exports a set of channel variables for outbound channels and FreeSWITCH dial plan logic.
3.1.1 Inbound Call Information
@ -64,7 +64,9 @@ osplookup application accepts two sets of channel variables that are used to pas
3.1.2 Outbound Control Parameters
- osp_networkid_userparam: The URI user parameter name that is used to present destination network ID. For example, sip:callednumber;networkid=dnid@host.
- osp_networkid_uriparam: The URI parameter name that is used to present destination network ID. For example, sip:callednumber @host;networkid=dnid.
- osp_networkid_uriparam: The URI parameter name that is used to present destination network ID. For example, sip:callednumber@host;networkid=dnid.
- osp_outstring_userparam: The URI user parameter string. For example, sip:callednumber;outstring@host.
- osp_outstring_uriparam: The URI parameter string. For example, sip:callednumber@host;outstring.
- osp_user_phone: Flag to add "user=phone" URI parameter. The default is "disabled".
- osp_outbound_proxy: Outbound proxy IP address channel variable.
@ -79,7 +81,7 @@ osplookup application accepts two sets of channel variables that are used to pas
- osp_termiation_cause: Destination termination cause. It will be used by ospnext application and OSP module state handlers.
3.2 OSPNext Application
ospnext application gets next supported destination for inbound calls. It exports a set channel variables for FreeSWITCH dial plan logic.
ospnext application gets next supported destination for inbound calls. It exports a set of channel variables for FreeSWITCH dial plan logic.
ospnext application accepts a set of channel variables exported by osplookup application to pass OSP call transaction information to OSP module. It also exports a set of channel variables for outbound channels and FreeSWITCH dial plan logic.
3.2.1 Transaction Parameters
@ -157,7 +159,7 @@ OSP module state handler accepts a set of channel variables exported by osplooku
<!-- OSP work mode, direct or indirect -->
<param name="work-mode" value="direct"/>
<!-- OSP service type, voice or npquery -->
<!-- OSP service type, voice, npquery or cnamquery -->
<param name="service-type" value="voice"/>
<!-- Max number of destinations -->
<param name="max-destinations" value="12"/>
@ -176,15 +178,14 @@ OSP module state handler accepts a set of channel variables exported by osplooku
</extension>
<!--
Tag anything pass thru here as an outside_call so you can make sure not
to create any routing loops based on the conditions that it came from
the outside of the switch.
Tag anything pass thru here as an outside_call so you can make sure
not to create any routing loops based on the conditions that it came
from the outside of the switch.
-->
<extension name="outside_call" continue="true">
<condition>
<action application="set" data="outside_call=true"/>
<action application="export" data="RFC2822_DATE=${strftime(%a, %d %b %Y %T %z)}"/>
</condition>
</extension>
@ -206,27 +207,68 @@ OSP module state handler accepts a set of channel variables exported by osplooku
<!-- OSP lookup application logic -->
<context name="osp_lookup">
<extension name="lookup">
<!--
Inbound information parameters
-->
<extension name="prepare_inbound" continue="true">
<condition>
<!-- Inbound information parameters -->
<!-- Actual source device -->
<!-- Actual source device from P-Source-Device -->
<action application="set" data="osp_source_device=${sip_h_P-Source-Device}"/>
<!-- Source network ID -->
<!-- Actual source device from SDP connection -->
<!--
<condition field="${switch_r_sdp}" expression="c=IN IP4 (.*?)(/|\r)" break="never">
<action application="set" data="osp_source_device=$1"/>
</condition>
-->
<!-- Source network ID from P-Network-ID -->
<action application="set" data="osp_source_nid=${sip_h_P-Network-ID}"/>
<!-- Custom info -->
<action application="set" data="osp_custom_info_4=${sip_h_P-Custom-Info}"/>
<!-- Outbound control parameters -->
<!-- Source network ID from otg -->
<!--
<condition field="${sip_from_params};" expression="otg=(.*?);" break="never">
<action application="set" data="osp_source_nid=$1"/>
</condition>
-->
<!-- Custom info, index starting from 1 -->
<action application="set" data="osp_custom_info_1=${sip_h_P-Custom-Info}"/>
</condition>
</extension>
<!--
Outbound control parameters
-->
<extension name="prepare_outbound" continue="true">
<condition>
<!-- Destination network ID parameter name, "sip:callednumber;dnidname=dnidvalue@host" -->
<!-- <action application="set" data="osp_networkid_userparam=networkid"/> -->
<!-- Destination network ID parameter name, "sip:callednumber@host;dnidname=dnidvalue" -->
<action application="set" data="osp_networkid_uriparam=networkid"/>
<!-- Fixed outbound parameter string, "sip:callednumber;outboundstring@host" -->
<!-- <action application="set" data="osp_outstring_userparam=outboundstring"/> -->
<!-- Fixed outbound parameter string, "sip:callednumber@host;outboundstring" -->
<!-- <action application="set" data="osp_outstring_uriparam=transport=udp"/> -->
<!-- Append "user=phone" -->
<!-- <action application="set" data="osp_user_phone=enabled"/> -->
<!-- Outbound proxy -->
<!-- <action application="set" data="osp_outbound_proxy=${network_addr}"/> -->
</condition>
</extension>
<extension name="lookup">
<condition>
<!-- OSP lookup application with default OSP profile -->
<action application="osplookup" data="default"/>
<!-- Debug info -->
<!--
Debug info
-->
<!-- OSP profile name -->
<action application="log" data="DEBUG osp_profile_name = ${osp_profile_name}"/>
<!-- OSP transaction handle -->
@ -265,10 +307,18 @@ OSP module state handler accepts a set of channel variables exported by osplooku
<condition>
<!-- Bridge control parameters -->
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="hangup_after_bridge=false"/>
<action application="set" data="hangup_after_bridge=true"/>
<!-- Timeout for without media -->
<action application="set" data="progress_timeout=5"/>
<!-- Timeout after ringing -->
<action application="set" data="call_timeout=60"/>
<!-- To proxy media, comment out the following line -->
<action application="set" data="bypass_media=true"/>
<!-- Bridge call legs -->
<action application="bridge" data="${osp_auto_route}"/>
<!-- Debug info -->
<!--
Debug info
-->
<!-- Destination termination cause for failed call -->
<action application="log" data="DEBUG last_bridge_hangup_cause = ${last_bridge_hangup_cause}"/>
<!-- Jump out to run OSP Next -->
@ -283,7 +333,9 @@ OSP module state handler accepts a set of channel variables exported by osplooku
<condition>
<!-- OSP next application -->
<action application="ospnext"/>
<!-- Debug info -->
<!--
Debug info
-->
<!-- OSP next application status -->
<action application="log" data="DEBUG osp_next_status = ${osp_next_status}"/>
<!-- Count of current destination, starting from 1 -->

File diff suppressed because it is too large Load Diff

View File

@ -231,43 +231,24 @@ SWITCH_STANDARD_APP(translate_app_function)
char *mydata = NULL;
char *translated = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_memory_pool_t *pool = NULL;
switch_event_t *event = NULL;
switch_assert(session);
if (!(mydata = switch_core_session_strdup(session, data))) {
goto end;
if (zstr(data)) {
return;
}
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
char *areacode = switch_core_get_variable("default_areacode");
mydata = switch_core_session_strdup(session, data);
if (session) {
pool = switch_core_session_get_pool(session);
} else {
switch_core_new_memory_pool(&pool);
switch_event_create(&event, SWITCH_EVENT_MESSAGE);
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (zstr(areacode)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no default_areacode set, using default of 777\n");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "areacode", "777");
} else {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "areacode", areacode);
}
if (!argc) {
return;
}
translate_number(argv[0], argv[1], &translated, session, event, NULL);
translate_number(argv[0], argv[1], &translated, session, NULL, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Translated: %s\n", translated);
switch_channel_set_variable_var_check(channel, "translated", translated, SWITCH_FALSE);
}
end:
if (pool) {
switch_core_destroy_memory_pool(&pool);
}
return;
}
@ -279,7 +260,6 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
char *translated_cid_num = NULL;
char *translate_profile = NULL;
char *areacode = NULL;
switch_event_t *event = NULL;
if (!caller_profile) {
if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
@ -292,16 +272,20 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
caller_profile->caller_id_name, caller_profile->caller_id_number, caller_profile->destination_number);
if ((translate_profile = (char *) switch_channel_get_variable(channel, "translate_profile"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "using translate_profile variable [%s] for translate profile\n", translate_profile);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"using translate_profile variable [%s] for translate profile\n", translate_profile);
} else if ((translate_profile = (char *) switch_channel_get_variable(channel, "country"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "using country variable [%s] for translate profile\n", translate_profile);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"using country variable [%s] for translate profile\n", translate_profile);
} else if ((translate_profile = (char *) switch_channel_get_variable(channel, "default_country"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "using default_country variable [%s] for translate profile\n", translate_profile);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"using default_country variable [%s] for translate profile\n", translate_profile);
} else {
translate_profile = "US";
}
areacode = (char *) switch_channel_get_variable(channel, "areacode");
if (zstr(areacode)) {
areacode = (char *) switch_channel_get_variable(channel, "default_areacode");
if (!zstr(areacode)) {
@ -309,8 +293,8 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
}
}
translate_number((char *) caller_profile->destination_number, translate_profile, &translated_dest, session, event, NULL);
translate_number((char *) caller_profile->caller_id_number, translate_profile, &translated_cid_num, session, event, NULL);
translate_number((char *) caller_profile->destination_number, translate_profile, &translated_dest, session, NULL, NULL);
translate_number((char *) caller_profile->caller_id_number, translate_profile, &translated_cid_num, session, NULL, NULL);
/* maybe we should translate ani/aniii here too? */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO,
"Profile: [%s] Translated Destination: [%s] Translated CID: [%s]\n", translate_profile, translated_dest, translated_cid_num);
@ -338,8 +322,10 @@ SWITCH_STANDARD_API(translate_function)
int argc = 0;
if (zstr(cmd)) {
goto usage;
stream->write_function(stream, "USAGE: %s\n", TRANSLATE_SYNTAX);
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s\n", cmd);
mydata = strdup(cmd);
@ -365,18 +351,12 @@ SWITCH_STANDARD_API(translate_function)
}
free(mydata);
end:
if (!session) {
if (pool) {
switch_core_destroy_memory_pool(&pool);
}
}
return SWITCH_STATUS_SUCCESS;
usage:
stream->write_function(stream, "USAGE: %s\n", TRANSLATE_SYNTAX);
goto end;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_translate_shutdown)

View File

@ -28,7 +28,7 @@
* John Wehle (john@feith.com)
* Raymond Chandler <intralanman@gmail.com>
* Kristin King <kristin.king@quentustech.com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
*
* mod_voicemail.c -- Voicemail Module
*
@ -181,6 +181,7 @@ struct vm_profile {
switch_bool_t auto_playback_recordings;
switch_bool_t db_password_override;
switch_bool_t allow_empty_password_auth;
switch_bool_t send_full_vm_header;
switch_thread_rwlock_t *rwlock;
switch_memory_pool_t *pool;
uint32_t flags;
@ -689,6 +690,7 @@ vm_profile_t *profile_set_config(vm_profile_t *profile)
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "allow-empty-password-auth", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE,
&profile->allow_empty_password_auth, SWITCH_TRUE, NULL, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "auto-playback-recordings", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auto_playback_recordings, SWITCH_FALSE, NULL, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "send-full-vm-header", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->send_full_vm_header, SWITCH_FALSE, NULL, NULL, NULL);
switch_assert(i < VM_PROFILE_CONFIGITEM_COUNT);
@ -1935,11 +1937,13 @@ static void update_mwi(vm_profile_t *profile, const char *id, const char *domain
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", yn);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Update-Reason", update_reason);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", "%s@%s", id, domain_name);
/*
if (profile->send_full_vm_header) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", total_new_messages, total_saved_messages,
total_new_urgent_messages, total_saved_urgent_messages);
*/
} else {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d", total_new_messages, total_saved_messages);
}
switch_event_fire(&event);

View File

@ -1244,7 +1244,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)
codec_interface->implementations->codec_control = switch_opus_control;
settings.stereo = 1;
if (x < 2) {
dft_fmtp = gen_fmtp(&settings, pool);
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
116, /* the IANA code number */
@ -1264,7 +1264,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)
switch_opus_decode, /* function to decode encoded data into raw data */
switch_opus_destroy); /* deinitalize a codec handle using this implementation */
codec_interface->implementations->codec_control = switch_opus_control;
}
bytes *= 2;
samples *= 2;
mss *= 2;

View File

@ -945,7 +945,7 @@ static int get_codecs(struct private_object *tech_pvt)
}
if (codec_string) {
if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs,
if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, NULL,
SWITCH_MAX_CODECS, codec_order_p, codec_order_last)) <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
return 0;

View File

@ -142,7 +142,7 @@ static switch_status_t tech_init(loopback_private_t *tech_pvt, switch_core_sessi
if ((var = switch_channel_get_variable(channel, "loopback_initial_codec"))) {
char *dup = switch_core_session_strdup(session, var);
uint32_t bit, channels;
iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit, &channels, &codec_modname);
iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit, &channels, &codec_modname, NULL);
}
}

View File

@ -730,7 +730,7 @@ void FSConnection::SetCodecs()
{
char *codec_order[SWITCH_MAX_CODECS];
int codec_order_last = switch_separate_string((char *)codec_string.GetPointer(), ',', codec_order, SWITCH_MAX_CODECS);
numCodecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, codec_order_last);
numCodecs = switch_loadable_module_get_codecs_sorted(codecs, NULL, SWITCH_MAX_CODECS, codec_order, codec_order_last);
}
for (int i = 0; i < numCodecs; i++) {

View File

@ -94,6 +94,7 @@ static switch_status_t skinny_api_list_devices(const char *line, const char *cur
return status;
}
if (!(argc = switch_separate_string(myline, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) || argc < 4) {
switch_safe_free(myline);
return status;
}
@ -115,6 +116,8 @@ static switch_status_t skinny_api_list_devices(const char *line, const char *cur
status = SWITCH_STATUS_SUCCESS;
}
switch_safe_free(myline);
return status;
}

View File

@ -116,9 +116,6 @@ switch_status_t skinny_create_incoming_session(listener_t *listener, uint32_t *l
if (!button || !button->shortname[0]) {
skinny_log_l(listener, SWITCH_LOG_CRIT, "Line %d not found on device\n", *line_instance_p);
if ( button ) {
switch_safe_free(button);
}
goto error;
}
@ -202,17 +199,13 @@ error:
}
listener->profile->ib_failed_calls++;
if ( button ) {
switch_safe_free(button);
}
return SWITCH_STATUS_FALSE;
done:
*session = nsession;
listener->profile->ib_calls++;
if ( button ) {
switch_safe_free(button);
}
return SWITCH_STATUS_SUCCESS;
}
@ -1246,27 +1239,27 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
listener->soft_key_set_set = switch_core_strdup(profile->pool, value);
} else if (!strcasecmp(name, "ext-voicemail")) {
if (!listener->ext_voicemail || strcmp(value,listener->ext_voicemail)) {
listener->ext_voicemail = switch_core_strdup(profile->pool, value);
listener->ext_voicemail = switch_core_strdup(listener->pool, value);
}
} else if (!strcasecmp(name, "ext-redial")) {
if (!listener->ext_redial || strcmp(value,listener->ext_redial)) {
listener->ext_redial = switch_core_strdup(profile->pool, value);
listener->ext_redial = switch_core_strdup(listener->pool, value);
}
} else if (!strcasecmp(name, "ext-meetme")) {
if (!listener->ext_meetme || strcmp(value,listener->ext_meetme)) {
listener->ext_meetme = switch_core_strdup(profile->pool, value);
listener->ext_meetme = switch_core_strdup(listener->pool, value);
}
} else if (!strcasecmp(name, "ext-pickup")) {
if (!listener->ext_pickup || strcmp(value,listener->ext_pickup)) {
listener->ext_pickup = switch_core_strdup(profile->pool, value);
listener->ext_pickup = switch_core_strdup(listener->pool, value);
}
} else if (!strcasecmp(name, "ext-cfwdall")) {
if (!listener->ext_cfwdall || strcmp(value,listener->ext_cfwdall)) {
listener->ext_cfwdall = switch_core_strdup(profile->pool, value);
listener->ext_cfwdall = switch_core_strdup(listener->pool, value);
}
} else if (!strcasecmp(name, "ext-autodial")) {
if (!listener->ext_autodial || strcmp(value,listener->ext_autodial)) {
listener->ext_autodial = switch_core_strdup(profile->pool, value);
listener->ext_autodial = switch_core_strdup(listener->pool, value);
}
}
}
@ -1531,11 +1524,12 @@ switch_status_t skinny_handle_stimulus_message(listener_t *listener, skinny_mess
}
if ( !session ) {
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle speed dial stimulus message, couldn't create incoming session.\n");
switch_safe_free(button_speed_dial);
return SWITCH_STATUS_FALSE;
}
skinny_session_process_dest(session, listener, line_instance, button_speed_dial->line, '\0', 0);
switch_safe_free(button_speed_dial);
}
switch_safe_free(button_speed_dial);
break;
case SKINNY_BUTTON_HOLD:
session = skinny_profile_find_session(listener->profile, listener, &line_instance, call_id);

View File

@ -501,6 +501,8 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
if (!tech_pvt->got_bye) {
switch_channel_set_variable(channel, "sip_hangup_disposition", "send_cancel");
switch_channel_set_variable(channel, "sip_invite_failure_status", "487");
switch_channel_set_variable(channel, "sip_invite_failure_phrase", "CANCEL");
}
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
nua_cancel(tech_pvt->nh,
@ -644,6 +646,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
const char *val;
const char *b_sdp = NULL;
int is_proxy = 0;
int is_3pcc_proxy = 0;
int is_3pcc = 0;
char *sticky = NULL;
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
@ -660,7 +663,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY nomedia - sending ack\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY nomedia - sending ack, SDP:\n%s\n", tech_pvt->mparams.local_sdp_str);
nua_ack(tech_pvt->nh,
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
@ -683,9 +687,10 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
is_proxy = (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA));
is_3pcc = (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
is_3pcc_proxy = (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
is_3pcc = (!sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
if (b_sdp && is_proxy && !is_3pcc) {
if (b_sdp && is_proxy && !is_3pcc_proxy) {
switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
@ -696,19 +701,18 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
}
} else {
/* This if statement check and handles the 3pcc proxy mode */
if (is_3pcc) {
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
tech_pvt->mparams.local_sdp_str = NULL;
switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
} else if (is_3pcc_proxy) {
if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY))) {
switch_channel_set_flag(channel, CF_3PCC);
}
if (!is_proxy) {
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
tech_pvt->mparams.local_sdp_str = NULL;
switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
} else {
switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
@ -719,9 +723,11 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
}
}
if (is_3pcc || is_3pcc_proxy) {
/* Send the 200 OK */
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
if (sofia_use_soa(tech_pvt)) {
nua_respond(tech_pvt->nh, SIP_200_OK,
@ -747,10 +753,12 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
switch_safe_free(extra_headers);
}
if (is_3pcc_proxy) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
/* Unlock the session signal to allow the ack to make it in */
// Maybe we should timeout?
switch_mutex_unlock(tech_pvt->sofia_mutex);
@ -762,17 +770,16 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
/* Regain lock on sofia */
switch_mutex_lock(tech_pvt->sofia_mutex);
if(is_proxy) {
if (is_proxy) {
sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
sofia_clear_flag(tech_pvt, TFLAG_3PCC);
// This sends the message to the other leg that causes it to call the TFLAG_3PCC_INVITE code at the start of this function.
// Is there another message it would be better to hang this on though?
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
return SWITCH_STATUS_SUCCESS;
}
}
if ((is_proxy && !b_sdp) || sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) ||
switch_core_media_codec_chosen(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) != SWITCH_STATUS_SUCCESS) {
@ -1427,8 +1434,21 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
{
if (zstr(msg->string_arg)) { /* no sdp requires proxy of ack */
switch_core_session_t *other_session;
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
sofia_set_flag(other_tech_pvt, TFLAG_PASS_ACK);
}
switch_core_session_rwunlock(other_session);
}
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",
switch_channel_get_name(channel), msg->string_arg);
switch_channel_get_name(channel), switch_str_nil(msg->string_arg));
switch_core_media_set_local_sdp(session, msg->string_arg, SWITCH_TRUE);
if (zstr(tech_pvt->mparams.local_sdp_str)) {
@ -1835,6 +1855,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
} else if (ua && ((switch_stristr("aastra", ua) && !switch_stristr("Intelligate", ua)) ||
(switch_stristr("cisco/spa50", ua) || switch_stristr("cisco/spa525", ua)) ||
switch_stristr("cisco/spa30", ua) || switch_stristr("Grandstream GXP", ua) ||
switch_stristr("Yealink", ua) || switch_stristr("Mitel", ua) ||
switch_stristr("Panasonic", ua))) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <sip:%s@%s>", name, number, tech_pvt->profile->printable_sipip);
@ -2097,6 +2118,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_mutex_unlock(tech_pvt->sofia_mutex);
while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
switch_ivr_parse_all_events(session);
switch_cond_next();
}
@ -2208,13 +2230,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
const char *val = NULL;
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
const char *b_sdp = NULL;
int is_proxy = 0, is_3pcc = 0;
int is_proxy = 0, is_3pcc_proxy = 0;
int send_sip_code = 183;
const char * p_send_sip_msg = sip_183_Session_progress;
b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
is_proxy = (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA));
is_3pcc = (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
is_3pcc_proxy = (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC));
// send 180 instead of 183 if variable "early_use_180" is "true"
if (switch_true(switch_channel_get_variable(channel, "early_use_180"))) {
@ -2222,7 +2244,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
p_send_sip_msg = sip_180_Ringing;
}
if (b_sdp && is_proxy && !is_3pcc) {
if (b_sdp && is_proxy && !is_3pcc_proxy) {
switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
@ -2232,84 +2254,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
goto end_lock;
}
}
} else {
if (is_3pcc) {
switch_channel_set_flag(channel, CF_3PCC);
if(!is_proxy) {
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
tech_pvt->mparams.local_sdp_str = NULL;
switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
switch_core_session_set_ice(session);
switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL , 0, NULL, 0);
} else {
switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
switch_core_media_patch_sdp(tech_pvt->session);
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "failed to activate rtp\n");
status = SWITCH_STATUS_FALSE;
goto end_lock;
}
}
}
/* Send the 183 */
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
if (sofia_use_soa(tech_pvt)) {
nua_respond(tech_pvt->nh, send_sip_code, p_send_sip_msg,
TAG_IF(is_proxy, NUTAG_AUTOANSWER(0)),
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
SOATAG_REUSE_REJECTED(1),
SOATAG_RTP_SELECT(1),
SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
} else {
nua_respond(tech_pvt->nh, send_sip_code, p_send_sip_msg,
NUTAG_MEDIA_ENABLE(0),
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 183 SESSION PROGRESS, waiting for PRACK\n");
switch_safe_free(extra_headers);
}
/* Unlock the session signal to allow the ack to make it in */
// Maybe we should timeout?
switch_mutex_unlock(tech_pvt->sofia_mutex);
while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
switch_cond_next();
}
/* Regain lock on sofia */
switch_mutex_lock(tech_pvt->sofia_mutex);
if(is_proxy || !switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE)) {
sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
sofia_clear_flag(tech_pvt, TFLAG_3PCC);
// This sends the message to the other leg that causes it to call the TFLAG_3PCC_INVITE code at the start of this function.
// Is there another message it would be better to hang this on though?
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for PRACK\n");
status = SWITCH_STATUS_SUCCESS;
goto end_lock;
}
}
if (!sofia_test_flag(tech_pvt, TFLAG_ANS) && !sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {

View File

@ -344,6 +344,7 @@ typedef enum {
TFLAG_REINVITED,
TFLAG_PASS_ACK,
TFLAG_KEEPALIVE,
TFLAG_SKIP_EARLY,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
@ -738,6 +739,8 @@ struct sofia_profile {
char *tls_verify_in_subjects_str;
su_strlst_t *tls_verify_in_subjects;
uint32_t sip_force_expires;
uint32_t sip_force_expires_min;
uint32_t sip_force_expires_max;
uint32_t sip_expires_max_deviation;
uint32_t sip_expires_late_margin;
uint32_t sip_subscription_max_deviation;

View File

@ -1279,30 +1279,41 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
switch_safe_free(dup);
}
static void tech_send_ack(nua_handle_t *nh, private_object_t *tech_pvt)
static void tech_send_ack(nua_handle_t *nh, private_object_t *tech_pvt, const char *r_sdp)
{
const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
int soa = sofia_use_soa(tech_pvt);
if (sofia_test_pflag(tech_pvt->profile, PFLAG_TRACK_CALLS)) {
const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
nua_ack(nh,
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_IF((zstr(tech_pvt->user_via) && !zstr(invite_full_via)), SIPTAG_VIA_STR(invite_full_via)),
TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
TAG_IF(r_sdp && soa, SOATAG_USER_SDP_STR(r_sdp)),
TAG_IF(r_sdp && soa, SOATAG_REUSE_REJECTED(1)),
TAG_IF(r_sdp && soa, SOATAG_AUDIO_AUX("cn telephone-event")),
TAG_IF(r_sdp && !soa, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
TAG_IF(r_sdp && !soa, SIPTAG_PAYLOAD_STR(r_sdp)),
TAG_IF(r_sdp && !soa, NUTAG_MEDIA_ENABLE(0)),
TAG_END());
} else {
nua_ack(nh,
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_IF(r_sdp && soa, SOATAG_USER_SDP_STR(r_sdp)),
TAG_IF(r_sdp && soa, SOATAG_REUSE_REJECTED(1)),
TAG_IF(r_sdp && soa, SOATAG_AUDIO_AUX("cn telephone-event")),
TAG_IF(r_sdp && !soa, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
TAG_IF(r_sdp && !soa, SIPTAG_PAYLOAD_STR(r_sdp)),
TAG_IF(r_sdp && !soa, NUTAG_MEDIA_ENABLE(0)),
TAG_END());
}
@ -1531,6 +1542,8 @@ static void our_sofia_event_callback(nua_event_t event,
if (sip && channel) {
switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_cancel");
switch_channel_set_variable(channel, "sip_invite_failure_status", "487");
switch_channel_set_variable(channel, "sip_invite_failure_phrase", "CANCEL");
if (sip->sip_reason) {
char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
@ -1552,6 +1565,25 @@ static void our_sofia_event_callback(nua_event_t event,
case nua_i_ack:
{
if (channel && sip) {
const char *r_sdp = NULL;
if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK) && sip->sip_payload && sip->sip_payload->pl_data) {
r_sdp = sip->sip_payload->pl_data;
if (tech_pvt->mparams.last_sdp_str) {
tech_pvt->mparams.prev_sdp_str = tech_pvt->mparams.last_sdp_str;
}
tech_pvt->mparams.last_sdp_str = NULL;
if (!zstr(tech_pvt->mparams.prev_sdp_str) && strcmp(tech_pvt->mparams.prev_sdp_str, sip->sip_payload->pl_data)) {
switch_channel_set_variable(channel, "sip_reinvite_sdp", sip->sip_payload->pl_data);
tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data);
} else {
tech_pvt->mparams.last_sdp_str = tech_pvt->mparams.prev_sdp_str;
}
}
if (sip->sip_to && sip->sip_to->a_tag) {
switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
}
@ -1579,11 +1611,10 @@ static void our_sofia_event_callback(nua_event_t event,
sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
tech_send_ack(other_tech_pvt->nh, other_tech_pvt);
tech_send_ack(other_tech_pvt->nh, other_tech_pvt, r_sdp);
}
switch_core_session_rwunlock(other_session);
}
@ -2027,15 +2058,18 @@ void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
sofia_dispatch_event_t *de = *dep;
switch_memory_pool_t *pool;
//sofia_profile_t *profile = (*dep)->profile;
switch_thread_data_t *td;
switch_core_new_memory_pool(&pool);
*dep = NULL;
de->pool = pool;
td = switch_core_alloc(pool, sizeof(*td));
td->func = sofia_msg_thread_run_once;
td->obj = de;
switch_thread_pool_launch_thread(&td);
}
void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
@ -4255,6 +4289,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile->dtmf_duration = 100;
profile->rtp_digit_delay = 40;
profile->sip_force_expires = 0;
profile->sip_force_expires_min = 0;
profile->sip_force_expires_max = 0;
profile->sip_expires_max_deviation = 0;
profile->sip_expires_late_margin = 60;
profile->sip_subscription_max_deviation = 0;
@ -5509,6 +5545,20 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} else {
profile->sip_expires_late_margin = 60;
}
} else if (!strcasecmp(var, "sip-force-expires-min")) {
int32_t sip_force_expires_min = atoi(val);
if (sip_force_expires_min >= 0) {
profile->sip_force_expires_min = sip_force_expires_min;
} else {
profile->sip_force_expires_min = 0;
}
} else if (!strcasecmp(var, "sip-force-expires-max")) {
int32_t sip_force_expires_max = atoi(val);
if (sip_force_expires_max >= 0) {
profile->sip_force_expires_max = sip_force_expires_max;
} else {
profile->sip_force_expires_max = 0;
}
} else if (!strcasecmp(var, "sip-force-expires")) {
int32_t sip_force_expires = atoi(val);
if (sip_force_expires >= 0) {
@ -6039,7 +6089,6 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
tagi_t tags[])
{
char *call_info = NULL;
if (sip && session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *uuid;
@ -6052,6 +6101,21 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
switch_channel_clear_flag(channel, CF_REQ_MEDIA);
if (status < 200) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (sofia_test_flag(other_tech_pvt, TFLAG_3PCC)) {
sofia_set_flag_locked(tech_pvt, TFLAG_SKIP_EARLY);
}
switch_core_session_rwunlock(other_session);
}
if (sofia_test_flag(tech_pvt, TFLAG_SKIP_EARLY)) {
return;
}
}
if (status >= 900) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s status %d received.\n",
switch_channel_get_name(channel), status);
@ -6065,8 +6129,13 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
if (status >= 400) {
char status_str[5];
switch_snprintf(status_str, sizeof(status_str), "%d", status);
switch_channel_set_variable(channel, "sip_invite_failure_status", status_str);
switch_channel_set_variable(channel, "sip_invite_failure_phrase", phrase);
switch_channel_set_variable_partner(channel, "sip_invite_failure_status", status_str);
switch_channel_set_variable_partner(channel, "sip_invite_failure_phrase", phrase);
} else {
switch_channel_set_variable_partner(channel, "sip_invite_failure_status", NULL);
switch_channel_set_variable_partner(channel, "sip_invite_failure_phrase", NULL);
}
if (status >= 400 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
@ -6411,6 +6480,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
(switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && (has_t38 || status > 299)))) {
if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
const char *wait_for_ack = switch_channel_get_variable(channel, "sip_wait_for_aleg_ack");
sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) {
@ -6426,7 +6496,22 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
switch_core_media_proxy_remote_addr(session, NULL);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n%s\n", status, phrase, switch_str_nil(r_sdp));
if (switch_true(wait_for_ack)) {
switch_core_session_t *other_session;
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (!sofia_test_flag(tech_pvt, TFLAG_3PCC) && !sofia_test_flag(other_tech_pvt, TFLAG_3PCC)) {
sofia_set_flag(other_tech_pvt, TFLAG_PASS_ACK);
}
}
switch_core_session_rwunlock(other_session);
}
}
if (status == 491 && (switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) ||
switch_channel_test_flag(channel, CF_PROXY_MODE))) {
@ -6910,8 +6995,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (channel && (status == 180 || status == 183) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
const char *full_to = NULL;
const char *val;
if ((val = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(val)) {
const char *var;
if ((var = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(var) &&
!((var = switch_channel_get_variable(channel, "sip_auto_answer_suppress_notify")) && switch_true(var))) {
full_to = switch_str_nil(switch_channel_get_variable(channel, "sip_full_to"));
nua_notify(nh,
@ -6955,6 +7041,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
break;
case nua_callstate_proceeding:
if (sofia_test_flag(tech_pvt, TFLAG_SKIP_EARLY)) {
sofia_clear_flag_locked(tech_pvt, TFLAG_SKIP_EARLY);
goto done;
}
switch (status) {
case 180:
switch_channel_mark_ring_ready(channel);
@ -7058,9 +7149,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (!sofia_test_flag(tech_pvt, TFLAG_3PCC) && !sofia_test_flag(other_tech_pvt, TFLAG_3PCC)) {
sofia_set_flag(other_tech_pvt, TFLAG_PASS_ACK);
send_ack = 0;
}
}
switch_core_session_rwunlock(other_session);
}
}
@ -7172,7 +7266,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
if (send_ack) {
tech_send_ack(nh, tech_pvt);
tech_send_ack(nh, tech_pvt, NULL);
} else {
ss_state = nua_callstate_ready;
goto state_process;
@ -7395,10 +7489,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_mark_pre_answered(channel);
sofia_set_flag(tech_pvt, TFLAG_SDP);
if (sofia_test_flag(tech_pvt, TFLAG_3PCC) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my PRACK\n");
sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
}
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_RESPONSE);
if (match) {
@ -10439,14 +10529,21 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
}
} else {
if (!zstr(bridge_uuid)) {
if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
switch_true(switch_find_parameter(*(sip->sip_replaces->rp_params), "early-only", switch_core_session_get_pool(session)))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercept rejected\n", bridge_uuid);
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "hangup:CALL_REJECTED");
} else {
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
&& switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS) &&
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(b_channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
switch_event_fire(&event);
}
}
} else {
const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);

View File

@ -1683,6 +1683,18 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu
}
}
if ( (( exp_var = atoi(switch_event_get_header_nil(*v_event, "sip-force-expires-min")) )) ||
(( exp_var = profile->sip_force_expires_min )) ) {
if ( (exp_var > 0) && (exptime < exp_var) ) {
exptime = exp_var;
}
}
if ( (( exp_var = atoi(switch_event_get_header_nil(*v_event, "sip-force-expires-max")) )) ||
(( exp_var = profile->sip_force_expires_max )) ) {
if ( (exp_var > 0) && (exptime > exp_var) ) {
exptime = exp_var;
}
}
if ( (( exp_var = atoi(switch_event_get_header_nil(*v_event, "sip-force-expires")) )) ||
(( exp_var = profile->sip_force_expires )) ) {
if (exp_var > 0) {

View File

@ -515,7 +515,9 @@ SWITCH_STANDARD_APP(socket_function)
switch_ivr_parse_all_events(session);
if (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var))) {
if (switch_channel_get_state(channel) != CS_HIBERNATE &&
!switch_channel_test_flag(channel, CF_REDIRECT) && !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_RESET)
&& (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var)))) {
switch_channel_set_state(channel, CS_EXECUTE);
}
@ -2771,7 +2773,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
channel = switch_core_session_get_channel(listener->session);
}
if (channel && (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var)))) {
if (channel && switch_channel_get_state(channel) != CS_HIBERNATE &&
!switch_channel_test_flag(channel, CF_REDIRECT) && !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_RESET) &&
(switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var)))) {
switch_channel_set_state(channel, CS_RESET);
}

View File

@ -477,6 +477,9 @@ switch_hash_t *create_default_filter() {
switch_core_hash_insert(filter, "whistle_application_name", "1");
switch_core_hash_insert(filter, "whistle_application_response", "1");
switch_core_hash_insert(filter, "whistle_event_name", "1");
switch_core_hash_insert(filter, "kazoo_application_name", "1");
switch_core_hash_insert(filter, "kazoo_application_response", "1");
switch_core_hash_insert(filter, "kazoo_event_name", "1");
switch_core_hash_insert(filter, "sip_auto_answer_notify", "1");
switch_core_hash_insert(filter, "eavesdrop_group", "1");
switch_core_hash_insert(filter, "origination_caller_id_name", "1");
@ -489,6 +492,21 @@ switch_hash_t *create_default_filter() {
switch_core_hash_insert(filter, "effective_caller_id_number", "1");
switch_core_hash_insert(filter, "effective_callee_id_name", "1");
switch_core_hash_insert(filter, "effective_callee_id_number", "1");
switch_core_hash_insert(filter, "variable_destination_number", "1");
switch_core_hash_insert(filter, "variable_effective_callee_id_name", "1");
switch_core_hash_insert(filter, "variable_effective_callee_id_number", "1");
switch_core_hash_insert(filter, "variable_record_silence_hits", "1");
switch_core_hash_insert(filter, "variable_refer_uuid", "1");
switch_core_hash_insert(filter, "variable_sip_call_id", "1");
switch_core_hash_insert(filter, "variable_sip_h_Referred-By", "1");
switch_core_hash_insert(filter, "variable_sip_h_X-AUTH-PORT", "1");
switch_core_hash_insert(filter, "variable_sip_loopback_req_uri", "1");
switch_core_hash_insert(filter, "variable_sip_received_port", "1");
switch_core_hash_insert(filter, "variable_sip_refer_to", "1");
switch_core_hash_insert(filter, "variable_sip_req_host", "1");
switch_core_hash_insert(filter, "variable_sip_req_uri", "1");
switch_core_hash_insert(filter, "variable_transfer_source", "1");
switch_core_hash_insert(filter, "variable_uuid", "1");
/* Registration headers */
switch_core_hash_insert(filter, "call-id", "1");
@ -570,6 +588,7 @@ switch_hash_t *create_default_filter() {
switch_core_hash_insert(filter, "variable_fax_timezone", "1");
switch_core_hash_insert(filter, "variable_fax_doc_id", "1");
switch_core_hash_insert(filter, "variable_fax_doc_database", "1");
switch_core_hash_insert(filter, "variable_has_t38", "1");
/* Secure headers */
switch_core_hash_insert(filter, "variable_sdp_secure_savp_only", "1");

View File

@ -340,7 +340,8 @@ static int read_cookie_from_file(char *filename) {
static switch_status_t config(void) {
char *cf = "kazoo.conf";
switch_xml_t cfg, xml, child, param;
globals.send_all_headers = globals.send_all_private_headers = 0;
globals.send_all_headers = 0;
globals.send_all_private_headers = 1;
globals.connection_timeout = 500;
globals.receive_timeout = 200;
globals.receive_msg_preallocate = 2000;

View File

@ -61,8 +61,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_imagick_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_imagick_shutdown);
SWITCH_MODULE_DEFINITION(mod_imagick, mod_imagick_load, mod_imagick_shutdown, NULL);
typedef enum pdf_loading_state_s {
PLS_LOADING,
PLS_BREAK,
PLS_DONE
} pdf_loading_state_t;
struct pdf_file_context {
switch_memory_pool_t *pool;
switch_mutex_t *mutex;
switch_image_t *img;
int reads;
int sent;
@ -75,16 +82,64 @@ struct pdf_file_context {
Image *images;
ExceptionInfo *exception;
int autoplay;
const char *path;
int lazy;
char *lazy_cookie;
pdf_loading_state_t loading_state;
switch_time_t next_play_time;
};
typedef struct pdf_file_context pdf_file_context_t;
static void *SWITCH_THREAD_FUNC open_pdf_thread_run(switch_thread_t *thread, void *obj)
{
pdf_file_context_t *context = (pdf_file_context_t *)obj;
int pagenumber = context->lazy;
char path[1024];
while (context->loading_state == PLS_LOADING) {
Image *tmp_images;
switch_snprintf(path, sizeof(path), "%s[%d]", context->path, pagenumber);
switch_set_string(context->image_info->filename, path);
if ((tmp_images = ReadImages(context->image_info, context->exception))) {
pagenumber++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s page %d loaded\n", context->path, pagenumber);
AppendImageToList(&context->images, tmp_images);
context->pagecount = pagenumber;
} else {
switch_event_t *event = NULL;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "imagick::info") == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "loaded");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "filename", context->path);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "pagecount", "%d", context->pagecount);
if (context->lazy_cookie) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "cookie", context->lazy_cookie);
}
switch_event_fire(&event);
}
break;
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "read file: %s %s, pagecount: %d\n",
context->path, context->loading_state == PLS_BREAK ? "break" : "done", pagenumber);
switch_mutex_lock(context->mutex);
context->loading_state = PLS_DONE;
switch_mutex_unlock(context->mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read Images Thread Ended.\n");
return NULL;
}
static switch_status_t imagick_file_open(switch_file_handle_t *handle, const char *path)
{
pdf_file_context_t *context;
char *ext;
unsigned int flags = 0;
char range_path[1024];
if ((ext = strrchr((char *)path, '.')) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
@ -121,13 +176,15 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha
context->exception = AcquireExceptionInfo();
context->image_info = AcquireImageInfo();
switch_set_string(context->image_info->filename, path);
context->path = switch_core_strdup(handle->memory_pool, path);
if (handle->params) {
const char *max = switch_event_get_header(handle->params, "img_ms");
const char *autoplay = switch_event_get_header(handle->params, "autoplay");
const char *density = switch_event_get_header(handle->params, "density");
const char *quality = switch_event_get_header(handle->params, "quality");
const char *lazy = switch_event_get_header(handle->params, "lazy");
const char *lazy_cookie = switch_event_get_header(handle->params, "cookie");
int tmp;
if (max) {
@ -148,6 +205,28 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha
if (tmp > 0) context->image_info->quality = tmp;
}
if (lazy) {
int tmp = atoi(lazy);
if (tmp >= 0) {
context->lazy = tmp;
} else {
context->lazy = 1;
}
}
if (lazy_cookie) {
context->lazy_cookie = switch_core_strdup(handle->memory_pool, lazy_cookie);
}
}
if (context->lazy) {
switch_snprintf(range_path, sizeof(range_path), "%s[0-%d]", path, context->lazy - 1);
switch_set_string(context->image_info->filename, range_path);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "loading first %d page%s\n", context->lazy, context->lazy > 1 ? "s" : "");
} else {
switch_set_string(context->image_info->filename, path);
}
context->images = ReadImages(context->image_info, context->exception);
@ -175,7 +254,20 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha
handle->private_info = context;
context->pool = handle->memory_pool;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s], pagecount: %d\n", path, context->pagecount);
if (context->lazy) {
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, context->pool);
context->loading_state = PLS_LOADING;
switch_thread_create(&thread, thd_attr, open_pdf_thread_run, context, context->pool);
}
if (context->lazy) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File %s, read the first %d page(s)", path, context->lazy);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File %s", path);
}
return SWITCH_STATUS_SUCCESS;
}
@ -184,6 +276,18 @@ static switch_status_t imagick_file_close(switch_file_handle_t *handle)
{
pdf_file_context_t *context = (pdf_file_context_t *)handle->private_info;
if (context->lazy) {
switch_mutex_lock(context->mutex);
if (context->loading_state == PLS_LOADING) context->loading_state = PLS_BREAK;
switch_mutex_unlock(context->mutex);
while (context->loading_state != PLS_DONE) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "waiting for pdf loading thread done, loading_state: %d\n", context->loading_state);
switch_yield(1000000);
switch_cond_next();
}
}
switch_img_free(&context->img);
if (context->images) DestroyImageList(context->images);

View File

@ -2000,6 +2000,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_RTCP_VIDEO_INTERVAL_MSEC_get() {
}
SWIGEXPORT int SWIGSTDCALL CSharp_MAX_FMTP_LEN_get() {
int jresult ;
int result;
result = (int)(256);
jresult = result;
return jresult;
}
SWIGEXPORT double SWIGSTDCALL CSharp_JITTER_VARIANCE_THRESHOLD_get() {
double jresult ;
double result;
@ -17340,7 +17350,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_codec_interface(
}
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void * jarg2, void * jarg3, void * jarg4, void * jarg5, void * jarg6) {
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void * jarg2, void * jarg3, void * jarg4, void * jarg5, void * jarg6, void * jarg7) {
char * jresult ;
char *arg1 = (char *) 0 ;
uint32_t *arg2 = (uint32_t *) 0 ;
@ -17348,6 +17358,7 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void *
uint32_t *arg4 = (uint32_t *) 0 ;
uint32_t *arg5 = (uint32_t *) 0 ;
char **arg6 = (char **) 0 ;
char **arg7 = (char **) 0 ;
char *result = 0 ;
arg1 = (char *)jarg1;
@ -17356,7 +17367,8 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_parse_codec_buf(char * jarg1, void *
arg4 = (uint32_t *)jarg4;
arg5 = (uint32_t *)jarg5;
arg6 = (char **)jarg6;
result = (char *)switch_parse_codec_buf(arg1,arg2,arg3,arg4,arg5,arg6);
arg7 = (char **)jarg7;
result = (char *)switch_parse_codec_buf(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
@ -17612,19 +17624,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_get_codecs(void * jarg1
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_get_codecs_sorted(void * jarg1, int jarg2, void * jarg3, int jarg4) {
SWIGEXPORT int SWIGSTDCALL CSharp_switch_loadable_module_get_codecs_sorted(void * jarg1, void * jarg2, int jarg3, void * jarg4, int jarg5) {
int jresult ;
switch_codec_implementation_t **arg1 = (switch_codec_implementation_t **) 0 ;
int arg2 ;
char **arg3 = (char **) 0 ;
int arg4 ;
char (*arg2)[256] ;
int arg3 ;
char **arg4 = (char **) 0 ;
int arg5 ;
int result;
arg1 = (switch_codec_implementation_t **)jarg1;
arg2 = (int)jarg2;
arg3 = (char **)jarg3;
arg4 = (int)jarg4;
result = (int)switch_loadable_module_get_codecs_sorted((switch_codec_implementation const **)arg1,arg2,arg3,arg4);
arg2 = (char (*)[256])jarg2;
arg3 = (int)jarg3;
arg4 = (char **)jarg4;
arg5 = (int)jarg5;
result = (int)switch_loadable_module_get_codecs_sorted((switch_codec_implementation const **)arg1,(char (*)[256])arg2,arg3,arg4,arg5);
jresult = result;
return jresult;
}

View File

@ -3447,8 +3447,8 @@ else
return ret;
}
public static string switch_parse_codec_buf(string buf, SWIGTYPE_p_unsigned_long interval, SWIGTYPE_p_unsigned_long rate, SWIGTYPE_p_unsigned_long bit, SWIGTYPE_p_unsigned_long channels, ref string modname) {
string ret = freeswitchPINVOKE.switch_parse_codec_buf(buf, SWIGTYPE_p_unsigned_long.getCPtr(interval), SWIGTYPE_p_unsigned_long.getCPtr(rate), SWIGTYPE_p_unsigned_long.getCPtr(bit), SWIGTYPE_p_unsigned_long.getCPtr(channels), ref modname);
public static string switch_parse_codec_buf(string buf, SWIGTYPE_p_unsigned_long interval, SWIGTYPE_p_unsigned_long rate, SWIGTYPE_p_unsigned_long bit, SWIGTYPE_p_unsigned_long channels, ref string modname, ref string fmtp) {
string ret = freeswitchPINVOKE.switch_parse_codec_buf(buf, SWIGTYPE_p_unsigned_long.getCPtr(interval), SWIGTYPE_p_unsigned_long.getCPtr(rate), SWIGTYPE_p_unsigned_long.getCPtr(bit), SWIGTYPE_p_unsigned_long.getCPtr(channels), ref modname, ref fmtp);
return ret;
}
@ -3561,8 +3561,8 @@ else
return ret;
}
public static int switch_loadable_module_get_codecs_sorted(SWIGTYPE_p_p_switch_codec_implementation array, int arraylen, ref string prefs, int preflen) {
int ret = freeswitchPINVOKE.switch_loadable_module_get_codecs_sorted(SWIGTYPE_p_p_switch_codec_implementation.getCPtr(array), arraylen, ref prefs, preflen);
public static int switch_loadable_module_get_codecs_sorted(SWIGTYPE_p_p_switch_codec_implementation array, SWIGTYPE_p_a_256__char fmtp_array, int arraylen, ref string prefs, int preflen) {
int ret = freeswitchPINVOKE.switch_loadable_module_get_codecs_sorted(SWIGTYPE_p_p_switch_codec_implementation.getCPtr(array), SWIGTYPE_p_a_256__char.getCPtr(fmtp_array), arraylen, ref prefs, preflen);
return ret;
}
@ -7611,6 +7611,7 @@ else
public static readonly int SWITCH_DEFAULT_VIDEO_SIZE = freeswitchPINVOKE.SWITCH_DEFAULT_VIDEO_SIZE_get();
public static readonly string SWITCH_RTCP_AUDIO_INTERVAL_MSEC = freeswitchPINVOKE.SWITCH_RTCP_AUDIO_INTERVAL_MSEC_get();
public static readonly string SWITCH_RTCP_VIDEO_INTERVAL_MSEC = freeswitchPINVOKE.SWITCH_RTCP_VIDEO_INTERVAL_MSEC_get();
public static readonly int MAX_FMTP_LEN = freeswitchPINVOKE.MAX_FMTP_LEN_get();
public static readonly double JITTER_VARIANCE_THRESHOLD = freeswitchPINVOKE.JITTER_VARIANCE_THRESHOLD_get();
public static readonly double IPDV_THRESHOLD = freeswitchPINVOKE.IPDV_THRESHOLD_get();
public static readonly int LOST_BURST_ANALYZE = freeswitchPINVOKE.LOST_BURST_ANALYZE_get();
@ -8385,6 +8386,9 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTCP_VIDEO_INTERVAL_MSEC_get")]
public static extern string SWITCH_RTCP_VIDEO_INTERVAL_MSEC_get();
[DllImport("mod_managed", EntryPoint="CSharp_MAX_FMTP_LEN_get")]
public static extern int MAX_FMTP_LEN_get();
[DllImport("mod_managed", EntryPoint="CSharp_JITTER_VARIANCE_THRESHOLD_get")]
public static extern double JITTER_VARIANCE_THRESHOLD_get();
@ -12151,7 +12155,7 @@ class freeswitchPINVOKE {
public static extern IntPtr switch_loadable_module_get_codec_interface(string jarg1, string jarg2);
[DllImport("mod_managed", EntryPoint="CSharp_switch_parse_codec_buf")]
public static extern string switch_parse_codec_buf(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4, HandleRef jarg5, ref string jarg6);
public static extern string switch_parse_codec_buf(string jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4, HandleRef jarg5, ref string jarg6, ref string jarg7);
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_dialplan_interface")]
public static extern IntPtr switch_loadable_module_get_dialplan_interface(string jarg1);
@ -12211,7 +12215,7 @@ class freeswitchPINVOKE {
public static extern int switch_loadable_module_get_codecs(HandleRef jarg1, int jarg2);
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_codecs_sorted")]
public static extern int switch_loadable_module_get_codecs_sorted(HandleRef jarg1, int jarg2, ref string jarg3, int jarg4);
public static extern int switch_loadable_module_get_codecs_sorted(HandleRef jarg1, HandleRef jarg2, int jarg3, ref string jarg4, int jarg5);
[DllImport("mod_managed", EntryPoint="CSharp_switch_api_execute")]
public static extern int switch_api_execute(string jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4);
@ -20471,6 +20475,36 @@ namespace FreeSWITCH.Native {
using System;
using System.Runtime.InteropServices;
public class SWIGTYPE_p_a_256__char {
private HandleRef swigCPtr;
internal SWIGTYPE_p_a_256__char(IntPtr cPtr, bool futureUse) {
swigCPtr = new HandleRef(this, cPtr);
}
protected SWIGTYPE_p_a_256__char() {
swigCPtr = new HandleRef(null, IntPtr.Zero);
}
internal static HandleRef getCPtr(SWIGTYPE_p_a_256__char obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
}
}
}
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 2.0.12
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
namespace FreeSWITCH.Native {
using System;
using System.Runtime.InteropServices;
public class SWIGTYPE_p_a_2__icand_s {
private HandleRef swigCPtr;

View File

@ -352,7 +352,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, swit
int argc;
char *argv[128];
int x;
char *dup = strdup(xcmd);
char *dup = NULL;
char *cmd;
switch_status_t status = SWITCH_STATUS_FALSE;
@ -363,6 +363,10 @@ SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, swit
goto end;
}
while (*xcmd == ' ') xcmd++;
dup = strdup(xcmd);
if (!strncasecmp(xcmd, "alias", 5)) {
argc = 1;
argv[0] = xcmd;

View File

@ -93,6 +93,7 @@ static void send_heartbeat(void)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Count", "%u", switch_core_session_count());
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Max-Sessions", "%u", switch_core_session_limit(0));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec", "%u", runtime.sps);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec-Last", "%u", runtime.sps_last);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec-Max", "%u", runtime.sps_peak);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec-FiveMin", "%u", runtime.sps_peak_fivemin);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Since-Startup", "%" SWITCH_SIZE_T_FMT, switch_core_session_id() - 1);

View File

@ -189,7 +189,7 @@ struct switch_media_handle_s {
char *codec_order[SWITCH_MAX_CODECS];
int codec_order_last;
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
char fmtp[SWITCH_MAX_CODECS][MAX_FMTP_LEN];
int payload_space;
char *origin;
@ -669,6 +669,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core
switch_media_type_t type,
const char *iananame,
uint32_t rate,
const char *fmtp_in,
switch_payload_t *ptP,
switch_payload_t *recv_ptP,
char **fmtpP)
@ -690,10 +691,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core
switch_mutex_lock(smh->sdp_mutex);
for (pmap = engine->payload_map; pmap ; pmap = pmap->next) {
char *fmtp_a = pmap->rm_fmtp;
if (!pmap->allocated) continue;
if (!strcasecmp(pmap->iananame, iananame) && (!rate || (rate == pmap->rate))) {
if (!fmtp_a) fmtp_a = "";
if (!fmtp_in) fmtp_in = "";
if (!strcasecmp(pmap->iananame, iananame) && !strcasecmp(fmtp_a, fmtp_in) && (!rate || (rate == pmap->rate))) {
pt = pmap->pt;
recv_pt = pmap->recv_pt;
fmtp = pmap->rm_fmtp;
@ -1866,7 +1872,7 @@ SWITCH_DECLARE(void) switch_core_media_prepare_codecs(switch_core_session_t *ses
tmp_codec_string = switch_core_session_strdup(smh->session, codec_string);
switch_channel_set_variable(session->channel, "rtp_use_codec_string", codec_string);
smh->codec_order_last = switch_separate_string(tmp_codec_string, ',', smh->codec_order, SWITCH_MAX_CODECS);
smh->mparams->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
smh->mparams->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, smh->fmtp, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
}
@ -2704,11 +2710,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio
return SWITCH_STATUS_GENERR;
}
if (!engine->read_codec.implementation || !switch_core_codec_ready(&engine->read_codec)) {
return SWITCH_STATUS_FALSE;
}
if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
if (engine->read_impl.encoded_bytes_per_packet) {
bytes = engine->read_impl.encoded_bytes_per_packet;
@ -3347,10 +3348,14 @@ static switch_bool_t ip_possible(switch_media_handle_t *smh, const char *ip)
static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_session_t *sdp, sdp_media_t *m)
{
switch_rtp_engine_t *engine = &smh->engines[type];
sdp_attribute_t *attr;
sdp_attribute_t *attr = NULL, *attrs[2] = { 0 };
int i = 0, got_rtcp_mux = 0;
const char *val;
int ice_seen = 0, cid = 0, ai = 0;
int ice_seen = 0, cid = 0, ai = 0, attr_idx = 0, cand_seen = 0;
if (switch_true(switch_channel_get_variable_dup(smh->session->channel, "ignore_sdp_ice", SWITCH_FALSE, -1))) {
return SWITCH_STATUS_BREAK;
}
//if (engine->ice_in.is_chosen[0] && engine->ice_in.is_chosen[1]) {
//return SWITCH_STATUS_SUCCESS;
@ -3365,12 +3370,14 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
engine->remote_ssrc = 0;
if (m) {
attr = m->m_attributes;
attrs[0] = m->m_attributes;
attrs[1] = sdp->sdp_attributes;
} else {
attr = sdp->sdp_attributes;
attrs[0] = sdp->sdp_attributes;
}
for (; attr; attr = attr->a_next) {
for (attr_idx = 0; attr_idx < 2 && !(ice_seen && cand_seen); attr_idx++) {
for (attr = attrs[attr_idx]; attr; attr = attr->a_next) {
char *data;
char *fields[15];
int argc = 0, j = 0;
@ -3515,9 +3522,11 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
j += 2;
}
cand_seen++;
engine->ice_in.cand_idx[cid]++;
}
}
}
if (!ice_seen) {
return SWITCH_STATUS_SUCCESS;
@ -3795,6 +3804,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
const char *tmp;
int m_idx = 0;
int nm_idx = 0;
int vmatch_pt = 0;
switch_assert(session);
@ -4438,6 +4448,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
const switch_codec_implementation_t *search[1];
char *prefs[1];
char tmp[80];
char fmtp[SWITCH_MAX_CODECS][MAX_FMTP_LEN];
int num;
const switch_codec_implementation_t *timp = NULL;
@ -4449,7 +4460,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
codec_ms, near_match->number_of_channels);
prefs[0] = tmp;
num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
num = switch_loadable_module_get_codecs_sorted(search, fmtp, 1, prefs, 1);
if (num) {
timp = search[0];
@ -4658,7 +4669,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
if (best_te) {
smh->mparams->te_rate = best_te_rate;
if (smh->mparams->dtmf_type == DTMF_AUTO) {
if (smh->mparams->dtmf_type == DTMF_AUTO || smh->mparams->dtmf_type == DTMF_2833 ||
switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF)) {
if (sdp_type == SDP_TYPE_REQUEST) {
smh->mparams->te = smh->mparams->recv_te = (switch_payload_t) best_te;
switch_channel_set_variable(session->channel, "dtmf_type", "rfc2833");
@ -4754,6 +4766,11 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
}
}
if (switch_true(switch_channel_get_variable_dup(session->channel, "inherit_codec", SWITCH_FALSE, -1))) {
vmatch_pt = 1;
}
compare:
for (map = m->m_rtpmaps; map; map = map->rm_next) {
@ -4832,7 +4849,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
continue;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d]/[%s:%d]\n",
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CONSOLE, "Video Codec Compare [%s:%d]/[%s:%d]\n",
rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
vmatch = (map->rm_pt == imp->ianacode) ? 1 : 0;
@ -4840,12 +4857,24 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
}
if (vmatch && (map->rm_rate == imp->samples_per_second)) {
if (vmatch && vmatch_pt) {
const char *other_pt = switch_channel_get_variable_partner(channel, "rtp_video_pt");
if (other_pt) {
int opt = atoi(other_pt);
if (map->rm_pt != opt) {
vmatch = 0;
}
}
}
if (vmatch) {
matches[m_idx].imp = imp;
matches[m_idx].map = map;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d] +++ is saved as a match\n",
imp->iananame, imp->ianacode);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CONSOLE, "Video Codec Compare [%s:%d] +++ is saved as a match\n",
imp->iananame, map->rm_pt);
m_idx++;
}
@ -4853,6 +4882,11 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
}
}
if (vmatch_pt && !m_idx) {
vmatch_pt = 0;
goto compare;
}
if (smh->crypto_mode == CRYPTO_MODE_MANDATORY && got_video_crypto < 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Crypto not negotiated but required.\n");
vmatch = 0;
@ -4917,8 +4951,6 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
#endif
}
switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->cur_payload_map->remote_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, v_engine->cur_payload_map->remote_sdp_ip);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
@ -6218,11 +6250,11 @@ static void gen_ice(switch_core_session_t *session, switch_media_type_t type, co
engine = &smh->engines[type];
#ifdef RTCP_MUX
if (!engine->rtcp_mux) {// && type == SWITCH_MEDIA_TYPE_AUDIO) {
engine->rtcp_mux = SWITCH_TRUE;
}
#endif
//#ifdef RTCP_MUX
//if (!engine->rtcp_mux) {// && type == SWITCH_MEDIA_TYPE_AUDIO) {
// engine->rtcp_mux = SWITCH_TRUE;
//}
//#endif
if (!smh->msid) {
switch_stun_random_string(tmp, 32, NULL);
@ -6671,7 +6703,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
if (!strcasecmp(val, "passthru")) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating RTCP PASSTHRU PORT %d\n", remote_rtcp_port);
switch_rtp_activate_rtcp(a_engine->rtp_session, -1, remote_rtcp_port, a_engine->rtcp_mux > 0);
} else if (remote_rtcp_port) {
} else {
int interval = atoi(val);
if (interval < 100 || interval > 500000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
@ -7345,6 +7377,7 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
fmtp = smh->fmtps[i];
}
if (smh->ianacodes[i] > 95 || switch_channel_test_flag(session->channel, CF_VERBOSE_SDP)) {
int channels = get_channels(imp->iananame, imp->number_of_channels);
@ -7682,7 +7715,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
if (switch_true(switch_channel_get_variable(session->channel, "rtcp_mux"))) {
if (sdp_type == SDP_TYPE_REQUEST || switch_true(switch_channel_get_variable(session->channel, "rtcp_mux"))) {
a_engine->rtcp_mux = 1;
v_engine->rtcp_mux = 1;
}
@ -7791,8 +7824,6 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
switch_payload_t orig_pt = 0;
char *orig_fmtp = NULL;
//smh->ianacodes[i] = imp->ianacode;
if (smh->ianacodes[i] > 64) {
if (smh->mparams->dtmf_type == DTMF_2833 && smh->mparams->te > 95 && smh->mparams->te == smh->payload_space) {
smh->payload_space++;
@ -7805,7 +7836,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
if (orig_session &&
switch_core_session_get_payload_code(orig_session,
imp->codec_type == SWITCH_CODEC_TYPE_AUDIO ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
imp->iananame, imp->samples_per_second, &orig_pt, NULL, &orig_fmtp) == SWITCH_STATUS_SUCCESS) {
imp->iananame, imp->samples_per_second, smh->fmtp[i], &orig_pt, NULL, &orig_fmtp) == SWITCH_STATUS_SUCCESS) {
if (orig_pt == smh->mparams->te) {
smh->mparams->te = (switch_payload_t)smh->payload_space++;
}
@ -8354,7 +8386,6 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\r\n");
if (v_engine->codec_negotiated) {
const char *of;
payload_map_t *pmap;
@ -8372,7 +8403,6 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
v_engine->cur_payload_map->pt, v_engine->cur_payload_map->rm_encoding,
v_engine->cur_payload_map->rm_rate);
if (switch_channel_test_flag(session->channel, CF_RECOVERING)) {
pass_fmtp = v_engine->cur_payload_map->rm_fmtp;
} else {
@ -8387,10 +8417,15 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
if (ov_fmtp) {
pass_fmtp = ov_fmtp;
} else if (switch_true(switch_channel_get_variable_dup(session->channel, "rtp_mirror_fmtp", SWITCH_FALSE, -1))) {
} else {
pass_fmtp = v_engine->cur_payload_map->fmtp_out;
if (!pass_fmtp || switch_true(switch_channel_get_variable_dup(session->channel, "rtp_mirror_fmtp", SWITCH_FALSE, -1))) {
pass_fmtp = switch_channel_get_variable(session->channel, "rtp_video_fmtp");
}
}
}
if (pass_fmtp) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\r\n", v_engine->cur_payload_map->pt, pass_fmtp);
@ -8403,7 +8438,6 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
if (pmap->pt != v_engine->cur_payload_map->pt && pmap->negotiated) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\r\n",
pmap->pt, pmap->iananame, pmap->rate);
}
}
switch_mutex_unlock(smh->sdp_mutex);
@ -8468,6 +8502,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
imp->samples_per_second);
}
if (!zstr(ov_fmtp)) {
fmtp = (char *) ov_fmtp;
} else {
@ -8476,7 +8512,9 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
fmtp = switch_event_get_header(map, imp->iananame);
}
if (smh->fmtps[i]) {
if (!zstr(smh->fmtp[i])) {
fmtp = smh->fmtp[i];
} else if (smh->fmtps[i]) {
fmtp = smh->fmtps[i];
}
@ -10099,7 +10137,6 @@ SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Setting NULL SDP is invalid\n");
return;
}
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
@ -10186,6 +10223,8 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
int num_codecs = 0;
char *codec_order[SWITCH_MAX_CODECS];
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 };
char fmtp[SWITCH_MAX_CODECS][MAX_FMTP_LEN];
switch_channel_t *channel = switch_core_session_get_channel(session);
int prefer_sdp = 0;
const char *var;
@ -10206,7 +10245,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
char *tmp_codec_string;
if ((tmp_codec_string = strdup(codec_string))) {
num_codecs = switch_separate_string(tmp_codec_string, ',', codec_order, SWITCH_MAX_CODECS);
num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, num_codecs);
num_codecs = switch_loadable_module_get_codecs_sorted(codecs, fmtp, SWITCH_MAX_CODECS, codec_order, num_codecs);
switch_safe_free(tmp_codec_string);
}
} else {
@ -10286,6 +10325,8 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
for (map = m->m_rtpmaps; map; map = map->rm_next) {
match = 0;
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
@ -10306,7 +10347,6 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
if (match) {
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
}
@ -10319,6 +10359,8 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
continue;
}
for (map = m->m_rtpmaps; map; map = map->rm_next) {
match = 0;
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
@ -10336,7 +10378,6 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
if (match) {
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
}
}
@ -10352,6 +10393,42 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
break;
}
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
for (map = m->m_rtpmaps; map; map = map->rm_next) {
match = 0;
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
if (map->rm_encoding) {
match = !strcasecmp(map->rm_encoding, imp->iananame) &&
((map->rm_pt < 96 && imp->ianacode < 96) || (map->rm_pt > 95 && imp->ianacode > 95));
} else {
match = 0;
}
}
if (match) {
if (map->rm_fmtp) {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s~%s", imp->modname, imp->iananame, map->rm_fmtp);
} else {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
}
already_did[imp->ianacode] = 1;
}
}
}
} else {
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
@ -10365,6 +10442,8 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
for (map = m->m_rtpmaps; map; map = map->rm_next) {
match = 0;
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
continue;
}
@ -10381,14 +10460,19 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
if (match) {
if (map->rm_fmtp) {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s~%s", imp->modname, imp->iananame, map->rm_fmtp);
} else {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
}
already_did[imp->ianacode] = 1;
break;
}
}
}
}
}
}
if (buf[0] == ',') {
switch_channel_set_variable(channel, "ep_codec_string", buf + 1);
}
@ -10600,7 +10684,7 @@ SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *s
if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_codec_string"))) {
char *tmp_codec_string = switch_core_session_strdup(smh->session, tmp);
smh->codec_order_last = switch_separate_string(tmp_codec_string, ',', smh->codec_order, SWITCH_MAX_CODECS);
smh->mparams->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
smh->mparams->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, smh->fmtp, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
}
if ((tmp = switch_channel_get_variable(session->channel, "rtp_2833_send_payload"))) {

View File

@ -37,6 +37,7 @@
//#define DEBUG_ALLOC
//#define DEBUG_ALLOC2
//#define DEBUG_ALLOC_CUTOFF 0 /* Lower to zero to log all pool allocations when DEBUG_ALLOC is defined */
//#define DESTROY_POOLS
//#define INSTANTLY_DESTROY_POOLS
//#define LOCK_MORE
@ -45,6 +46,9 @@
#ifndef SWITCH_POOL_RECYCLE
#define PER_POOL_LOCK 1
#endif
#ifndef DEBUG_ALLOC_CUTOFF
#define DEBUG_ALLOC_CUTOFF 500
#endif
static struct {
#ifdef USE_MEM_LOCK
@ -79,7 +83,7 @@ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(switch_core_session_t *
#endif
#ifdef DEBUG_ALLOC
if (memory > 500)
if (memory > DEBUG_ALLOC_CUTOFF)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Session Allocate %s %d\n",
(void *) session->pool, (void *) session, apr_pool_tag(session->pool, NULL), (int) memory);
#endif
@ -247,7 +251,7 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
#ifdef DEBUG_ALLOC
len = strlen(todup);
if (len > 500)
if (len > DEBUG_ALLOC_CUTOFF)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Sess Strdup Allocate %s %ld\n",
(void *) session->pool, (void *)session, apr_pool_tag(session->pool, NULL), strlen(todup));
#endif
@ -286,7 +290,7 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
len = strlen(todup) + 1;
#ifdef DEBUG_ALLOC
if (len > 500)
if (len > DEBUG_ALLOC_CUTOFF)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int)len);
#endif
@ -457,7 +461,7 @@ SWITCH_DECLARE(void *) switch_core_perform_alloc(switch_memory_pool_t *pool, swi
#endif
#ifdef DEBUG_ALLOC
if (memory > 500)
if (memory > DEBUG_ALLOC_CUTOFF)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int) memory);
/*switch_assert(memory < 20000); */

View File

@ -719,6 +719,7 @@ static const char *message_names[] = {
"UNBRIDGE",
"TRANSFER",
"RINGING",
"ALERTING",
"MEDIA",
"3P_MEDIA",
"NOMEDIA",

View File

@ -2346,11 +2346,12 @@ static void core_event_handler(switch_event_t *event)
case SWITCH_EVENT_CHANNEL_EXECUTE: {
new_sql() = switch_mprintf("update channels set application='%q',application_data='%q',"
"presence_id='%q',presence_data='%q' where uuid='%q'",
"presence_id='%q',presence_data='%q',accountcode='%q' where uuid='%q'",
switch_event_get_header_nil(event, "application"),
switch_event_get_header_nil(event, "application-data"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "variable_accountcode"),
switch_event_get_header_nil(event, "unique-id")
);
@ -2361,18 +2362,20 @@ static void core_event_handler(switch_event_t *event)
{
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q'",
"presence_id='%q',presence_data='%q',accountcode='%q',call_uuid='%q',%s where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "variable_accountcode"),
switch_event_get_header_nil(event, "channel-call-uuid"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q'",
"presence_id='%q',presence_data='%q',accountcode='%q',call_uuid='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "variable_accountcode"),
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "unique-id"));
}
@ -2463,7 +2466,7 @@ static void core_event_handler(switch_event_t *event)
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"sent_callee_name='%q',sent_callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',%s "
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',accountcode='%q',%s "
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
@ -2478,13 +2481,14 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "caller-context"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "variable_accountcode"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"sent_callee_name='%q',sent_callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' "
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',accountcode='%q' "
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
@ -2499,6 +2503,7 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "caller-context"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "variable_accountcode"),
switch_event_get_header_nil(event, "unique-id"));
}
break;
@ -2705,6 +2710,7 @@ static char create_channels_sql[] =
" hostname VARCHAR(256),\n"
" presence_id VARCHAR(4096),\n"
" presence_data VARCHAR(4096),\n"
" accountcode VARCHAR(256),\n"
" callstate VARCHAR(64),\n"
" callee_name VARCHAR(1024),\n"
" callee_num VARCHAR(256),\n"
@ -2804,6 +2810,7 @@ static char detailed_calls_sql[] =
"a.hostname as hostname,"
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.accountcode as accountcode,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
@ -2835,6 +2842,7 @@ static char detailed_calls_sql[] =
"b.hostname as b_hostname,"
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.accountcode as b_accountcode,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
@ -2874,6 +2882,7 @@ static char basic_calls_sql[] =
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.accountcode as accountcode,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
@ -2897,6 +2906,7 @@ static char basic_calls_sql[] =
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.accountcode as b_accountcode,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
@ -3437,7 +3447,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
char *err;
int result = 0;
switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name, initial_cid_name, initial_cid_num, initial_ip_addr, initial_dest, initial_dialplan, initial_context from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name, initial_cid_name, initial_cid_num, initial_ip_addr, initial_dest, initial_dialplan, initial_context, accountcode from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select * from basic_calls where sent_callee_name=''", "DROP VIEW basic_calls", basic_calls_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select * from detailed_calls where sent_callee_name=''", "DROP VIEW detailed_calls", detailed_calls_sql);

View File

@ -552,7 +552,12 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED)
&& switch_channel_test_flag(chan_b, CF_ANSWERED)) {
if (switch_true(switch_channel_get_variable_dup(chan_a, "bypass_media_after_bridge_oldschool", SWITCH_FALSE, -1))) {
switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);
} else {
switch_ivr_3p_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);
}
bypass_media_after_bridge = 0;
switch_channel_clear_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE);
goto end_of_bridge_loop;

View File

@ -2252,6 +2252,13 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
const char *transfer_on_failure)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
char *var_name_invalid = NULL;
if (!zstr(digits_regex) && !zstr(var_name)) {
var_name_invalid = switch_mprintf("%s_invalid", var_name);
switch_channel_set_variable(channel, var_name_invalid, NULL);
switch_safe_free(var_name_invalid);
}
while (switch_channel_ready(channel) && max_tries) {
switch_status_t status;
@ -2277,21 +2284,20 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
if (!(status == SWITCH_STATUS_TOO_SMALL && strlen(digit_buffer) == 0)) {
if (status == SWITCH_STATUS_SUCCESS) {
if (!zstr(digit_buffer)) {
char *invalid_var = NULL;
if (zstr(digits_regex)) {
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "Test Regex [%s][%s]\n", digit_buffer, digits_regex);
invalid_var = switch_mprintf("%s_invalid", var_name);
if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, invalid_var, NULL);
switch_safe_free(invalid_var);
return SWITCH_STATUS_SUCCESS;
} else {
switch_channel_set_variable(channel, var_name, NULL);
switch_channel_set_variable(channel, invalid_var, digit_buffer);
switch_safe_free(invalid_var);
if (!zstr(var_name)) {
var_name_invalid = switch_mprintf("%s_invalid", var_name);
switch_channel_set_variable(channel, var_name_invalid, digit_buffer);
switch_safe_free(var_name_invalid);
}
}
}
}

View File

@ -205,15 +205,15 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
for (impl = ptr->implementations; impl; impl = impl->next) {
if (impl->bits_per_second) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Adding Codec %s %d %s %dhz %dms %dbps\n",
"Adding Codec %s %d %s %dhz %dms %dch %dbps\n",
impl->iananame, impl->ianacode,
ptr->interface_name, impl->actual_samples_per_second,
impl->microseconds_per_packet / 1000, impl->bits_per_second);
impl->microseconds_per_packet / 1000, impl->number_of_channels, impl->bits_per_second);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Adding Codec %s %d %s %dhz %dms (VBR)\n",
"Adding Codec %s %d %s %dhz %dms %dch (VBR)\n",
impl->iananame, impl->ianacode,
ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000, impl->number_of_channels);
}
node = switch_core_alloc(new_module->pool, sizeof(*node));
@ -2340,7 +2340,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
}
SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname)
SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname, char **fmtp)
{
char *cur, *next = NULL, *name, *p;
@ -2380,10 +2380,17 @@ SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uin
name = p;
}
if ((p = strchr(name, '~'))) {
*p++ = '\0';
if (fmtp) {
*fmtp = p;
}
}
return name;
}
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen)
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, char fmtp_array[SWITCH_MAX_CODECS][MAX_FMTP_LEN], int arraylen, char **prefs, int preflen)
{
int x, i = 0, j = 0;
switch_codec_interface_t *codec_interface;
@ -2392,14 +2399,14 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
switch_mutex_lock(loadable_modules.mutex);
for (x = 0; x < preflen; x++) {
char *name, buf[256], jbuf[256], *modname = NULL;
char *name, buf[256], jbuf[256], *modname = NULL, *fmtp = NULL;
uint32_t interval = 0, rate = 0, bit = 0, channels = 1;
switch_copy_string(buf, prefs[x], sizeof(buf));
name = switch_parse_codec_buf(buf, &interval, &rate, &bit, &channels, &modname);
name = switch_parse_codec_buf(buf, &interval, &rate, &bit, &channels, &modname, &fmtp);
for(j = 0; j < x; j++) {
char *jname, *jmodname = NULL;
char *jname, *jmodname = NULL, *jfmtp = NULL;
uint32_t jinterval = 0, jrate = 0, jbit = 0, jchannels = 1;
uint32_t ointerval = interval, orate = rate, ochannels = channels;
@ -2416,7 +2423,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
}
switch_copy_string(jbuf, prefs[j], sizeof(jbuf));
jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit, &jchannels, &jmodname);
jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit, &jchannels, &jmodname, &jfmtp);
if (jinterval == 0) {
jinterval = switch_default_ptime(jname, 0);
@ -2430,7 +2437,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
jchannels = 1;
}
if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate && ochannels == jchannels) {
if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate && ochannels == jchannels &&
!strcasecmp(switch_str_nil(fmtp), switch_str_nil(jfmtp))) {
goto next_x;
}
}
@ -2462,7 +2470,9 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
}
}
if (!zstr(fmtp)) {
switch_set_string(fmtp_array[i], fmtp);
}
array[i++] = imp;
goto found;

View File

@ -5176,6 +5176,10 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
switch_core_timer_sync(&rtp_session->timer);
}
if (rtp_session->session) {
switch_ivr_parse_all_messages(rtp_session->session);
}
block = 0;
}

View File

@ -360,7 +360,7 @@ static switch_status_t init_encoder(switch_codec_t *codec)
vpx_codec_enc_cfg_t *config = &context->config;
int token_parts = 1;
int cpus = switch_core_cpu_count();
int sane;
int sane, threads = 1;
if (!context->codec_settings.video.width) {
context->codec_settings.video.width = 1280;
@ -404,7 +404,9 @@ static switch_status_t init_encoder(switch_codec_t *codec)
config->rc_target_bitrate = context->bandwidth;
config->g_lag_in_frames = 0;
config->kf_max_dist = 360;//2000;
config->g_threads = cpus - 1;//(cpus > 1) ? 2 : 1;
threads = cpus / 4;
if (threads < 0) threads = 1;
config->g_threads = threads;
if (context->is_vp9) {
//config->rc_dropframe_thresh = 2;