Merge branch 'master' into v1.6 for v1.6.2

This commit is contained in:
Ken Rice 2015-09-25 09:49:42 -05:00
commit f6ab7ff6ae
163 changed files with 11055 additions and 9583 deletions

View File

@ -224,7 +224,7 @@ library_include_HEADERS = \
src/include/switch_types.h \
src/include/switch_utils.h \
src/include/switch_rtp.h \
src/include/switch_vidderbuffer.h \
src/include/switch_jitterbuffer.h \
src/include/switch_rtcp_frame.h \
src/include/switch_stun.h \
src/include/switch_nat.h \
@ -234,7 +234,6 @@ library_include_HEADERS = \
src/include/switch_cpp.h \
src/include/switch_curl.h \
src/include/switch_json.h \
src/include/switch_stfu.h \
src/include/switch_utf8.h \
src/include/switch_vpx.h \
libs/libteletone/src/libteletone_detect.h \
@ -290,7 +289,7 @@ libfreeswitch_la_SOURCES = \
src/switch_resample.c \
src/switch_regex.c \
src/switch_rtp.c \
src/switch_vidderbuffer.c \
src/switch_jitterbuffer.c \
src/switch_ivr_bridge.c \
src/switch_ivr_originate.c \
src/switch_ivr_async.c \
@ -315,7 +314,6 @@ libfreeswitch_la_SOURCES = \
src/switch_json.c \
src/switch_curl.c \
src/switch_hashtable.c\
src/switch_stfu.c \
src/switch_utf8.c \
libs/libtpl-1.5/src/tpl.c \
libs/libteletone/src/libteletone_detect.c \

View File

@ -1,7 +1,14 @@
<configuration name="opus.conf">
<settings>
<param name="use-vbr" value="1"/>
<!--<param name="use-dtx" value="1"/>-->
<param name="complexity" value="10"/>
<!-- Set the initial packet loss percentage 0-100 -->
<!--<param name="packet-loss-percent" value="10"/>-->
<!-- Support asymmetric sample rates -->
<!--<param name="asymmetric-sample-rates" value="1"/>-->
<!-- Keep FEC Enabled -->
<param name="keep-fec-enabled" value="1"/>
<!--
maxaveragebitrate: the maximum average codec bitrate (values: 6000 to 510000 in bps) 0 is not considered
@ -14,6 +21,8 @@
-->
<param name="maxaveragebitrate" value="0"/>
<param name="maxplaybackrate" value="0"/>
<!-- Max capture rate, 8000, 12000, 16000, 24000 and 48000 are valid options -->
<!--<param name="sprop-maxcapturerate" value="0"/>-->
</settings>
</configuration>

View File

@ -91,7 +91,7 @@
<load module="mod_g729"/>
<load module="mod_amr"/>
<!--<load module="mod_ilbc"/>-->
<load module="mod_h26x"/>
<!--<load module="mod_h26x"/>-->
<load module="mod_vpx"/>
<load module="mod_b64"/>
<!--<load module="mod_siren"/>-->

View File

@ -1,8 +1,15 @@
<configuration name="opus.conf">
<settings>
<param name="use-vbr" value="1"/>
<!--<param name="use-dtx" value="1"/>-->
<param name="complexity" value="10"/>
<!-- Set the initial packet loss percentage 0-100 -->
<!--<param name="packet-loss-percent" value="10"/>-->
<!-- Support asymmetric sample rates -->
<!--<param name="asymmetric-sample-rates" value="1"/>-->
<!-- Keep FEC Enabled -->
<param name="keep-fec-enabled" value="1"/>
<!--<param name="use-jb-lookahead" value="true"/> -->
<!--
maxaveragebitrate: the maximum average codec bitrate (values: 6000 to 510000 in bps) 0 is not considered
maxplaybackrate: the maximum codec internal frequency (values: 8000, 12000, 16000, 24000, 48000 in Hz) 0 is not considered
@ -14,6 +21,8 @@
-->
<param name="maxaveragebitrate" value="0"/>
<param name="maxplaybackrate" value="0"/>
<!-- Max capture rate, 8000, 12000, 16000, 24000 and 48000 are valid options -->
<!--<param name="sprop-maxcapturerate" value="0"/>-->
</settings>
</configuration>

View File

@ -559,13 +559,12 @@ AC_SUBST(SYS_XMLRPC_CFLAGS)
AC_SUBST(SYS_XMLRPC_LDFLAGS)
AM_CONDITIONAL([SYSTEM_XMLRPCC],[test "${enable_xmlrpcc}" = "yes"])
PKG_CHECK_MODULES([LUA],[lua5.2],[have_lua=yes],[have_lua=no])
if test "${have_lua}" = "no" ; then
PKG_CHECK_MODULES([LUA],[lua5.1],[have_lua=yes],[have_lua=no])
fi
if test "${have_lua}" = "no" ; then
PKG_CHECK_MODULES([LUA],[lua],[have_lua=yes],[have_lua=no])
fi
for luaversion in lua5.2 lua-5.2 lua5.1 lua-5.1 lua; do
PKG_CHECK_MODULES([LUA],[${luaversion}],[have_lua=yes],[have_lua=no])
if test ${have_lua} = yes; then
break
fi
done
if test x"${LUA_LIBS}" = x"" ; then
LUA_LIBS="-llua"
fi

3
debian/bootstrap.sh vendored
View File

@ -362,7 +362,8 @@ Description: Cross-Platform Scalable Multi-Protocol Soft Switch
Package: libfreeswitch1
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Depends: \${shlibs:Depends}, \${misc:Depends},
libyuv, libvpx (>= 1.4.0) | libvpx2
Recommends:
Suggests: libfreeswitch1-dbg
Description: Cross-Platform Scalable Multi-Protocol Soft Switch

View File

@ -113,6 +113,12 @@ Module: applications/mod_hash
Description: Hash
This module provides a hash API, a key-value in-memory datastore.
Module: applications/mod_hiredis
Description: Redis client support
This module provides a mechanism to use Redis as a datastore.
Build-Depends: libhiredis-dev
Depends: libhiredis0.10
Module: applications/mod_httapi
Description: HT-TAPI Hypertext Telephony API
This module provides an API for controlling the switch by responding

10
debian/copyright vendored
View File

@ -1517,22 +1517,22 @@ Copyright: 1992, 1993, 1994 by Jutta Degener and Carsten Bormann
License:
Their work was released under the following license which is
assumed to be compatible with The GNU Lesser General Public License.
.
----------------------------------------------------------------------------
.
Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin
.
Any use of this software is permitted provided that this notice is not
removed and that neither the authors nor the Technische Universitaet Berlin
are deemed to have made any representations as to the suitability of this
software for any purpose nor are held responsible for any defects of
this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
.
As a matter of courtesy, the authors request to be informed about uses
this software has found, about bugs in this software, and about any
improvements that may be of general interest.
.
Berlin, 28.11.1994
Jutta Degener (jutta@cs.tu-berlin.de)
Carsten Bormann (cabo@cs.tu-berlin.de)

View File

@ -0,0 +1 @@
/usr/lib/python*/*-packages/freeswitch.py

View File

@ -1 +0,0 @@
d /run/freeswitch 0755 freeswitch freeswitch -

View File

@ -8,14 +8,12 @@ After=syslog.target network.target local-fs.target
; service
Type=forking
PIDFile=/run/freeswitch/freeswitch.pid
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /run/freeswitch
ExecStartPre=/bin/chown freeswitch:freeswitch /run/freeswitch
ExecStart=/usr/bin/freeswitch -ncwait -nonat
TimeoutSec=45s
Restart=always
; exec
WorkingDirectory=/var/log/freeswitch
RuntimeDirectory=freeswitch
RuntimeDirectoryMode=0755
User=freeswitch
Group=freeswitch
LimitCORE=infinity

View File

@ -1,3 +1 @@
/lib/systemd/system/freeswitch.service
/usr/lib/tmpfiles.d/freeswitch.conf

View File

@ -31,8 +31,8 @@ case "$1" in
done
if [ ! -d "/etc/freeswitch" ]; then
mkdir -p /etc/freeswitch/tls/
chown freeswitch:freeswitch /etc/freeswitch/tls
cp -a /usr/share/freeswitch/conf/vanilla/* /etc/freeswitch/
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)

4
debian/rules vendored
View File

@ -100,10 +100,6 @@ override_dh_auto_install:
dh_auto_install -- -C libs/esl pymod-install
mkdir -p debian/tmp/lib/systemd/system
install -m0644 debian/freeswitch-systemd.freeswitch.service debian/tmp/lib/systemd/system/freeswitch.service
mkdir -p debian/tmp/usr/lib/tmpfiles.d
install -m0644 debian/freeswitch-systemd.freeswitch.conf debian/tmp/usr/lib/tmpfiles.d/freeswitch.conf
rm -f debian/tmp/usr/share/freeswitch/grammar/model/communicator/COPYING
override_dh_installinit:

View File

@ -1279,9 +1279,6 @@ PREDEFINED =SWITCH_DECLARE(type)=type \
SPAN_DECLARE(type)=type \
SPAN_DECLARE_NONSTD(type)=type \
SPAN_DECLARE_DATA= \
STFU_DECLARE(type)=type \
STFU_DECLARE_NONSTD(type)=type \
STFU_DECLARE_DATA= \
FT_DECLARE(type)=type \
FT_DECLARE_NONSTD(type)=type \
FT_DECLARE_INLINE(type)=type \

View File

@ -1,5 +1,5 @@
var iceTimerSent=0;var iceTimerCompleted=0;var iceTimer;(function($){function findLine(sdpLines,prefix,substr){return findLineInRange(sdpLines,0,-1,prefix,substr);}
(function($){function findLine(sdpLines,prefix,substr){return findLineInRange(sdpLines,0,-1,prefix,substr);}
function findLineInRange(sdpLines,startLine,endLine,prefix,substr){var realEndLine=(endLine!=-1)?endLine:sdpLines.length;for(var i=startLine;i<realEndLine;++i){if(sdpLines[i].indexOf(prefix)===0){if(!substr||sdpLines[i].toLowerCase().indexOf(substr.toLowerCase())!==-1){return i;}}}
return null;}
function getCodecPayloadType(sdpLine){var pattern=new RegExp('a=rtpmap:(\\d+) \\w+\\/\\d+');var result=sdpLine.match(pattern);return(result&&result.length==2)?result[1]:null;}
@ -8,7 +8,7 @@ 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,}};}
if(self.options.useVideo){self.options.useVideo.style.display='none';}
setCompat();checkCompat();};$.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;}}
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;}}
@ -27,15 +27,15 @@ 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';self.options.useVideo[moz?'mozSrcObject':'src']=null;}
$.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;}
if(self.options.localVideo){self.options.localVideo.style.display='none';self.options.localVideo[moz?'mozSrcObject':'src']=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;}
$.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;}
$.FSRTC.prototype.createAnswer=function(params){var self=this;self.type="answer";self.remoteSDP=params.sdp;console.debug("inbound sdp: ",params.sdp);self.options.useCamera=params.useCamera||"any";self.options.useMic=params.useMic||"any";self.options.useSpeak=params.useSpeak||"any";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);}
$.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}]}}
@ -43,18 +43,22 @@ if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audi
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 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=null;useVideo=null;}
if(bestFrameRate&&!window.moz){video.optional.push({minFrameRate:bestFrameRate});}}else{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;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){console.error("SKIP");}: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 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 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);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;}
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}];}
var peer=new PeerConnection(iceServers,optional);openOffererChannel();var x=0;peer.onicecandidate=function(event){if(event.candidate){options.onICE(event.candidate);clearTimeout(iceTimer);iceTimer=setTimeout(function(){iceTimerSent=1;if(iceTimerCompleted==0){if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}},1000);}else{if(iceTimerSent==0){clearTimeout(iceTimer);iceTimerCompleted=1;if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
var peer=new PeerConnection(iceServers,optional);openOffererChannel();var x=0;function ice_handler(){done=true;gathering=null;if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}
peer.onicecandidate=function(event){if(done){return;}
if(!gathering){gathering=setTimeout(ice_handler,1000);}
if(event){if(event.candidate){options.onICE(event.candidate);}}else{done=true;if(gathering){clearTimeout(gathering);gathering=null;}
ice_handler();}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
peer.onaddstream=function(event){var remoteMediaStream=event.stream;remoteMediaStream.onended=function(){if(options.onRemoteStreamEnded)options.onRemoteStreamEnded(remoteMediaStream);};if(options.onRemoteStream)options.onRemoteStream(remoteMediaStream);};var constraints=options.constraints||{offerToReceiveAudio:true,offerToReceiveVideo:true};function createOffer(){if(!options.onOfferSDP)return;peer.createOffer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);options.onOfferSDP(sessionDescription);if(moz&&options.onICESDP&&sessionDescription.sdp.match(/a=candidate/)){options.onICESDP(sessionDescription);options.sentICESDP=1;}},onSdpError,constraints);}
function createAnswer(){if(options.type!="answer")return;peer.setRemoteDescription(new SessionDescription(options.offerSDP),onSdpSuccess,onSdpError);peer.createAnswer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);if(options.onAnswerSDP){options.onAnswerSDP(sessionDescription);}},onSdpError,constraints);}
if((options.onChannelMessage&&!moz)||!options.onChannelMessage){createOffer();createAnswer();}
@ -75,17 +79,20 @@ var video_constraints={mandatory:{},optional:[]};function getUserMedia(options){
if(options.onsuccess){options.onsuccess(stream);}
media=stream;}
return media;}
$.FSRTC.validRes=[];$.FSRTC.resSupported=function(w,h){for(var i in $.FSRTC.validRes){if($.FSRTC.validRes[i][0]==w&&$.FSRTC.validRes[i][1]==h){return true;}}
$.FSRTC.resSupported=function(w,h){for(var i in $.FSRTC.validRes){if($.FSRTC.validRes[i][0]==w&&$.FSRTC.validRes[i][1]==h){return true;}}
return false;}
$.FSRTC.bestResSupported=function(){var w=0,h=0;for(var i in $.FSRTC.validRes){if($.FSRTC.validRes[i][0]>w&&$.FSRTC.validRes[i][1]>h){w=$.FSRTC.validRes[i][0];h=$.FSRTC.validRes[i][1];}}
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){if(func)return func();return;}
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);}});}
$.FSRTC.getValidRes=function(cam,func){var used=[];$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
$.FSRTC.checkPerms=function(){getUserMedia({constraints:{audio:true,video:true,},onsuccess:function(e){e.stop();console.info("media perm init complete");},onerror:function(e){console.error("media perm init error");}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
$.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={};}
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);};}
@ -118,10 +125,14 @@ 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:{},userVariables:{},iceServers:false,ringSleep:6000,sessid:null},options);if(verto.options.sessid){verto.sessid=verto.options.sessid;}else{verto.sessid=$.cookie('verto_session_uuid')||generateGUID();$.cookie('verto_session_uuid',verto.sessid,{expires:1});}
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);}
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.rpcClient.call('login',{});};$.verto.prototype.videoParams=function(on){var verto=this;verto.options.videoParams=on;};$.verto.prototype.iceServers=function(on){var verto=this;verto.options.iceServers=on;};$.verto.prototype.loginData=function(params){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.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++;}
if(!msg.body){console.error("Missing Body");err++;}
if(err){return false;}
@ -190,7 +201,18 @@ dt.fnClearTable();dt.fnAddData(obj.asArray());dt.fnAdjustColumnSizing();break;ca
if(args.redraw>-1){dt.fnClearTable();dt.fnAddData(obj.asArray());}else{dt.fnAddData(args.data);}
dt.fnAdjustColumnSizing();break;case"modify":if(!args.data){return;}
dt.fnUpdate(args.data,index);dt.fnAdjustColumnSizing();break;case"del":dt.fnDeleteRow(index);dt.fnAdjustColumnSizing();break;case"clear":dt.fnClearTable();break;case"reorder":dt.fnClearTable();dt.fnAddData(obj.asArray());break;case"hide":jq.hide();break;case"show":jq.show();break;}}catch(err){console.error("ERROR: "+err);iserr++;}
if(iserr){obj.errs++;if(obj.errs<3){obj.bootstrap(obj.user_obj);}}else{obj.errs=0;}};la.onChange(la,{action:"init"});};var CONFMAN_SERNO=1;$.verto.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>"+
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("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}});};}
$.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);}
$("#"+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"]);});}
@ -199,28 +221,30 @@ html+="<br>"+"<button class='ctlbtn' id='"+layer_set_id+"'>Set Layer</button>"+"
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;}
var atitle="";var awidth=0;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("");}
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(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.destroy=function(){var confMan=this;confMan.destroyed=true;if(confMan.lt){confMan.lt.destroy();}
confMan.lt=new $.verto.liveTable(verto,confMan.params.laData.laChannel,confMan.params.laData.laName,$(confMan.params.tableID),{subParams:{callID:confMan.params.dialog?confMan.params.dialog.callID:null},"onChange":function(obj,args){$(confMan.params.statusID).text("Conference Members: "+" ("+obj.arrayLen()+" Total)");if(confMan.params.onLaChange){confMan.params.onLaChange(verto,confMan,$.verto.enum.confEvent.laChange,obj,args);}},"aaData":[],"aoColumns":[{"sTitle":"ID","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:"any",useMic:"any",useSpeak:"any",tag:verto.options.tag,localTag:verto.options.localTag,login:verto.options.login,videoParams:verto.options.videoParams},params);dialog.useCamera=verto.options.deviceParams.useCamera;dialog.useMic=verto.options.deviceParams.useMic;dialog.useSpeak=verto.options.deviceParams.useSpeak;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=params.useCamera;dialog.useMic=params.useMic;dialog.useSpeak=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;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(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;}
if(!dialog.params.remote_caller_id_name){dialog.params.remote_caller_id_name="Nobody";}
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){if(rtc.type=="offer"){console.log("offer",rtc.mediaData.SDP);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.videoStream,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;}
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;}
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;}
$.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.info("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;}
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);}
@ -238,15 +262,18 @@ dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.proto
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={};}
params.sdp=dialog.params.sdp;dialog.useCamera=dialog.verto.options.deviceParams.useCamera;dialog.useMic=dialog.verto.options.deviceParams.useMic;dialog.useSpeak=dialog.verto.options.deviceParams.useSpeak;if(params){if(params.useVideo){dialog.useVideo(true);}
dialog.params.callee_id_name=params.callee_id_name;dialog.params.callee_id_number=params.callee_id_number;dialog.useCamera=params.useCamera;dialog.useMic=params.useMic;dialog.useSpeak=params.useSpeak;}
params.sdp=dialog.params.sdp;if(params){if(params.useVideo){dialog.useVideo(true);}
dialog.params.callee_id_name=params.callee_id_name;dialog.params.callee_id_number=params.callee_id_number;if(params.useCamera){dialog.useCamera=params.useCamera;}
if(params.useMic){dialog.useMic=params.useMic;}
if(params.useSpeak){dialog.useSpeak=params.useSpeak;}}
dialog.rtc.createAnswer(params);dialog.answered=true;}};$.verto.dialog.prototype.handleAnswer=function(params){var dialog=this;dialog.gotAnswer=true;if(dialog.state.val>=$.verto.enum.state.active.val){return;}
if(dialog.state.val>=$.verto.enum.state.early.val){dialog.setState($.verto.enum.state.active);}else{if(dialog.gotEarly){console.log("Dialog "+dialog.callID+" Got answer while still establishing early media, delaying...");}else{console.log("Dialog "+dialog.callID+" Answering Channel");dialog.rtc.answer(params.sdp,function(){dialog.setState($.verto.enum.state.active);},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"ANSWER SDP",params.sdp);}}};$.verto.dialog.prototype.cidString=function(enc){var dialog=this;var party=dialog.params.remote_caller_id_name+(enc?" &lt;":" <")+dialog.params.remote_caller_id_number+(enc?"&gt;":">");return party;};$.verto.dialog.prototype.sendMessage=function(msg,params){var dialog=this;if(dialog.callbacks.onMessage){dialog.callbacks.onMessage(dialog.verto,dialog,msg,params);}};$.verto.dialog.prototype.handleInfo=function(params){var dialog=this;dialog.sendMessage($.verto.enum.message.info,params.msg);};$.verto.dialog.prototype.handleDisplay=function(params){var dialog=this;if(params.display_name){dialog.params.remote_caller_id_name=params.display_name;}
if(params.display_number){dialog.params.remote_caller_id_number=params.display_number;}
dialog.sendMessage($.verto.enum.message.display,{});};$.verto.dialog.prototype.handleMedia=function(params){var dialog=this;if(dialog.state.val>=$.verto.enum.state.early.val){return;}
dialog.gotEarly=true;dialog.rtc.answer(params.sdp,function(){console.log("Dialog "+dialog.callID+"Establishing early media");dialog.setState($.verto.enum.state.early);if(dialog.gotAnswer){console.log("Dialog "+dialog.callID+"Answering Channel");dialog.setState($.verto.enum.state.active);}},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"EARLY SDP",params.sdp);};$.verto.ENUM=function(s){var i=0,o={};s.split(" ").map(function(x){o[x]={name:x,val:i++};});return Object.freeze(o);};$.verto.enum={};$.verto.enum.states=Object.freeze({new:{requesting:1,recovering:1,ringing:1,destroy:1,answering:1,hangup:1},requesting:{trying:1,hangup:1},recovering:{answering:1,hangup:1},trying:{active:1,early:1,hangup:1},ringing:{answering:1,hangup:1},answering:{active:1,hangup:1},active:{answering:1,requesting:1,hangup:1,held:1},held:{hangup:1,active:1},early:{hangup:1,active:1},hangup:{destroy:1},destroy:{},purge:{destroy:1}});$.verto.enum.state=$.verto.ENUM("new requesting trying recovering ringing answering early active held hangup destroy purge");$.verto.enum.direction=$.verto.ENUM("inbound outbound");$.verto.enum.message=$.verto.ENUM("display info pvtEvent");$.verto.enum=Object.freeze($.verto.enum);$.verto.saved=[];$.verto.unloadJobs=[];$(window).bind('beforeunload',function(){for(var f in $.verto.unloadJobs){$.verto.unloadJobs[f]();}
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(err.name+": "+error.message);runtime();});}};$.verto.init=function(obj,runtime){checkDevices(function(){$.FSRTC.getValidRes(obj.camera,runtime);});}
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.genUUID=function(){return generateGUID();}})(jQuery);

View File

@ -29,11 +29,6 @@
*
*/
var iceTimerSent = 0;
var iceTimerCompleted = 0;
var iceTimer;
(function($) {
// Find the line in sdpLines that starts with |prefix|, and, if specified,
@ -173,18 +168,24 @@ var iceTimer;
var sdpLines = sdp.split('\r\n');
// Find opus payload.
var opusIndex = findLine(sdpLines, 'a=rtpmap', 'opus/48000'),
opusPayload;
if (opusIndex) {
var opusIndex = findLine(sdpLines, 'a=rtpmap', 'opus/48000'), opusPayload;
if (!opusIndex) {
return sdp;
} else {
opusPayload = getCodecPayloadType(sdpLines[opusIndex]);
}
// Find the payload in fmtp line.
var fmtpLineIndex = findLine(sdpLines, 'a=fmtp:' + opusPayload.toString());
if (fmtpLineIndex === null) return sdp;
if (fmtpLineIndex === null) {
// create an fmtp line
sdpLines[opusIndex] = sdpLines[opusIndex] + '\r\na=fmtp:' + opusPayload.toString() + " stereo=1; sprop-stereo=1"
} else {
// Append stereo=1 to fmtp line.
sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat('; stereo=1');
sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat('; stereo=1; sprop-stereo=1');
}
sdp = sdpLines.join('\r\n');
return sdp;
@ -292,6 +293,13 @@ var iceTimer;
onSuccess, onError);
};
$.FSRTC.prototype.stopPeer = function() {
if (self.peer) {
console.log("stopping peer");
self.peer.stop();
}
}
$.FSRTC.prototype.stop = function() {
var self = this;
@ -305,7 +313,11 @@ var iceTimer;
}
if (self.localStream) {
if(typeof self.localStream.stop == 'function') {
self.localStream.stop();
} else {
self.localStream.active = false;
}
self.localStream = null;
}
@ -319,7 +331,11 @@ var iceTimer;
}
if (self.options.localVideoStream) {
if(typeof self.options.localVideoStream.stop == 'function') {
self.options.localVideoStream.stop();
} else {
self.options.localVideoStream.active = false;
}
}
if (self.peer) {
@ -507,8 +523,8 @@ var iceTimer;
}
} else {
video = null;
useVideo = null;
video = false;
useVideo = false;
}
return {audio: audio, video: video, useVideo: useVideo};
@ -604,6 +620,7 @@ var iceTimer;
window.moz = !!navigator.mozGetUserMedia;
function RTCPeerConnection(options) {
var gathering = false, done = false;
var w = window,
PeerConnection = w.mozRTCPeerConnection || w.webkitRTCPeerConnection,
@ -655,101 +672,71 @@ var iceTimer;
openOffererChannel();
var x = 0;
function ice_handler() {
done = true;
gathering = null;
if (options.onICEComplete) {
options.onICEComplete();
}
if (options.type == "offer") {
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createOffer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
} else {
if (!x && options.onICESDP) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createAnswer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
}
}
peer.onicecandidate = function(event) {
if (done) {
return;
}
if (!gathering) {
gathering = setTimeout(ice_handler, 1000);
}
if (event) {
if (event.candidate) {
options.onICE(event.candidate);
clearTimeout(iceTimer);
iceTimer = setTimeout(function() {
iceTimerSent = 1;
if (iceTimerCompleted == 0) {
if (options.onICEComplete) {
options.onICEComplete();
}
if (options.type == "offer") {
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
to handle partial setups to maybe save 100m
*/
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createOffer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
} else {
if (!x && options.onICESDP) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createAnswer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
}
}
}, 1000);
} else {
if (iceTimerSent == 0) {
clearTimeout(iceTimer);
iceTimerCompleted = 1;
done = true;
if (options.onICEComplete) {
options.onICEComplete();
if (gathering) {
clearTimeout(gathering);
gathering = null;
}
if (options.type == "offer") {
/* new mozilla now tries to be like chrome but it takes them 10 seconds to complete the ICE
Booooooooo! This trickle thing is a waste of time...... We'll all have to re-code our engines
to handle partial setups to maybe save 100m
*/
if ((!moz || (!options.sentICESDP && peer.localDescription.sdp.match(/a=candidate/)) && !x && options.onICESDP)) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createOffer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
} else {
if (!x && options.onICESDP) {
options.onICESDP(peer.localDescription);
//x = 1;
/*
x = 1;
peer.createAnswer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription);
if (options.onICESDP) {
options.onICESDP(sessionDescription);
}
}, onSdpError, constraints);
*/
}
}
}
ice_handler();
}
};
@ -972,7 +959,11 @@ var iceTimer;
stop: function() {
peer.close();
if (options.attachStream) {
if(typeof options.attachStream.stop == 'function') {
options.attachStream.stop();
} else {
options.attachStream.active = false;
}
}
}
@ -1094,7 +1085,13 @@ var iceTimer;
audio: ttl++ == 0,
video: video
},
onsuccess: function(e) {e.stop(); console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
onsuccess: function(e) {
if(typeof e.stop == 'function') {
e.stop();
} else {
e.active = false;
}
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);}
});
}
@ -1123,14 +1120,35 @@ var iceTimer;
checkRes(cam, func);
}
$.FSRTC.checkPerms = function (runtime) {
$.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
getUserMedia({
constraints: {
audio: true,
video: true,
audio: check_audio,
video: check_video,
},
onsuccess: function(e) {e.stop(); console.info("media perm init complete"); if (runtime) {setTimeout(runtime, 100, true)}},
onerror: function(e) {console.error("media perm init error"); if (runtime) {runtime(false)}}
onsuccess: function(e) {
if(typeof e.stop == 'function') {
e.stop();
} else {
e.active = false;
}
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)
}
}
});
}

View File

@ -1962,8 +1962,8 @@
dialog.rtc = new $.FSRTC({
callbacks: RTCcallbacks,
localVideo: dialog.localVideo,
useVideo: dialog.videoStream,
localVideo: dialog.screenShare ? null : dialog.localVideo,
useVideo: dialog.params.useVideo ? dialog.videoStream : null,
useAudio: dialog.audioStream,
useStereo: dialog.params.useStereo,
videoParams: dialog.params.videoParams,
@ -2093,7 +2093,9 @@
break;
case $.verto.enum.state.destroy:
delete dialog.verto.dialogs[dialog.callID];
if (!dialog.params.screenShare) {
if (dialog.params.screenShare) {
dialog.rtc.stopPeer();
} else {
dialog.rtc.stop();
}
break;
@ -2588,7 +2590,7 @@
})
.catch(function(err) {
console.log(err.name + ": " + error.message);
console.log(" Device Enumeration ERROR: " + err.name + ": " + err.message);
runtime();
});
}
@ -2602,7 +2604,7 @@
$.verto.init = function(obj, runtime) {
$.FSRTC.checkPerms(function() {
checkDevices(runtime);
});
}, true, true);
}
$.verto.genUUID = function () {

View File

@ -281,6 +281,7 @@ module.exports = function (grunt) {
src: [
'*.{ico,png,txt}',
'*.html',
'*.json',
'partials/**/*.html',
'images/{,*/}*.{webp}',
'css/fonts/{,*/}*.*',

View File

@ -32,6 +32,7 @@
"angular-prompt": "~1.1.1",
"angular-animate": "~1.3.15",
"angular-cookies": "~1.3.15",
"angular-directive.g-signin": "~0.1.2",
"jquery": "~2.1.4",
"angular-fullscreen": "~1.0.1",
"ngstorage": "~0.3.9",

View File

@ -0,0 +1,4 @@
{
"login": "1008",
"password": "1234"
}

View File

@ -0,0 +1,13 @@
{
"extension": "3500",
"name": "Ken Rice",
"email": "krice@freeswitch.org",
"cid": "1008",
"textTo": "1000",
"login": "1008",
"password": "1234",
"autologin": "true",
"autocall": "3500",
"googlelogin": "true",
"wsURL": "wss://gamma.tollfreegateway.com/wss2"
}

View File

@ -2,5 +2,6 @@
"Jonatas Oliveira <jonatas@evolux.net.br>",
"Ítalo Rossi <italo@evolux.net.br>",
"Stefan Yohansson <stefan@evolux.net.br>",
"João Mesquita <jmesquita@indicium.com.ar>"
"João Mesquita <jmesquita@indicium.com.ar>",
"Ken Rice <krice@freeswitch.org>"
]

View File

@ -36,13 +36,19 @@ body {
height: 100%;
}
.modal-content .modal-footer button.btn-pull-left {
padding-left: 16px;
padding-right: 16px;
margin-left: 5px;
}
/* This is an technique to align the block centered vertically
and horizontally in a page. */
.centered-block-frame {
display: flex;
display: -webkit-flex; /* Safari */
-webkit-justify-content: center; /* Safari 6.1+ */
-webkit-align-items: center;
display: flex;
justify-content: center;
align-items: center;
object-fit:inherit;
@ -72,6 +78,10 @@ button.btn i {
z-index:1001;
}
.googlelogin {
margin: 5px 0px;
}
.navbar .navbar-nav > li.navbar-item-icon > a {
padding: 18px;
height: 60px;
@ -483,6 +493,7 @@ body .modal-body .btn-group .btn.active {
#incall .panel {
background: #333;
padding-top: 5px;
}
#incall .hangup-button {
@ -842,6 +853,14 @@ body .modal-body .btn-group .btn.active {
/*color: #DDD;*/
}
.members-name {
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 5px;
white-space: nowrap;
}
.chat-members .chat-member-item {
padding: 8px 16px;
height: 56px;
@ -873,7 +892,7 @@ body .modal-body .btn-group .btn.active {
margin: 0;
font-size: 16px;
display: inline-block;
line-height: 40px;
line-height: 18px;
}
.chat-members .chat-members-status i {

View File

@ -71,6 +71,7 @@
<script src="bower_components/angular-prompt/dist/angular-prompt.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-directive.g-signin/google-plus-signin.js"></script>
<script src="bower_components/angular-fullscreen/src/angular-fullscreen.js"></script>
<script src="bower_components/ngstorage/ngStorage.js"></script>
<script src="bower_components/momentjs/moment.js"></script>
@ -121,9 +122,9 @@
<script type="text/javascript" src="src/storageService/storageService.module.js"></script>
<script type="text/javascript" src="src/storageService/services/storage.js"></script>
<script type="text/javascript" src="src/storageService/services/call_history.js"></script>
<!-- endbuild -->
</body>
</html>

View File

@ -21,7 +21,7 @@
<span class="chat-members-avatar">
<img gravatar-size="40" gravatar-src-once="member.email" class="img-circle" ng-class="{'chat-member-talking': member.status.audio.talking, 'chat-member-muted': member.status.audio.muted}" />
</span>
<h4 class="chat-members-name">{{ member.name }}</h4>
<h4 class="chat-members-name"><div class="members-name">{{ member.name }}</div> <small>({{ member.number }})</small></h4>
<div class="pull-right action-buttons chat-members-action" ng-show="verto.data.confRole == 'moderator'">
<div class="btn-group">
<button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown">

View File

@ -4,6 +4,7 @@
<div class="panel-body">
<h3>Login</h3>
<div ng-show="form.$submitted && form.$invalid" class="alert alert-danger">
<p>Verify the fields bellow and try again.</p>
</div>
@ -45,9 +46,14 @@
<input type="text" class="form-control" id="login-password" placeholder="Password" ng-model="verto.data.password">
</div>
<div class="form-group text-right">
<a style="margin-top: 13px;" href="" ng-click="advanced = !advanced" class="pull-left">Settings</a>
<button type="submit" class="btn btn-success" ng-click="(form.$valid && login())">Login</button>
<div><a style="margin-top: 13px;" href="" ng-click="advanced = !advanced" class="pull-left">Settings</a></div>
<div><button type="submit" class="btn btn-success" ng-click="(form.$valid && login())">Login</button></div>
<div ng-if="googlelogin" class="googlelogin">
<google-plus-signin clientid="{{src/partials/login.html}}" class="center">
</google-plus-signin>
</div>
</div>
</form>
</div>

View File

@ -112,6 +112,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-danger pull-left btn-pull-left" ng-click="resetSettings()">Factory reset</button>
<!-- <button class="btn btn-primary" ng-click="cancel()">Cancel</button> -->
<button class="btn btn-primary" ng-click="ok()">Save Device Settings</button>
</div>

View File

@ -17,9 +17,6 @@
<button tooltips="" tooltip-title="Snapshot" tooltip-side="bottom" tooltip-lazy="false" class="btn btn-material-blue-900" ng-click="snapshot()">
<i class="mdi-image-photo-camera"></i>
</button>
<button tooltips="" tooltip-title="Screenshare" tooltip-side="bottom" tooltip-lazy="false" class="btn btn-material-blue-900" ng-click="screenshare()">
<i class="mdi-hardware-desktop-windows"></i>
</button>
<div class="btn-group">
<button tooltips="" tooltip-title="Video Mode" tooltip-side="bottom" tooltip-lazy="false" type="button" class="btn btn-material-blue-900 dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="mdi-action-view-module"></i>
@ -42,6 +39,9 @@
<button tooltips="" tooltip-title="Toggle Fullscreen Mode" tooltip-side="bottom" tooltip-lazy="false" class="btn btn-material-blue-900" ng-click="goFullscreen()">
<i class="" ng-class="{'mdi-navigation-fullscreen': !fullscreenEnabled, 'mdi-navigation-fullscreen-exit': fullscreenEnabled}"></i>
</button>
<button tooltips="" tooltip-title="Screenshare" tooltip-side="bottom" tooltip-lazy="false" class="btn btn-material-blue-900" ng-click="screenshare()">
<i class="mdi-hardware-desktop-windows"></i>
</button>
<button tooltips="" tooltip-title="Open/Close Chat" tooltip-side="right" tooltip-lazy="false" class="btn btn-material-blue-900" ng-click="toggleChat()" ng-show="fullscreenEnabled">
<i class="mdi-communication-chat"></i>
</button>

View File

@ -4,9 +4,8 @@
.module('storageService')
.service('storage', ['$rootScope', '$localStorage',
function($rootScope, $localStorage) {
var data = $localStorage;
data.$default({
var data = $localStorage,
defaultSettings = {
ui_connected: false,
ws_connected: false,
cur_call: 0,
@ -36,7 +35,9 @@
googNoiseSuppression: true,
googHighpassFilter: true,
googEchoCancellation: true
});
};
data.$default(defaultSettings);
function changeData(verto_data) {
jQuery.extend(true, data, verto_data);
@ -51,6 +52,9 @@
data.cur_call = 0;
data.userStatus = 'disconnected';
},
factoryReset: function() {
data.$reset(defaultSettings);
},
};
}
]);

View File

@ -13,6 +13,7 @@
'cgPrompt',
'720kb.tooltips',
'ui.gravatar',
'directive.g+signin',
]);
vertoApp.config(['$routeProvider', 'gravatarServiceProvider',
@ -33,11 +34,6 @@
templateUrl: 'partials/incall.html',
controller: 'InCallController'
}).
/*when('/contributors', {
title: 'Contributors',
templateUrl: 'partials/contributors.html',
controller: 'ContributorsController',
}).*/
when('/browser-upgrade', {
title: '',
templateUrl: 'partials/browser_upgrade.html',

View File

@ -32,6 +32,17 @@
*/
if ($location.search().autocall) {
$rootScope.dialpadNumber = $location.search().autocall;
delete $location.search().autocall;
call($rootScope.dialpadNumber);
}
/**
* fill in dialpad via config.json
*/
if ('autocall' in verto.data) {
$rootScope.dialpadNumber = verto.data.autocall;
delete verto.data.autocall;
call($rootScope.dialpadNumber);
}
/**
@ -49,10 +60,7 @@
verto.data.call.transfer($rootScope.dialpadNumber);
};
/**
* Call to the number in the $rootScope.dialpadNumber.
*/
$rootScope.call = function(extension) {
function call(extension) {
storage.data.onHold = false;
storage.data.cur_call = 0;
$rootScope.dialpadNumber = extension;
@ -79,6 +87,13 @@
CallHistory.add($rootScope.dialpadNumber, 'outbound');
$location.path('/incall');
}
/**
* Call to the number in the $rootScope.dialpadNumber.
*/
$rootScope.call = function(extension) {
return call(extension);
}
}
]);

View File

@ -21,6 +21,14 @@
$scope.callTemplate = 'partials/video_call.html';
}
$rootScope.$on('call.conference', function(event, data) {
$timeout(function() {
if($scope.chatStatus) {
$scope.openChat();
}
});
});
$rootScope.$on('call.video', function(event, data) {
$timeout(function() {
$scope.callTemplate = 'partials/video_call.html';

View File

@ -3,23 +3,58 @@
angular
.module('vertoControllers')
.controller('LoginController', ['$scope', '$http', '$location',
'verto',
.controller('LoginController', ['$scope', '$http', '$location', 'verto',
function($scope, $http, $location, verto) {
$scope.checkBrowser();
/**
* using stored data (localStorage) for logon
/*
* Load the Configs before logging in
* with cache buster
*/
verto.data.name = $scope.storage.data.name;
verto.data.email = $scope.storage.data.email;
if ($scope.storage.data.login != '' && $scope.storage.data.password != '') {
$http.get(window.location.pathname + '/config.json?cachebuster=' + Math.floor((Math.random()*1000000)+1))
.success(function(data) {
/* save these for later as we're about to possibly over write them */
var name = verto.data.name;
var email = verto.data.email;
console.debug("googlelogin: " + data.googlelogin);
if (data.googlelogin){
$scope.googlelogin = data.googlelogin;
$scope.googleclientid = data.googleclientid;
}
angular.extend(verto.data, data);
/**
* use stored data (localStorage) for login, allow config.json to take precedence
*/
if (name != '' && data.name == '') {
verto.data.name = name;
}
if (email != '' && data.email == '') {
verto.data.email = email;
}
if (verto.data.login == '' && verto.data.password == '' && $scope.storage.data.login != '' && $scope.storage.data.password != '') {
verto.data.login = $scope.storage.data.login;
verto.data.password = $scope.storage.data.password;
}
if (verto.data.autologin == "true" && !verto.data.autologin_done) {
console.debug("auto login per config.json");
verto.data.autologin_done = true;
$scope.login();
}
});
verto.data.name = $scope.storage.data.name;
verto.data.email = $scope.storage.data.email;
console.debug('Executing LoginController.');
}
]);
})();

View File

@ -12,7 +12,7 @@
$scope.verto = verto;
$scope.storage = storage;
$scope.call_history = angular.element("#call_history").hasClass('active');
$scope.chatStatus = angular.element('#wrapper').hasClass('toggled');
$rootScope.chatStatus = angular.element('#wrapper').hasClass('toggled');
/**
* (explanation) scope in another controller extends rootScope (singleton)
@ -83,11 +83,15 @@
* Logout the user from verto server and
* redirects him to login page.
*/
$scope.logout = function() {
$rootScope.logout = function() {
var disconnect = function() {
var disconnectCallback = function(v, connected) {
console.debug('Redirecting to login page.');
storage.reset();
if (typeof gapi !== 'undefined'){
console.debug(gapi);
gapi.auth.signOut();
}
$location.path('/login');
};
@ -202,20 +206,20 @@
};
$scope.toggleChat = function() {
if ($scope.chatStatus && $rootScope.activePane === 'chat') {
if ($rootScope.chatStatus && $rootScope.activePane === 'chat') {
$rootScope.chat_counter = 0;
}
angular.element('#wrapper').toggleClass('toggled');
$scope.chatStatus = angular.element('#wrapper').hasClass('toggled');
$rootScope.chatStatus = angular.element('#wrapper').hasClass('toggled');
};
$scope.openChat = function() {
$scope.chatStatus = false;
$rootScope.openChat = function() {
$rootScope.chatStatus = false;
angular.element('#wrapper').removeClass('toggled');
};
$scope.closeChat = function() {
$scope.chatStatus = true;
$rootScope.chatStatus = true;
angular.element('#wrapper').addClass('toggled');
};
@ -240,11 +244,9 @@
Fullscreen.cancel();
}
console.log($scope.chatStatus);
if (!$scope.chatStatus) {
if (!$rootScope.chatStatus) {
angular.element('#wrapper').toggleClass('toggled');
$scope.chatStatus = angular.element('#wrapper').hasClass('toggled');
$rootScope.chatStatus = angular.element('#wrapper').hasClass('toggled');
}
$rootScope.dialpadNumber = '';
@ -277,6 +279,40 @@
});
$scope.$on('event:google-plus-signin-success', function (event,authResult) {
// Send login to server or save into cookie
console.log('Google+ Login Success');
console.log(authResult);
gapi.client.load('plus', 'v1', gapiClientLoaded);
});
function gapiClientLoaded() {
gapi.client.plus.people.get({userId: 'me'}).execute(handleEmailResponse);
}
function handleEmailResponse(resp){
var primaryEmail;
for (var i=0; i < resp.emails.length; i++) {
if (resp.emails[i].type === 'account') primaryEmail = resp.emails[i].value;
}
console.debug("Primary Email: " + primaryEmail );
console.debug("display name: " + resp.displayName);
console.debug("imageurl: " + resp.image.url);
console.debug(resp);
console.debug(verto.data);
verto.data.email = primaryEmail;
verto.data.name = resp.displayName;
storage.data.name = verto.data.name;
storage.data.email = verto.data.email;
$scope.login();
}
$scope.$on('event:google-plus-signin-failure', function (event,authResult) {
// Auth failure or signout detected
console.log('Google+ Login Failure');
});
$rootScope.callActive = function(data) {
verto.data.mutedMic = storage.data.mutedMic;
verto.data.mutedVideo = storage.data.mutedVideo;
@ -355,7 +391,9 @@
//};
//
//verto.hangup(hangupCallback);
if (verto.data.shareCall) {
verto.screenshareHangup();
}
verto.hangup();
};

View File

@ -24,7 +24,16 @@
$scope.refreshDeviceList = function() {
return verto.refreshDevices();
}
};
$scope.resetSettings = function() {
if (confirm('Factory Reset Settings?')) {
storage.factoryReset();
$scope.logout();
$scope.ok();
window.location.reload();
};
};
}
]);

View File

@ -199,13 +199,20 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
bandwidth: bandwidth,
refreshDevicesCallback : function refreshDevicesCallback() {
data.videoDevices = [];
data.videoDevices = [{
id: 'none',
label: 'No Camera'
}];
data.shareDevices = [{
id: 'screen',
label: 'Screen'
}];
data.audioDevices = [];
if(!storage.data.selectedShare) {
storage.data.selectedShare = data.shareDevices[0]['id'];
}
for (var i in jQuery.verto.videoDevices) {
var device = jQuery.verto.videoDevices[i];
if (!device.label) {
@ -328,6 +335,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
function startConference(v, dialog, pvtData) {
$rootScope.$emit('call.video', 'video');
$rootScope.$emit('call.conference', 'conference');
data.chattingWith = pvtData.chatID;
data.confRole = pvtData.role;
@ -413,6 +421,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
function stopConference() {
console.log('stopConference()');
if (data.liveArray) {
data.liveArray.destroy();
console.log('Has data.liveArray.');
$rootScope.$emit('members.clear');
data.liveArray = null;
@ -503,6 +512,10 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
if (d.params.screenShare) {
cleanShareCall(that);
} else {
if (data.liveArray) {
data.liveArray.destroy();
}
if (data.conf) {
data.conf.destroy();
}

View File

@ -1,5 +1,5 @@
var iceTimerSent=0;var iceTimerCompleted=0;var iceTimer;(function($){function findLine(sdpLines,prefix,substr){return findLineInRange(sdpLines,0,-1,prefix,substr);}
(function($){function findLine(sdpLines,prefix,substr){return findLineInRange(sdpLines,0,-1,prefix,substr);}
function findLineInRange(sdpLines,startLine,endLine,prefix,substr){var realEndLine=(endLine!=-1)?endLine:sdpLines.length;for(var i=startLine;i<realEndLine;++i){if(sdpLines[i].indexOf(prefix)===0){if(!substr||sdpLines[i].toLowerCase().indexOf(substr.toLowerCase())!==-1){return i;}}}
return null;}
function getCodecPayloadType(sdpLine){var pattern=new RegExp('a=rtpmap:(\\d+) \\w+\\/\\d+');var result=sdpLine.match(pattern);return(result&&result.length==2)?result[1]:null;}
@ -10,8 +10,9 @@ $.FSRTC=function(options){this.options=$.extend({useVideo:null,useStereo:false,u
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,7 +28,8 @@ 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']='';}}
$.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){self.localStream.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();}
@ -43,19 +45,22 @@ if(obj.options.useVideo&&obj.options.localVideo){getUserMedia({constraints:{audi
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 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=null;useVideo=null;}
if(bestFrameRate&&!window.moz){video.optional.push({minFrameRate:bestFrameRate});}}else{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 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);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;}
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}];}
var peer=new PeerConnection(iceServers,optional);openOffererChannel();var x=0;peer.onicecandidate=function(event){if(event.candidate){options.onICE(event.candidate);clearTimeout(iceTimer);iceTimer=setTimeout(function(){iceTimerSent=1;if(iceTimerCompleted==0){if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}},1000);}else{if(iceTimerSent==0){clearTimeout(iceTimer);iceTimerCompleted=1;if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
var peer=new PeerConnection(iceServers,optional);openOffererChannel();var x=0;function ice_handler(){done=true;gathering=null;if(options.onICEComplete){options.onICEComplete();}
if(options.type=="offer"){if((!moz||(!options.sentICESDP&&peer.localDescription.sdp.match(/a=candidate/))&&!x&&options.onICESDP)){options.onICESDP(peer.localDescription);}}else{if(!x&&options.onICESDP){options.onICESDP(peer.localDescription);}}}
peer.onicecandidate=function(event){if(done){return;}
if(!gathering){gathering=setTimeout(ice_handler,1000);}
if(event){if(event.candidate){options.onICE(event.candidate);}}else{done=true;if(gathering){clearTimeout(gathering);gathering=null;}
ice_handler();}};if(options.attachStream)peer.addStream(options.attachStream);if(options.attachStreams&&options.attachStream.length){var streams=options.attachStreams;for(var i=0;i<streams.length;i++){peer.addStream(streams[i]);}}
peer.onaddstream=function(event){var remoteMediaStream=event.stream;remoteMediaStream.onended=function(){if(options.onRemoteStreamEnded)options.onRemoteStreamEnded(remoteMediaStream);};if(options.onRemoteStream)options.onRemoteStream(remoteMediaStream);};var constraints=options.constraints||{offerToReceiveAudio:true,offerToReceiveVideo:true};function createOffer(){if(!options.onOfferSDP)return;peer.createOffer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);options.onOfferSDP(sessionDescription);if(moz&&options.onICESDP&&sessionDescription.sdp.match(/a=candidate/)){options.onICESDP(sessionDescription);options.sentICESDP=1;}},onSdpError,constraints);}
function createAnswer(){if(options.type!="answer")return;peer.setRemoteDescription(new SessionDescription(options.offerSDP),onSdpSuccess,onSdpError);peer.createAnswer(function(sessionDescription){sessionDescription.sdp=serializeSdp(sessionDescription.sdp);peer.setLocalDescription(sessionDescription);if(options.onAnswerSDP){options.onAnswerSDP(sessionDescription);}},onSdpError,constraints);}
if((options.onChannelMessage&&!moz)||!options.onChannelMessage){createOffer();createAnswer();}
@ -88,7 +93,8 @@ getUserMedia({constraints:{audio:ttl++==0,video:video},onsuccess:function(e){e.s
$.FSRTC.getValidRes=function(cam,func){var used=[];var cached=localStorage.getItem("res_"+cam);if(cached){var cache=$.parseJSON(cached);if(cache){$.FSRTC.validRes=cache.validRes;console.log("CACHED RES FOR CAM "+cam,cache);}else{console.error("INVALID CACHE");}
return func?func(cache):null;}
$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
$.FSRTC.checkPerms=function(runtime){getUserMedia({constraints:{audio:true,video:true,},onsuccess:function(e){e.stop();console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true)}},onerror:function(e){console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
$.FSRTC.checkPerms=function(runtime,check_audio,check_video){getUserMedia({constraints:{audio:check_audio,video:check_video,},onsuccess:function(e){e.stop();console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true)}},onerror:function(e){if(check_video&&check_audio){console.error("error, retesting with audio params only");return $.FSRTC.checkPerms(runtime,check_audio,false);}
console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
if(this.options.sessid){params.sessid=this.options.sessid;}
var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
@ -234,7 +240,7 @@ 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.videoStream,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;}
@ -245,7 +251,7 @@ 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);}
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: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);}
@ -270,6 +276,6 @@ dialog.gotEarly=true;dialog.rtc.answer(params.sdp,function(){console.log("Dialog
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(err.name+": "+error.message);runtime();});}};$.verto.refreshDevices=function(runtime){checkDevices(runtime);}
$.verto.init=function(obj,runtime){$.FSRTC.checkPerms(function(){checkDevices(runtime);});}
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.genUUID=function(){return generateGUID();}})(jQuery);

View File

@ -204,7 +204,7 @@ static const char *parse_string(cJSON *item,const char *str)
break;
default: *ptr2++=*ptr; break;
}
ptr++;
if (*ptr) ptr++;
}
}
*ptr2=0;

View File

@ -20,7 +20,15 @@ $(MYLIB): $(OBJS) $(HEADERS) $(SRC)
ranlib $(MYLIB)
%.o: %.c $(HEADERS)
$(CC) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
$(CC) $(CC_CFLAGS) $(CFLAGS) $(CXFLAGS) -c $< -o $@
clean:
test-clean:
rm -f test/testpools
clean: test-clean
rm -f *.o src/*.o libks.a *~ src/*~ src/include/*~
test/testpools: $(MYLIB) test/testpools.c
$(CC) $(CXFLAGS) test/testpools.c -Isrc/include/ libks.a -o test/testpools
test-all: test/testpools

14
libs/libks/libks.props Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>SIMCLIST_NO_DUMPRESTORE;_CRT_SECURE_NO_WARNINGS;KS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)\src\include;$(ProjectDir)\src\win\sys;$(ProjectDir)\src\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4574;4100;4127;4668;4255;4706;4710;4820</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

41
libs/libks/libks.sln Normal file
View File

@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libks", "libks.vcxproj", "{70D178D8-1100-4152-86C0-809A91CFF832}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpools", "test\testpools\testpools.vcxproj", "{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}"
ProjectSection(ProjectDependencies) = postProject
{70D178D8-1100-4152-86C0-809A91CFF832} = {70D178D8-1100-4152-86C0-809A91CFF832}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x64.ActiveCfg = Debug|x64
{70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x64.Build.0 = Debug|x64
{70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x86.ActiveCfg = Debug|Win32
{70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x86.Build.0 = Debug|Win32
{70D178D8-1100-4152-86C0-809A91CFF832}.Release|x64.ActiveCfg = Release|x64
{70D178D8-1100-4152-86C0-809A91CFF832}.Release|x64.Build.0 = Release|x64
{70D178D8-1100-4152-86C0-809A91CFF832}.Release|x86.ActiveCfg = Release|Win32
{70D178D8-1100-4152-86C0-809A91CFF832}.Release|x86.Build.0 = Release|Win32
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Debug|x64.ActiveCfg = Debug|x64
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Debug|x64.Build.0 = Debug|x64
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Debug|x86.ActiveCfg = Debug|Win32
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Debug|x86.Build.0 = Debug|Win32
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Release|x64.ActiveCfg = Release|x64
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Release|x64.Build.0 = Release|x64
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Release|x86.ActiveCfg = Release|Win32
{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

156
libs/libks/libks.vcxproj Normal file
View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{70D178D8-1100-4152-86C0-809A91CFF832}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libks.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libks.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libks.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libks.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>EnableAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>EnableAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>EnableAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>EnableAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\ks.c" />
<ClCompile Include="src\ks_buffer.c" />
<ClCompile Include="src\ks_config.c" />
<ClCompile Include="src\ks_json.c" />
<ClCompile Include="src\ks_threadmutex.c" />
<ClCompile Include="src\mpool.c" />
<ClCompile Include="src\simclist.c" />
<ClCompile Include="src\table.c" />
<ClCompile Include="src\table_util.c" />
<ClCompile Include="src\win\mman.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\include\cc.h" />
<ClInclude Include="src\include\ks.h" />
<ClInclude Include="src\include\ks_buffer.h" />
<ClInclude Include="src\include\ks_config.h" />
<ClInclude Include="src\include\ks_json.h" />
<ClInclude Include="src\include\ks_platform.h" />
<ClInclude Include="src\include\ks_threadmutex.h" />
<ClInclude Include="src\include\ks_types.h" />
<ClInclude Include="src\include\mpool.h" />
<ClInclude Include="src\include\mpool_loc.h" />
<ClInclude Include="src\include\simclist.h" />
<ClInclude Include="src\include\table.h" />
<ClInclude Include="src\include\table_loc.h" />
<ClInclude Include="src\win\mman.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\ks.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ks_buffer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ks_config.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ks_json.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ks_threadmutex.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\mpool.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\simclist.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\table.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\table_util.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\win\mman.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\include\cc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_buffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_json.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_threadmutex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\mpool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\mpool_loc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\simclist.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\table.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\table_loc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\win\mman.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\include\ks_platform.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -35,6 +35,7 @@
#define _KS_H_
#include <stdarg.h>
#include <ks_types.h>
#ifdef __cplusplus
extern "C" {
@ -42,160 +43,8 @@ extern "C" {
#define ks_copy_string(_x, _y, _z) strncpy(_x, _y, _z - 1)
#define ks_set_string(_x, _y) ks_copy_string(_x, _y, sizeof(_x))
#define KS_VA_NONE "%s", ""
typedef enum {
KS_POLL_READ = (1 << 0),
KS_POLL_WRITE = (1 << 1),
KS_POLL_ERROR = (1 << 2)
} ks_poll_t;
#ifdef WIN32
#define KS_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
#define KS_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
#define KS_SEQ_BRED FOREGROUND_RED
#define KS_SEQ_FMAGEN FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY
#define KS_SEQ_BMAGEN FOREGROUND_BLUE | FOREGROUND_RED
#define KS_SEQ_FCYAN FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BCYAN FOREGROUND_GREEN | FOREGROUND_BLUE
#define KS_SEQ_FGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define KS_SEQ_BGREEN FOREGROUND_GREEN
#define KS_SEQ_FYELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define KS_SEQ_BYELLOW FOREGROUND_RED | FOREGROUND_GREEN
#define KS_SEQ_DEFAULT_COLOR KS_SEQ_FWHITE
#define KS_SEQ_FBLUE FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BBLUE FOREGROUND_BLUE
#define KS_SEQ_FBLACK 0 | FOREGROUND_INTENSITY
#define KS_SEQ_BBLACK 0
#else
#define KS_SEQ_ESC "\033["
/* Ansi Control character suffixes */
#define KS_SEQ_HOME_CHAR 'H'
#define KS_SEQ_HOME_CHAR_STR "H"
#define KS_SEQ_CLEARLINE_CHAR '1'
#define KS_SEQ_CLEARLINE_CHAR_STR "1"
#define KS_SEQ_CLEARLINEEND_CHAR "K"
#define KS_SEQ_CLEARSCR_CHAR0 '2'
#define KS_SEQ_CLEARSCR_CHAR1 'J'
#define KS_SEQ_CLEARSCR_CHAR "2J"
#define KS_SEQ_DEFAULT_COLOR KS_SEQ_ESC KS_SEQ_END_COLOR /* Reset to Default fg/bg color */
#define KS_SEQ_AND_COLOR ";" /* To add multiple color definitions */
#define KS_SEQ_END_COLOR "m" /* To end color definitions */
/* Foreground colors values */
#define KS_SEQ_F_BLACK "30"
#define KS_SEQ_F_RED "31"
#define KS_SEQ_F_GREEN "32"
#define KS_SEQ_F_YELLOW "33"
#define KS_SEQ_F_BLUE "34"
#define KS_SEQ_F_MAGEN "35"
#define KS_SEQ_F_CYAN "36"
#define KS_SEQ_F_WHITE "37"
/* Background colors values */
#define KS_SEQ_B_BLACK "40"
#define KS_SEQ_B_RED "41"
#define KS_SEQ_B_GREEN "42"
#define KS_SEQ_B_YELLOW "43"
#define KS_SEQ_B_BLUE "44"
#define KS_SEQ_B_MAGEN "45"
#define KS_SEQ_B_CYAN "46"
#define KS_SEQ_B_WHITE "47"
/* Preset escape sequences - Change foreground colors only */
#define KS_SEQ_FBLACK KS_SEQ_ESC KS_SEQ_F_BLACK KS_SEQ_END_COLOR
#define KS_SEQ_FRED KS_SEQ_ESC KS_SEQ_F_RED KS_SEQ_END_COLOR
#define KS_SEQ_FGREEN KS_SEQ_ESC KS_SEQ_F_GREEN KS_SEQ_END_COLOR
#define KS_SEQ_FYELLOW KS_SEQ_ESC KS_SEQ_F_YELLOW KS_SEQ_END_COLOR
#define KS_SEQ_FBLUE KS_SEQ_ESC KS_SEQ_F_BLUE KS_SEQ_END_COLOR
#define KS_SEQ_FMAGEN KS_SEQ_ESC KS_SEQ_F_MAGEN KS_SEQ_END_COLOR
#define KS_SEQ_FCYAN KS_SEQ_ESC KS_SEQ_F_CYAN KS_SEQ_END_COLOR
#define KS_SEQ_FWHITE KS_SEQ_ESC KS_SEQ_F_WHITE KS_SEQ_END_COLOR
#define KS_SEQ_BBLACK KS_SEQ_ESC KS_SEQ_B_BLACK KS_SEQ_END_COLOR
#define KS_SEQ_BRED KS_SEQ_ESC KS_SEQ_B_RED KS_SEQ_END_COLOR
#define KS_SEQ_BGREEN KS_SEQ_ESC KS_SEQ_B_GREEN KS_SEQ_END_COLOR
#define KS_SEQ_BYELLOW KS_SEQ_ESC KS_SEQ_B_YELLOW KS_SEQ_END_COLOR
#define KS_SEQ_BBLUE KS_SEQ_ESC KS_SEQ_B_BLUE KS_SEQ_END_COLOR
#define KS_SEQ_BMAGEN KS_SEQ_ESC KS_SEQ_B_MAGEN KS_SEQ_END_COLOR
#define KS_SEQ_BCYAN KS_SEQ_ESC KS_SEQ_B_CYAN KS_SEQ_END_COLOR
#define KS_SEQ_BWHITE KS_SEQ_ESC KS_SEQ_B_WHITE KS_SEQ_END_COLOR
/* Preset escape sequences */
#define KS_SEQ_HOME KS_SEQ_ESC KS_SEQ_HOME_CHAR_STR
#define KS_SEQ_CLEARLINE KS_SEQ_ESC KS_SEQ_CLEARLINE_CHAR_STR
#define KS_SEQ_CLEARLINEEND KS_SEQ_ESC KS_SEQ_CLEARLINEEND_CHAR
#define KS_SEQ_CLEARSCR KS_SEQ_ESC KS_SEQ_CLEARSCR_CHAR KS_SEQ_HOME
#endif
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#define _XOPEN_SOURCE 600
#endif
#ifndef HAVE_STRINGS_H
#define HAVE_STRINGS_H 1
#endif
#ifndef HAVE_SYS_SOCKET_H
#define HAVE_SYS_SOCKET_H 1
#endif
#ifndef __WINDOWS__
#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
#define __WINDOWS__
#endif
#endif
#ifdef _MSC_VER
#ifndef __inline__
#define __inline__ __inline
#endif
#if (_MSC_VER >= 1400) /* VC8+ */
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#endif
#ifndef strcasecmp
#define strcasecmp(s1, s2) _stricmp(s1, s2)
#endif
#ifndef strncasecmp
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
#endif
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
#endif
#ifndef S_IWUSR
#define S_IWUSR _S_IWRITE
#endif
#undef HAVE_STRINGS_H
#undef HAVE_SYS_SOCKET_H
#endif
#include <time.h>
#ifndef WIN32
#include <sys/time.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <sys/types.h>
#include <sys/select.h>
#include <netinet/tcp.h>
#include <sys/signal.h>
#include <unistd.h>
#include <ctype.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <assert.h>
#if (_MSC_VER >= 1400) // VC8+
#define ks_assert(expr) assert(expr);__analysis_assume( expr )
#endif
@ -209,66 +58,9 @@ typedef enum {
#define ks_strlen_zero_buf(s) (*(s) == '\0')
#define end_of(_s) *(*_s == '\0' ? _s : _s + strlen(_s) - 1)
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
typedef SOCKET ks_socket_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef __int8 int8_t;
typedef intptr_t ks_ssize_t;
typedef int ks_filehandle_t;
#define KS_SOCK_INVALID INVALID_SOCKET
#define strerror_r(num, buf, size) strerror_s(buf, size, num)
#if defined(KS_DECLARE_STATIC)
#define KS_DECLARE(type) type __stdcall
#define KS_DECLARE_NONSTD(type) type __cdecl
#define KS_DECLARE_DATA
#elif defined(KS_EXPORTS)
#define KS_DECLARE(type) __declspec(dllexport) type __stdcall
#define KS_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define KS_DECLARE_DATA __declspec(dllexport)
#else
#define KS_DECLARE(type) __declspec(dllimport) type __stdcall
#define KS_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define KS_DECLARE_DATA __declspec(dllimport)
#endif
#else
#define KS_DECLARE(type) type
#define KS_DECLARE_NONSTD(type) type
#define KS_DECLARE_DATA
#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define KS_SOCK_INVALID -1
typedef int ks_socket_t;
typedef ssize_t ks_ssize_t;
typedef int ks_filehandle_t;
#endif
#include "math.h"
#include "ks_json.h"
typedef int16_t ks_port_t;
typedef size_t ks_size_t;
typedef enum {
KS_SUCCESS,
KS_FAIL,
KS_BREAK,
KS_DISCONNECTED,
KS_GENERR
} ks_status_t;
#define BUF_CHUNK 65536 * 50
#define BUF_START 65536 * 100
@ -279,37 +71,6 @@ typedef enum {
#define ks_set_flag(obj, flag) (obj)->flags |= (flag)
#define ks_clear_flag(obj, flag) (obj)->flags &= ~(flag)
/*! \brief Used internally for truth test */
typedef enum {
KS_TRUE = 1,
KS_FALSE = 0
} ks_bool_t;
#ifndef __FUNCTION__
#define __FUNCTION__ (const char *)__func__
#endif
#define KS_PRE __FILE__, __FUNCTION__, __LINE__
#define KS_LOG_LEVEL_DEBUG 7
#define KS_LOG_LEVEL_INFO 6
#define KS_LOG_LEVEL_NOTICE 5
#define KS_LOG_LEVEL_WARNING 4
#define KS_LOG_LEVEL_ERROR 3
#define KS_LOG_LEVEL_CRIT 2
#define KS_LOG_LEVEL_ALERT 1
#define KS_LOG_LEVEL_EMERG 0
#define KS_LOG_DEBUG KS_PRE, KS_LOG_LEVEL_DEBUG
#define KS_LOG_INFO KS_PRE, KS_LOG_LEVEL_INFO
#define KS_LOG_NOTICE KS_PRE, KS_LOG_LEVEL_NOTICE
#define KS_LOG_WARNING KS_PRE, KS_LOG_LEVEL_WARNING
#define KS_LOG_ERROR KS_PRE, KS_LOG_LEVEL_ERROR
#define KS_LOG_CRIT KS_PRE, KS_LOG_LEVEL_CRIT
#define KS_LOG_ALERT KS_PRE, KS_LOG_LEVEL_ALERT
#define KS_LOG_EMERG KS_PRE, KS_LOG_LEVEL_EMERG
typedef void (*ks_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
typedef void (*ks_listen_callback_t)(ks_socket_t server_sock, ks_socket_t client_sock, struct sockaddr_in *addr);
KS_DECLARE(int) ks_vasprintf(char **ret, const char *fmt, va_list ap);

View File

@ -0,0 +1,179 @@
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KS_PLATFORM_H_
#define _KS_PLATFORM_H_
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif /* defined(__cplusplus) */
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#define _XOPEN_SOURCE 600
#endif
#ifndef HAVE_STRINGS_H
#define HAVE_STRINGS_H 1
#endif
#ifndef HAVE_SYS_SOCKET_H
#define HAVE_SYS_SOCKET_H 1
#endif
#ifndef __WINDOWS__
#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
#define __WINDOWS__
#endif
#endif
#ifdef _MSC_VER
#ifndef __inline__
#define __inline__ __inline
#endif
#if (_MSC_VER >= 1400) /* VC8+ */
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#endif
#ifndef strcasecmp
#define strcasecmp(s1, s2) _stricmp(s1, s2)
#endif
#ifndef strncasecmp
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
#endif
#if (_MSC_VER < 1900) /* VC 2015 */
#ifndef snprintf
#define snprintf _snprintf
#endif
#endif
#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
#endif
#ifndef S_IWUSR
#define S_IWUSR _S_IWRITE
#endif
#undef HAVE_STRINGS_H
#undef HAVE_SYS_SOCKET_H
#endif
#include <time.h>
#ifndef WIN32
#include <sys/time.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <sys/types.h>
#include <sys/select.h>
#include <netinet/tcp.h>
#include <sys/signal.h>
#include <unistd.h>
#include <ctype.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <assert.h>
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
typedef SOCKET ks_socket_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef __int8 int8_t;
typedef intptr_t ks_ssize_t;
typedef int ks_filehandle_t;
#define KS_SOCK_INVALID INVALID_SOCKET
#define strerror_r(num, buf, size) strerror_s(buf, size, num)
#if defined(KS_DECLARE_STATIC)
#define KS_DECLARE(type) type __stdcall
#define KS_DECLARE_NONSTD(type) type __cdecl
#define KS_DECLARE_DATA
#elif defined(KS_EXPORTS)
#define KS_DECLARE(type) __declspec(dllexport) type __stdcall
#define KS_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define KS_DECLARE_DATA __declspec(dllexport)
#else
#define KS_DECLARE(type) __declspec(dllimport) type __stdcall
#define KS_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define KS_DECLARE_DATA __declspec(dllimport)
#endif
#else // !WIN32
#define KS_DECLARE(type) type
#define KS_DECLARE_NONSTD(type) type
#define KS_DECLARE_DATA
#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define KS_SOCK_INVALID -1
typedef int ks_socket_t;
typedef ssize_t ks_ssize_t;
typedef int ks_filehandle_t;
#endif
#ifdef __cplusplus
}
#endif /* defined(__cplusplus) */
#endif /* defined(_KS_PLATFORM_H_) */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KS_TYPES_H_
#define _KS_TYPES_H_
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif /* defined(__cplusplus) */
#include <ks_platform.h>
#define KS_VA_NONE "%s", ""
typedef enum {
KS_POLL_READ = (1 << 0),
KS_POLL_WRITE = (1 << 1),
KS_POLL_ERROR = (1 << 2)
} ks_poll_t;
#ifdef WIN32
#define KS_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
#define KS_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
#define KS_SEQ_BRED FOREGROUND_RED
#define KS_SEQ_FMAGEN FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY
#define KS_SEQ_BMAGEN FOREGROUND_BLUE | FOREGROUND_RED
#define KS_SEQ_FCYAN FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BCYAN FOREGROUND_GREEN | FOREGROUND_BLUE
#define KS_SEQ_FGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define KS_SEQ_BGREEN FOREGROUND_GREEN
#define KS_SEQ_FYELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define KS_SEQ_BYELLOW FOREGROUND_RED | FOREGROUND_GREEN
#define KS_SEQ_DEFAULT_COLOR KS_SEQ_FWHITE
#define KS_SEQ_FBLUE FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define KS_SEQ_BBLUE FOREGROUND_BLUE
#define KS_SEQ_FBLACK 0 | FOREGROUND_INTENSITY
#define KS_SEQ_BBLACK 0
#else
#define KS_SEQ_ESC "\033["
/* Ansi Control character suffixes */
#define KS_SEQ_HOME_CHAR 'H'
#define KS_SEQ_HOME_CHAR_STR "H"
#define KS_SEQ_CLEARLINE_CHAR '1'
#define KS_SEQ_CLEARLINE_CHAR_STR "1"
#define KS_SEQ_CLEARLINEEND_CHAR "K"
#define KS_SEQ_CLEARSCR_CHAR0 '2'
#define KS_SEQ_CLEARSCR_CHAR1 'J'
#define KS_SEQ_CLEARSCR_CHAR "2J"
#define KS_SEQ_DEFAULT_COLOR KS_SEQ_ESC KS_SEQ_END_COLOR /* Reset to Default fg/bg color */
#define KS_SEQ_AND_COLOR ";" /* To add multiple color definitions */
#define KS_SEQ_END_COLOR "m" /* To end color definitions */
/* Foreground colors values */
#define KS_SEQ_F_BLACK "30"
#define KS_SEQ_F_RED "31"
#define KS_SEQ_F_GREEN "32"
#define KS_SEQ_F_YELLOW "33"
#define KS_SEQ_F_BLUE "34"
#define KS_SEQ_F_MAGEN "35"
#define KS_SEQ_F_CYAN "36"
#define KS_SEQ_F_WHITE "37"
/* Background colors values */
#define KS_SEQ_B_BLACK "40"
#define KS_SEQ_B_RED "41"
#define KS_SEQ_B_GREEN "42"
#define KS_SEQ_B_YELLOW "43"
#define KS_SEQ_B_BLUE "44"
#define KS_SEQ_B_MAGEN "45"
#define KS_SEQ_B_CYAN "46"
#define KS_SEQ_B_WHITE "47"
/* Preset escape sequences - Change foreground colors only */
#define KS_SEQ_FBLACK KS_SEQ_ESC KS_SEQ_F_BLACK KS_SEQ_END_COLOR
#define KS_SEQ_FRED KS_SEQ_ESC KS_SEQ_F_RED KS_SEQ_END_COLOR
#define KS_SEQ_FGREEN KS_SEQ_ESC KS_SEQ_F_GREEN KS_SEQ_END_COLOR
#define KS_SEQ_FYELLOW KS_SEQ_ESC KS_SEQ_F_YELLOW KS_SEQ_END_COLOR
#define KS_SEQ_FBLUE KS_SEQ_ESC KS_SEQ_F_BLUE KS_SEQ_END_COLOR
#define KS_SEQ_FMAGEN KS_SEQ_ESC KS_SEQ_F_MAGEN KS_SEQ_END_COLOR
#define KS_SEQ_FCYAN KS_SEQ_ESC KS_SEQ_F_CYAN KS_SEQ_END_COLOR
#define KS_SEQ_FWHITE KS_SEQ_ESC KS_SEQ_F_WHITE KS_SEQ_END_COLOR
#define KS_SEQ_BBLACK KS_SEQ_ESC KS_SEQ_B_BLACK KS_SEQ_END_COLOR
#define KS_SEQ_BRED KS_SEQ_ESC KS_SEQ_B_RED KS_SEQ_END_COLOR
#define KS_SEQ_BGREEN KS_SEQ_ESC KS_SEQ_B_GREEN KS_SEQ_END_COLOR
#define KS_SEQ_BYELLOW KS_SEQ_ESC KS_SEQ_B_YELLOW KS_SEQ_END_COLOR
#define KS_SEQ_BBLUE KS_SEQ_ESC KS_SEQ_B_BLUE KS_SEQ_END_COLOR
#define KS_SEQ_BMAGEN KS_SEQ_ESC KS_SEQ_B_MAGEN KS_SEQ_END_COLOR
#define KS_SEQ_BCYAN KS_SEQ_ESC KS_SEQ_B_CYAN KS_SEQ_END_COLOR
#define KS_SEQ_BWHITE KS_SEQ_ESC KS_SEQ_B_WHITE KS_SEQ_END_COLOR
/* Preset escape sequences */
#define KS_SEQ_HOME KS_SEQ_ESC KS_SEQ_HOME_CHAR_STR
#define KS_SEQ_CLEARLINE KS_SEQ_ESC KS_SEQ_CLEARLINE_CHAR_STR
#define KS_SEQ_CLEARLINEEND KS_SEQ_ESC KS_SEQ_CLEARLINEEND_CHAR
#define KS_SEQ_CLEARSCR KS_SEQ_ESC KS_SEQ_CLEARSCR_CHAR KS_SEQ_HOME
#endif
typedef int16_t ks_port_t;
typedef size_t ks_size_t;
typedef enum {
KS_SUCCESS,
KS_FAIL,
KS_BREAK,
KS_DISCONNECTED,
KS_GENERR
} ks_status_t;
/*! \brief Used internally for truth test */
typedef enum {
KS_TRUE = 1,
KS_FALSE = 0
} ks_bool_t;
#ifndef __FUNCTION__
#define __FUNCTION__ (const char *)__func__
#endif
#define KS_PRE __FILE__, __FUNCTION__, __LINE__
#define KS_LOG_LEVEL_DEBUG 7
#define KS_LOG_LEVEL_INFO 6
#define KS_LOG_LEVEL_NOTICE 5
#define KS_LOG_LEVEL_WARNING 4
#define KS_LOG_LEVEL_ERROR 3
#define KS_LOG_LEVEL_CRIT 2
#define KS_LOG_LEVEL_ALERT 1
#define KS_LOG_LEVEL_EMERG 0
#define KS_LOG_DEBUG KS_PRE, KS_LOG_LEVEL_DEBUG
#define KS_LOG_INFO KS_PRE, KS_LOG_LEVEL_INFO
#define KS_LOG_NOTICE KS_PRE, KS_LOG_LEVEL_NOTICE
#define KS_LOG_WARNING KS_PRE, KS_LOG_LEVEL_WARNING
#define KS_LOG_ERROR KS_PRE, KS_LOG_LEVEL_ERROR
#define KS_LOG_CRIT KS_PRE, KS_LOG_LEVEL_CRIT
#define KS_LOG_ALERT KS_PRE, KS_LOG_LEVEL_ALERT
#define KS_LOG_EMERG KS_PRE, KS_LOG_LEVEL_EMERG
typedef void (*ks_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
typedef void (*ks_listen_callback_t)(ks_socket_t server_sock, ks_socket_t client_sock, struct sockaddr_in *addr);
#ifdef __cplusplus
}
#endif /* defined(__cplusplus) */
#endif /* defined(_KS_TYPES_H_) */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -24,6 +24,7 @@
#ifndef __MPOOL_H__
#define __MPOOL_H__
#include "ks.h"
#include <sys/types.h>
/*
@ -61,10 +62,9 @@
#define MPOOL_FLAG_HEAVY_PACKING (1<<2)
/*
* Use sbrk not mmap to allocate pages. This is not recommended for
* normal use.
* Use MMAP_ANONYMOUS instead of /dev/zero
*/
#define MPOOL_FLAG_USE_SBRK (1<<3)
#define MPOOL_FLAG_ANONYMOUS (1<<3)
/*
* Mpool error codes
@ -86,7 +86,7 @@
#define MPOOL_ERROR_IS_FREE 15 /* memory block already free */
#define MPOOL_ERROR_BLOCK_STAT 16 /* invalid internal block status */
#define MPOOL_ERROR_FREE_ADDR 17 /* invalid internal free address */
#define MPOOL_ERROR_SBRK_CONTIG 18 /* sbrk did not return contiguous mem*/
#define MPOOL_ERROR_UNUSED 18 /* UNUSED */
#define MPOOL_ERROR_NO_PAGES 19 /* ran out of pages in pool */
#define MPOOL_ERROR_ALLOC 20 /* calloc,malloc,free,realloc failed */
#define MPOOL_ERROR_PNT_OVER 21 /* pointer structure was overwritten */
@ -181,8 +181,7 @@ typedef void mpool_t;
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
extern
mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
KS_DECLARE(mpool_t *) mpool_open(const unsigned int flags, const unsigned int page_size,
void *start_addr, int *error_p);
/*
@ -203,8 +202,7 @@ mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
*
* mp_p <-> Pointer to our memory pool.
*/
extern
int mpool_close(mpool_t *mp_p);
KS_DECLARE(int) mpool_close(mpool_t *mp_p);
/*
* int mpool_clear
@ -223,8 +221,7 @@ int mpool_close(mpool_t *mp_p);
*
* mp_p <-> Pointer to our memory pool.
*/
extern
int mpool_clear(mpool_t *mp_p);
KS_DECLARE(int) mpool_clear(mpool_t *mp_p);
/*
* void *mpool_alloc
@ -249,8 +246,7 @@ int mpool_clear(mpool_t *mp_p);
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
extern
void *mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
KS_DECLARE(void *) mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
int *error_p);
/*
@ -279,8 +275,7 @@ void *mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
extern
void *mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
KS_DECLARE(void *)mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
const unsigned long ele_size, int *error_p);
/*
@ -305,8 +300,8 @@ void *mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
*
* size -> Size of the address being freed.
*/
extern
int mpool_free(mpool_t *mp_p, void *addr, const unsigned long size);
KS_DECLARE(int) mpool_free(mpool_t *mp_p, void *addr, const unsigned long size);
/*
* void *mpool_resize
@ -339,8 +334,7 @@ int mpool_free(mpool_t *mp_p, void *addr, const unsigned long size);
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
extern
void *mpool_resize(mpool_t *mp_p, void *old_addr,
KS_DECLARE(void *) mpool_resize(mpool_t *mp_p, void *old_addr,
const unsigned long old_byte_size,
const unsigned long new_byte_size,
int *error_p);
@ -379,8 +373,7 @@ void *mpool_resize(mpool_t *mp_p, void *old_addr,
* will be set to the total amount of space (including administrative
* overhead) used by the pool.
*/
extern
int mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
KS_DECLARE(int) mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
unsigned long *num_alloced_p,
unsigned long *user_alloced_p,
unsigned long *max_alloced_p,
@ -407,8 +400,7 @@ int mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
* log_func -> Log function (defined in mpool.h) which will be called
* with each mpool transaction.
*/
extern
int mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func);
KS_DECLARE(int) mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func);
/*
* int mpool_set_max_pages
@ -435,8 +427,7 @@ int mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func);
*
* max_pages -> Maximum number of pages used by the library.
*/
extern
int mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages);
KS_DECLARE(int) mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages);
/*
* const char *mpool_strerror
@ -455,9 +446,19 @@ int mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages);
*
* error -> Error number that we are converting.
*/
extern
const char *mpool_strerror(const int error);
KS_DECLARE(const char *) mpool_strerror(const int error);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#endif /* ! __MPOOL_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -73,6 +73,7 @@
typedef struct {
unsigned int mp_magic; /* magic number for struct */
unsigned int mp_flags; /* flags for the struct */
unsigned int mp_mmflags; /* flags for mmap */
unsigned long mp_alloc_c; /* number of allocations */
unsigned long mp_user_alloc; /* user bytes allocated */
unsigned long mp_max_alloc; /* maximum user bytes allocated */
@ -114,3 +115,14 @@ typedef struct {
} mpool_free_t;
#endif /* ! __MPOOL_LOC_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -40,7 +40,7 @@ extern "C" {
#endif
/* Be friend of both C90 and C99 compilers */
/* Be friend of both C90 and C99 compilers */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* "inline" and "restrict" are keywords */
#else
@ -49,15 +49,15 @@ extern "C" {
#endif
/**
/**
* Type representing list hashes.
*
* This is a signed integer value.
*/
typedef int32_t list_hash_t;
typedef int32_t list_hash_t;
#ifndef SIMCLIST_NO_DUMPRESTORE
typedef struct {
typedef struct {
uint16_t version; /* dump version */
struct timeval timestamp; /* when the list has been dumped, seconds since UNIX epoch */
uint32_t list_size;
@ -65,10 +65,10 @@ typedef struct {
list_hash_t list_hash; /* hash of the list when dumped, or 0 if invalid */
uint32_t dumpsize;
int consistent; /* 1 if the dump is verified complete/consistent; 0 otherwise */
} list_dump_info_t;
} list_dump_info_t;
#endif
/**
/**
* a comparator of elements.
*
* A comparator of elements is a function that:
@ -77,9 +77,9 @@ typedef struct {
*
* It is responsability of the function to handle possible NULL values.
*/
typedef int (*element_comparator)(const void *a, const void *b);
typedef int (*element_comparator)(const void *a, const void *b);
/**
/**
* a seeker of elements.
*
* An element seeker is a function that:
@ -90,9 +90,9 @@ typedef int (*element_comparator)(const void *a, const void *b);
* It is responsability of the function to handle possible NULL values in any
* argument.
*/
typedef int (*element_seeker)(const void *el, const void *indicator);
typedef int (*element_seeker)(const void *el, const void *indicator);
/**
/**
* an element lenght meter.
*
* An element meter is a function that:
@ -101,9 +101,9 @@ typedef int (*element_seeker)(const void *el, const void *indicator);
*
* It is responsability of the function to handle possible NULL values.
*/
typedef size_t (*element_meter)(const void *el);
typedef size_t (*element_meter)(const void *el);
/**
/**
* a function computing the hash of elements.
*
* An hash computing function is a function that:
@ -112,9 +112,9 @@ typedef size_t (*element_meter)(const void *el);
*
* It is responsability of the function to handle possible NULL values.
*/
typedef list_hash_t (*element_hash_computer)(const void *el);
typedef list_hash_t (*element_hash_computer)(const void *el);
/**
/**
* a function for serializing an element.
*
* A serializer function is one that gets a reference to an element,
@ -132,9 +132,9 @@ typedef list_hash_t (*element_hash_computer)(const void *el);
* @param serialize_buffer reference to fill with the length of the buffer
* @return reference to the buffer with the serialized data
*/
typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict serializ_len);
typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict serializ_len);
/**
/**
* a function for un-serializing an element.
*
* An unserializer function accomplishes the inverse operation of the
@ -149,19 +149,19 @@ typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict
* @param data_len reference to the location where to store the length of the data in the buffer returned
* @return reference to a buffer with the original, unserialized representation of the element
*/
typedef void *(*element_unserializer)(const void *restrict data, uint32_t *restrict data_len);
typedef void *(*element_unserializer)(const void *restrict data, uint32_t *restrict data_len);
/* [private-use] list entry -- olds actual user datum */
struct list_entry_s {
/* [private-use] list entry -- olds actual user datum */
struct list_entry_s {
void *data;
/* doubly-linked list service references */
struct list_entry_s *next;
struct list_entry_s *prev;
};
};
/* [private-use] list attributes */
struct list_attributes_s {
/* [private-use] list attributes */
struct list_attributes_s {
/* user-set routine for comparing list elements */
element_comparator comparator;
/* user-set routing for seeking elements */
@ -175,10 +175,10 @@ struct list_attributes_s {
element_serializer serializer;
/* user-set routine for unserializing an element */
element_unserializer unserializer;
};
};
/** list object */
typedef struct {
/** list object */
typedef struct {
struct list_entry_s *head_sentinel;
struct list_entry_s *tail_sentinel;
struct list_entry_s *mid;
@ -201,17 +201,17 @@ typedef struct {
/* list attributes */
struct list_attributes_s attrs;
} list_t;
} list_t;
/**
/**
* initialize a list object for use.
*
* @param l must point to a user-provided memory location
* @return 0 for success. -1 for failure
*/
int list_init(list_t *restrict l);
int list_init(list_t *restrict l);
/**
/**
* completely remove the list from memory.
*
* This function is the inverse of list_init(). It is meant to be called when
@ -220,9 +220,9 @@ int list_init(list_t *restrict l);
*
* @param l list to destroy
*/
void list_destroy(list_t *restrict l);
void list_destroy(list_t *restrict l);
/**
/**
* set the comparator function for list elements.
*
* Comparator functions are used for searching and sorting. If NULL is passed
@ -234,9 +234,9 @@ void list_destroy(list_t *restrict l);
*
* @see element_comparator()
*/
int list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
int list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
/**
/**
* set a seeker function for list elements.
*
* Seeker functions are used for finding elements. If NULL is passed as reference
@ -248,9 +248,9 @@ int list_attributes_comparator(list_t *restrict l, element_comparator comparator
*
* @see element_seeker()
*/
int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
/**
/**
* require to free element data when list entry is removed (default: don't free).
*
* [ advanced preference ]
@ -280,9 +280,9 @@ int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
* @see list_meter_double()
* @see list_meter_string()
*/
int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
/**
/**
* set the element hash computing function for the list elements.
*
* [ advanced preference ]
@ -300,9 +300,9 @@ int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_
*
* @see element_hash_computer()
*/
int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
/**
/**
* set the element serializer function for the list elements.
*
* [ advanced preference ]
@ -321,9 +321,9 @@ int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash
* @see list_dump_filedescriptor()
* @see list_restore_filedescriptor()
*/
int list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
int list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
/**
/**
* set the element unserializer function for the list elements.
*
* [ advanced preference ]
@ -343,9 +343,9 @@ int list_attributes_serializer(list_t *restrict l, element_serializer serializer
* @see list_dump_filedescriptor()
* @see list_restore_filedescriptor()
*/
int list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
int list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
/**
/**
* append data at the end of the list.
*
* This function is useful for adding elements with a FIFO/queue policy.
@ -355,9 +355,9 @@ int list_attributes_unserializer(list_t *restrict l, element_unserializer unseri
*
* @return 1 for success. < 0 for failure
*/
int list_append(list_t *restrict l, const void *data);
int list_append(list_t *restrict l, const void *data);
/**
/**
* insert data in the head of the list.
*
* This function is useful for adding elements with a LIFO/Stack policy.
@ -367,9 +367,9 @@ int list_append(list_t *restrict l, const void *data);
*
* @return 1 for success. < 0 for failure
*/
int list_prepend(list_t *restrict l, const void *restrict data);
int list_prepend(list_t *restrict l, const void *restrict data);
/**
/**
* extract the element in the top of the list.
*
* This function is for using a list with a FIFO/queue policy.
@ -377,18 +377,18 @@ int list_prepend(list_t *restrict l, const void *restrict data);
* @param l list to operate
* @return reference to user datum, or NULL on errors
*/
void *list_fetch(list_t *restrict l);
void *list_fetch(list_t *restrict l);
/**
/**
* retrieve an element at a given position.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element wanted
* @return reference to user datum, or NULL on errors
*/
void *list_get_at(const list_t *restrict l, unsigned int pos);
void *list_get_at(const list_t *restrict l, unsigned int pos);
/**
/**
* return the maximum element of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -400,9 +400,9 @@ void *list_get_at(const list_t *restrict l, unsigned int pos);
* @param l list to operate
* @return the reference to the element, or NULL
*/
void *list_get_max(const list_t *restrict l);
void *list_get_max(const list_t *restrict l);
/**
/**
* return the minimum element of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -414,18 +414,18 @@ void *list_get_max(const list_t *restrict l);
* @param l list to operate
* @return the reference to the element, or NULL
*/
void *list_get_min(const list_t *restrict l);
void *list_get_min(const list_t *restrict l);
/**
/**
* retrieve and remove from list an element at a given position.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element wanted
* @return reference to user datum, or NULL on errors
*/
void *list_extract_at(list_t *restrict l, unsigned int pos);
void *list_extract_at(list_t *restrict l, unsigned int pos);
/**
/**
* insert an element at a given position.
*
* @param l list to operate
@ -433,9 +433,9 @@ void *list_extract_at(list_t *restrict l, unsigned int pos);
* @param pos [0,size-1] position index to insert the element at
* @return positive value on success. Negative on failure
*/
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
/**
/**
* expunge the first found given element from the list.
*
* Inspects the given list looking for the given element; if the element
@ -450,18 +450,18 @@ int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
* @see list_attributes_comparator()
* @see list_delete_at()
*/
int list_delete(list_t *restrict l, const void *data);
int list_delete(list_t *restrict l, const void *data);
/**
/**
* expunge an element at a given position from the list.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element to be deleted
* @return 0 on success. Negative value on failure
*/
int list_delete_at(list_t *restrict l, unsigned int pos);
int list_delete_at(list_t *restrict l, unsigned int pos);
/**
/**
* expunge an array of elements from the list, given their position range.
*
* @param l list to operate
@ -469,9 +469,9 @@ int list_delete_at(list_t *restrict l, unsigned int pos);
* @param posend [posstart,size-1] position of the last element to be deleted
* @return the number of elements successfully removed on success, <0 on error
*/
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
/**
/**
* clear all the elements off of the list.
*
* The element datums will not be freed.
@ -482,17 +482,17 @@ int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int po
* @param l list to operate
* @return the number of elements removed on success, <0 on error
*/
int list_clear(list_t *restrict l);
int list_clear(list_t *restrict l);
/**
/**
* inspect the number of elements in the list.
*
* @param l list to operate
* @return number of elements currently held by the list
*/
unsigned int list_size(const list_t *restrict l);
unsigned int list_size(const list_t *restrict l);
/**
/**
* inspect whether the list is empty.
*
* @param l list to operate
@ -500,9 +500,9 @@ unsigned int list_size(const list_t *restrict l);
*
* @see list_size()
*/
int list_empty(const list_t *restrict l);
int list_empty(const list_t *restrict l);
/**
/**
* find the position of an element in a list.
*
* @warning Requires a comparator function to be set for the list.
@ -519,9 +519,9 @@ int list_empty(const list_t *restrict l);
* @see list_attributes_comparator()
* @see list_get_at()
*/
int list_locate(const list_t *restrict l, const void *data);
int list_locate(const list_t *restrict l, const void *data);
/**
/**
* returns an element given an indicator.
*
* @warning Requires a seeker function to be set for the list.
@ -534,9 +534,9 @@ int list_locate(const list_t *restrict l, const void *data);
* @param indicator indicator data to pass to the seeker along with elements
* @return reference to the element accepted by the seeker, or NULL if none found
*/
void *list_seek(list_t *restrict l, const void *indicator);
void *list_seek(list_t *restrict l, const void *indicator);
/**
/**
* inspect whether some data is member of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -555,9 +555,9 @@ void *list_seek(list_t *restrict l, const void *indicator);
*
* @see list_attributes_comparator()
*/
int list_contains(const list_t *restrict l, const void *data);
int list_contains(const list_t *restrict l, const void *data);
/**
/**
* concatenate two lists
*
* Concatenates one list with another, and stores the result into a
@ -574,9 +574,9 @@ int list_contains(const list_t *restrict l, const void *data);
* @param dest reference to the destination list
* @return 0 for success, -1 for errors
*/
int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
/**
/**
* sort list elements.
*
* @warning Requires a comparator function to be set for the list.
@ -591,9 +591,9 @@ int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
*
* @see list_attributes_comparator()
*/
int list_sort(list_t *restrict l, int versus);
int list_sort(list_t *restrict l, int versus);
/**
/**
* start an iteration session.
*
* This function prepares the list to be iterated.
@ -603,33 +603,33 @@ int list_sort(list_t *restrict l, int versus);
*
* @see list_iterator_stop()
*/
int list_iterator_start(list_t *restrict l);
int list_iterator_start(list_t *restrict l);
/**
/**
* return the next element in the iteration session.
*
* @param l list to operate
* @return element datum, or NULL on errors
*/
void *list_iterator_next(list_t *restrict l);
void *list_iterator_next(list_t *restrict l);
/**
/**
* inspect whether more elements are available in the iteration session.
*
* @param l list to operate
* @return 0 iff no more elements are available.
*/
int list_iterator_hasnext(const list_t *restrict l);
int list_iterator_hasnext(const list_t *restrict l);
/**
/**
* end an iteration session.
*
* @param l list to operate
* @return 0 iff the iteration session cannot be stopped
*/
int list_iterator_stop(list_t *restrict l);
int list_iterator_stop(list_t *restrict l);
/**
/**
* return the hash of the current status of the list.
*
* @param l list to operate
@ -637,10 +637,10 @@ int list_iterator_stop(list_t *restrict l);
*
* @return 0 for success; <0 for failure
*/
int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
#ifndef SIMCLIST_NO_DUMPRESTORE
/**
/**
* get meta informations on a list dump on filedescriptor.
*
* [ advanced function ]
@ -655,9 +655,9 @@ int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
*
* @see list_dump_filedescriptor()
*/
int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
/**
/**
* get meta informations on a list dump on file.
*
* [ advanced function ]
@ -670,9 +670,9 @@ int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
*
* @see list_dump_filedescriptor()
*/
int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
/**
/**
* dump the list into an open, writable file descriptor.
*
* This function "dumps" the list to a persistent storage so it can be
@ -706,9 +706,9 @@ int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *rest
* @see list_attributes_copy()
* @see list_attributes_serializer()
*/
int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
/**
/**
* dump the list to a file name.
*
* This function creates a filename and dumps the current content of the list
@ -729,9 +729,9 @@ int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict
*
* This function stores a representation of the list
*/
int list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
int list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
/**
/**
* restore the list from an open, readable file descriptor to memory.
*
* This function is the "inverse" of list_dump_filedescriptor(). It restores
@ -749,9 +749,9 @@ int list_dump_file(const list_t *restrict l, const char *restrict filename, size
* @param len location to store the length of the dump read (bytes), or NULL
* @return 0 if successful; -1 otherwise
*/
int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
/**
/**
* restore the list from a file name.
*
* This function restores the content of a list from a file into memory. It is
@ -767,210 +767,210 @@ int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len
* @param len location to store the length of the dump read (bytes), or NULL
* @return 0 if successful; -1 otherwise
*/
int list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
int list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
#endif
/* ready-made comparators, meters and hash computers */
/* ready-made comparators, meters and hash computers */
/* comparator functions */
/**
/**
* ready-made comparator for int8_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int8_t(const void *a, const void *b);
int list_comparator_int8_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int16_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int16_t(const void *a, const void *b);
int list_comparator_int16_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int32_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int32_t(const void *a, const void *b);
int list_comparator_int32_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int64_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int64_t(const void *a, const void *b);
int list_comparator_int64_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint8_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint8_t(const void *a, const void *b);
int list_comparator_uint8_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint16_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint16_t(const void *a, const void *b);
int list_comparator_uint16_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint32_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint32_t(const void *a, const void *b);
int list_comparator_uint32_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint64_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint64_t(const void *a, const void *b);
int list_comparator_uint64_t(const void *a, const void *b);
/**
/**
* ready-made comparator for float elements.
* @see list_attributes_comparator()
*/
int list_comparator_float(const void *a, const void *b);
int list_comparator_float(const void *a, const void *b);
/**
/**
* ready-made comparator for double elements.
* @see list_attributes_comparator()
*/
int list_comparator_double(const void *a, const void *b);
int list_comparator_double(const void *a, const void *b);
/**
/**
* ready-made comparator for string elements.
* @see list_attributes_comparator()
*/
int list_comparator_string(const void *a, const void *b);
int list_comparator_string(const void *a, const void *b);
/* metric functions */
/**
/**
* ready-made metric function for int8_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int8_t(const void *el);
size_t list_meter_int8_t(const void *el);
/**
/**
* ready-made metric function for int16_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int16_t(const void *el);
size_t list_meter_int16_t(const void *el);
/**
/**
* ready-made metric function for int32_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int32_t(const void *el);
size_t list_meter_int32_t(const void *el);
/**
/**
* ready-made metric function for int64_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int64_t(const void *el);
size_t list_meter_int64_t(const void *el);
/**
/**
* ready-made metric function for uint8_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint8_t(const void *el);
size_t list_meter_uint8_t(const void *el);
/**
/**
* ready-made metric function for uint16_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint16_t(const void *el);
size_t list_meter_uint16_t(const void *el);
/**
/**
* ready-made metric function for uint32_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint32_t(const void *el);
size_t list_meter_uint32_t(const void *el);
/**
/**
* ready-made metric function for uint64_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint64_t(const void *el);
size_t list_meter_uint64_t(const void *el);
/**
/**
* ready-made metric function for float elements.
* @see list_attributes_copy()
*/
size_t list_meter_float(const void *el);
size_t list_meter_float(const void *el);
/**
/**
* ready-made metric function for double elements.
* @see list_attributes_copy()
*/
size_t list_meter_double(const void *el);
size_t list_meter_double(const void *el);
/**
/**
* ready-made metric function for string elements.
* @see list_attributes_copy()
*/
size_t list_meter_string(const void *el);
size_t list_meter_string(const void *el);
/* hash functions */
/**
/**
* ready-made hash function for int8_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int8_t(const void *el);
list_hash_t list_hashcomputer_int8_t(const void *el);
/**
/**
* ready-made hash function for int16_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int16_t(const void *el);
list_hash_t list_hashcomputer_int16_t(const void *el);
/**
/**
* ready-made hash function for int32_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int32_t(const void *el);
list_hash_t list_hashcomputer_int32_t(const void *el);
/**
/**
* ready-made hash function for int64_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int64_t(const void *el);
list_hash_t list_hashcomputer_int64_t(const void *el);
/**
/**
* ready-made hash function for uint8_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint8_t(const void *el);
list_hash_t list_hashcomputer_uint8_t(const void *el);
/**
/**
* ready-made hash function for uint16_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint16_t(const void *el);
list_hash_t list_hashcomputer_uint16_t(const void *el);
/**
/**
* ready-made hash function for uint32_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint32_t(const void *el);
list_hash_t list_hashcomputer_uint32_t(const void *el);
/**
/**
* ready-made hash function for uint64_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint64_t(const void *el);
list_hash_t list_hashcomputer_uint64_t(const void *el);
/**
/**
* ready-made hash function for float elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_float(const void *el);
list_hash_t list_hashcomputer_float(const void *el);
/**
/**
* ready-made hash function for double elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_double(const void *el);
list_hash_t list_hashcomputer_double(const void *el);
/**
/**
* ready-made hash function for string elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_string(const void *el);
list_hash_t list_hashcomputer_string(const void *el);
#ifdef __cplusplus
}
@ -978,3 +978,13 @@ list_hash_t list_hashcomputer_string(const void *el);
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -28,7 +28,7 @@
extern "C" {
#endif /* __cplusplus */
/*
/*
* To build a "key" in any of the below routines, pass in a pointer to
* the key and its size [i.e. sizeof(int), etc]. With any of the
* "key" or "data" arguments, if their size is < 0, it will do an
@ -40,7 +40,7 @@ extern "C" {
* deleting from firstkey to NULL it will work fine.
*/
/* return types for table functions */
/* return types for table functions */
#define TABLE_ERROR_NONE 1 /* no error from function */
#define TABLE_ERROR_PNT 2 /* bad table pointer */
#define TABLE_ERROR_ARG_NULL 3 /* buffer args were null */
@ -62,11 +62,11 @@ extern "C" {
#define TABLE_ERROR_COMPARE 19 /* problems with internal comparison */
#define TABLE_ERROR_FREE 20 /* memory free error */
/*
/*
* Table flags set with table_attr.
*/
/*
/*
* Automatically adjust the number of table buckets on the fly.
* Whenever the number of entries gets above some threshold, the
* number of buckets is realloced to a new size and each entry is
@ -75,20 +75,20 @@ extern "C" {
*/
#define TABLE_FLAG_AUTO_ADJUST (1<<0)
/*
/*
* If the above auto-adjust flag is set, also adjust the number of
* table buckets down as we delete entries.
*/
#define TABLE_FLAG_ADJUST_DOWN (1<<1)
/* structure to walk through the fields in a linear order */
typedef struct {
/* structure to walk through the fields in a linear order */
typedef struct {
unsigned int tl_magic; /* magic structure to ensure correct init */
unsigned int tl_bucket_c; /* where in the table buck array we are */
unsigned int tl_entry_c; /* in the bucket, which entry we are on */
} table_linear_t;
} table_linear_t;
/*
/*
* int (*table_compare_t)
*
* DESCRIPTION
@ -118,12 +118,12 @@ typedef struct {
*
* data2_size - Pointer to the size of the second data entry.
*/
typedef int (*table_compare_t)(const void *key1, const int key1_size,
typedef int (*table_compare_t)(const void *key1, const int key1_size,
const void *data1, const int data1_size,
const void *key2, const int key2_size,
const void *data2, const int data2_size);
/*
/*
* int (*table_mem_alloc_t)
*
* DESCRIPTION
@ -143,9 +143,9 @@ typedef int (*table_compare_t)(const void *key1, const int key1_size,
*
* size -> Number of bytes that needs to be allocated.
*/
typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
/*
/*
* int (*table_mem_resize_t)
*
* DESCRIPTION
@ -173,11 +173,11 @@ typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
*
* new_size -> New size of the allocation.
*/
typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
const unsigned long old_size,
const unsigned long new_size);
/*
/*
* int (*table_mem_free_t)
*
* DESCRIPTION
@ -200,7 +200,7 @@ typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
* min_size -> Minimum size of the address being freed or 0 if not
* known. This can also be the exact size if known.
*/
typedef int (*table_mem_free_t)(void *pool_p, void *addr,
typedef int (*table_mem_free_t)(void *pool_p, void *addr,
const unsigned long min_size);
#ifdef TABLE_MAIN
@ -209,17 +209,17 @@ typedef int (*table_mem_free_t)(void *pool_p, void *addr,
#else
/* generic table type */
typedef void table_t;
/* generic table type */
typedef void table_t;
/* generic table entry type */
typedef void table_entry_t;
/* generic table entry type */
typedef void table_entry_t;
#endif
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/*
/*
* table_t *table_alloc
*
* DESCRIPTION:
@ -240,10 +240,10 @@ typedef void table_entry_t;
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_alloc(const unsigned int bucket_n, int *error_p);
extern
table_t *table_alloc(const unsigned int bucket_n, int *error_p);
/*
/*
* table_t *table_alloc_in_pool
*
* DESCRIPTION:
@ -275,14 +275,14 @@ table_t *table_alloc(const unsigned int bucket_n, int *error_p);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_alloc_in_pool(const unsigned int bucket_n,
extern
table_t *table_alloc_in_pool(const unsigned int bucket_n,
void *mem_pool,
table_mem_alloc_t alloc_func,
table_mem_resize_t resize_func,
table_mem_free_t free_func, int *error_p);
/*
/*
* int table_attr
*
* DESCRIPTION:
@ -302,10 +302,10 @@ table_t *table_alloc_in_pool(const unsigned int bucket_n,
*
* attr - Attribute(s) that we will be applying to the table.
*/
extern
int table_attr(table_t *table_p, const int attr);
extern
int table_attr(table_t *table_p, const int attr);
/*
/*
* int table_set_data_alignment
*
* DESCRIPTION:
@ -342,10 +342,10 @@ int table_attr(table_t *table_p, const int attr);
* alignment - Alignment requested for the data. Must be a power of
* 2. Set to 0 for none.
*/
extern
int table_set_data_alignment(table_t *table_p, const int alignment);
extern
int table_set_data_alignment(table_t *table_p, const int alignment);
/*
/*
* int table_clear
*
* DESCRIPTION:
@ -362,10 +362,10 @@ int table_set_data_alignment(table_t *table_p, const int alignment);
*
* table_p - Table structure pointer that we will be clearing.
*/
extern
int table_clear(table_t *table_p);
extern
int table_clear(table_t *table_p);
/*
/*
* int table_free
*
* DESCRIPTION:
@ -382,10 +382,10 @@ int table_clear(table_t *table_p);
*
* table_p - Table structure pointer that we will be freeing.
*/
extern
int table_free(table_t *table_p);
extern
int table_free(table_t *table_p);
/*
/*
* int table_insert_kd
*
* DESCRIPTION:
@ -461,14 +461,14 @@ int table_free(table_t *table_p);
* the data in the table with the new data if the key already exists
* in the table.
*/
extern
int table_insert_kd(table_t *table_p,
extern
int table_insert_kd(table_t *table_p,
const void *key_buf, const int key_size,
const void *data_buf, const int data_size,
void **key_buf_p, void **data_buf_p,
const char overwrite_b);
/*
/*
* int table_insert
*
* DESCRIPTION:
@ -520,13 +520,13 @@ int table_insert_kd(table_t *table_p,
* the data in the table with the new data if the key already exists
* in the table.
*/
extern
int table_insert(table_t *table_p,
extern
int table_insert(table_t *table_p,
const void *key_buf, const int key_size,
const void *data_buf, const int data_size,
void **data_buf_p, const char overwrite_b);
/*
/*
* int table_retrieve
*
* DESCRIPTION:
@ -565,12 +565,12 @@ int table_insert(table_t *table_p,
* to the size of the data stored in the table that is associated with
* the key.
*/
extern
int table_retrieve(table_t *table_p,
extern
int table_retrieve(table_t *table_p,
const void *key_buf, const int key_size,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_delete
*
* DESCRIPTION:
@ -615,12 +615,12 @@ int table_retrieve(table_t *table_p,
* to the size of the data that was stored in the table and that was
* associated with the key.
*/
extern
int table_delete(table_t *table_p,
extern
int table_delete(table_t *table_p,
const void *key_buf, const int key_size,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_delete_first
*
* DESCRIPTION:
@ -669,12 +669,12 @@ int table_delete(table_t *table_p,
* to the size of the data that was stored in the table and that was
* associated with the key.
*/
extern
int table_delete_first(table_t *table_p,
extern
int table_delete_first(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_info
*
* DESCRIPTION:
@ -698,10 +698,10 @@ int table_delete_first(table_t *table_p,
* num_entries_p - Pointer to an integer which, if not NULL, will
* contain the number of entries stored in the table.
*/
extern
int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
extern
int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
/*
/*
* int table_adjust
*
* DESCRIPTION:
@ -721,10 +721,10 @@ int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
* bucket_n - Number buckets to adjust the table to. Set to 0 to
* adjust the table to its number of entries.
*/
extern
int table_adjust(table_t *table_p, const int bucket_n);
extern
int table_adjust(table_t *table_p, const int bucket_n);
/*
/*
* int table_type_size
*
* DESCRIPTION:
@ -739,10 +739,10 @@ int table_adjust(table_t *table_p, const int bucket_n);
*
* None.
*/
extern
int table_type_size(void);
extern
int table_type_size(void);
/*
/*
* int table_first
*
* DESCRIPTION:
@ -785,12 +785,12 @@ int table_type_size(void);
* to the size of the data that is stored in the table and that is
* associated with the first key.
*/
extern
int table_first(table_t *table_p,
extern
int table_first(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_next
*
* DESCRIPTION:
@ -833,12 +833,12 @@ int table_first(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the next key.
*/
extern
int table_next(table_t *table_p,
extern
int table_next(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_this
*
* DESCRIPTION:
@ -880,12 +880,12 @@ int table_next(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the current key.
*/
extern
int table_this(table_t *table_p,
extern
int table_this(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_first_r
*
* DESCRIPTION:
@ -929,12 +929,12 @@ int table_this(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the first key.
*/
extern
int table_first_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_first_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_next_r
*
* DESCRIPTION:
@ -978,12 +978,12 @@ int table_first_r(table_t *table_p, table_linear_t *linear_p,
* to the size of the data that is stored in the table and that is
* associated with the next key.
*/
extern
int table_next_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_next_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_this_r
*
* DESCRIPTION:
@ -1027,12 +1027,12 @@ int table_next_r(table_t *table_p, table_linear_t *linear_p,
* to the size of the data that is stored in the table and that is
* associated with the current key.
*/
extern
int table_this_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_this_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* table_t *table_mmap
*
* DESCRIPTION:
@ -1052,10 +1052,10 @@ int table_this_r(table_t *table_p, table_linear_t *linear_p,
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_mmap(const char *path, int *error_p);
extern
table_t *table_mmap(const char *path, int *error_p);
/*
/*
* int table_munmap
*
* DESCRIPTION:
@ -1070,10 +1070,10 @@ table_t *table_mmap(const char *path, int *error_p);
*
* table_p - Mmaped table pointer to unmap.
*/
extern
int table_munmap(table_t *table_p);
extern
int table_munmap(table_t *table_p);
/*
/*
* int table_read
*
* DESCRIPTION:
@ -1095,10 +1095,10 @@ int table_munmap(table_t *table_p);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_read(const char *path, int *error_p);
extern
table_t *table_read(const char *path, int *error_p);
/*
/*
* int table_write
*
* DESCRIPTION:
@ -1120,10 +1120,10 @@ table_t *table_read(const char *path, int *error_p);
* mode - Mode of the file. This argument is passed on to open when
* the file is created.
*/
extern
int table_write(const table_t *table_p, const char *path, const int mode);
extern
int table_write(const table_t *table_p, const char *path, const int mode);
/*
/*
* table_entry_t *table_order
*
* DESCRIPTION:
@ -1157,11 +1157,11 @@ int table_write(const table_t *table_p, const char *path, const int mode);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_entry_t **table_order(table_t *table_p, table_compare_t compare,
extern
table_entry_t **table_order(table_t *table_p, table_compare_t compare,
int *num_entries_p, int *error_p);
/*
/*
* int table_order_free
*
* DESCRIPTION:
@ -1185,11 +1185,11 @@ table_entry_t **table_order(table_t *table_p, table_compare_t compare,
* entry_n - Number of entries in the array as passed back by
* table_order or table_order_pos in num_entries_p.
*/
extern
int table_order_free(table_t *table_p, table_entry_t **table_entries,
extern
int table_order_free(table_t *table_p, table_entry_t **table_entries,
const int entry_n);
/*
/*
* int table_entry
*
* DESCRIPTION:
@ -1228,12 +1228,12 @@ int table_order_free(table_t *table_p, table_entry_t **table_entries,
* data_size_p - Pointer to an integer which, if not NULL, will be set
* to the size of the data that is stored in the table.
*/
extern
int table_entry(table_t *table_p, table_entry_t *entry_p,
extern
int table_entry(table_t *table_p, table_entry_t *entry_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* table_linear_t *table_order_pos
*
* DESCRIPTION:
@ -1267,11 +1267,11 @@ int table_entry(table_t *table_p, table_entry_t *entry_p,
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
extern
table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
int *num_entries_p, int *error_p);
/*
/*
* int table_order_pos_free
*
* DESCRIPTION:
@ -1295,11 +1295,11 @@ table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
* entry_n - Number of entries in the array as passed back by
* table_order or table_order_pos in num_entries_p.
*/
extern
int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
extern
int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
const int entry_n);
/*
/*
* int table_entry_pos
*
* DESCRIPTION:
@ -1338,12 +1338,12 @@ int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
* data_size_p - Pointer to an integer which, if not NULL, will be set
* to the size of the data that is stored in the table.
*/
extern
int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
extern
int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* const char *table_strerror
*
* DESCRIPTION:
@ -1360,13 +1360,24 @@ int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
*
* error - Error number that we are converting.
*/
extern
const char *table_strerror(const int error);
extern
const char *table_strerror(const int error);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ! __TABLE_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -227,3 +227,15 @@ static error_str_t errors[] = {
#define INVALID_ERROR "invalid error code"
#endif /* ! __TABLE_LOC_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -59,6 +59,7 @@
/* These warnings need to be ignored warning in sdk header */
#include <Ws2tcpip.h>
#include <windows.h>
#pragma comment(lib, "Ws2_32.lib")
#ifndef errno
#define errno WSAGetLastError()
#endif

View File

@ -204,7 +204,7 @@ static const char *parse_string(cJSON *item,const char *str)
break;
default: *ptr2++=*ptr; break;
}
ptr++;
if (*ptr) ptr++;
}
}
*ptr2=0;

View File

@ -37,7 +37,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
#include <io.h>
#ifndef open
#define open _open
#endif
#ifndef close
#define close _close
#endif
#else
#include <unistd.h>
#endif
#include <sys/mman.h>
#ifdef DMALLOC
@ -64,6 +74,18 @@ static unsigned int min_bit_free_next = 0; /* min size of next pnt */
static unsigned int min_bit_free_size = 0; /* min size of next + size */
static unsigned long bit_array[MAX_BITS + 1]; /* size -> bit */
#ifdef _MSC_VER
#include <Windows.h>
long getpagesize(void) {
static long g_pagesize = 0;
if (!g_pagesize) {
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
g_pagesize = system_info.dwPageSize;
}
return g_pagesize;
}
#endif
/****************************** local utilities ******************************/
/*
@ -225,8 +247,8 @@ static unsigned long bits_to_size(const int bit_n)
static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n,
int *error_p)
{
void *mem, *fill_mem;
unsigned long size, fill;
void *mem;
unsigned long size;
int state;
/* are we over our max-pages? */
@ -241,54 +263,34 @@ static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n,
(void)printf("allocating %u pages or %lu bytes\n", page_n, size);
#endif
if (BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_USE_SBRK)) {
mem = sbrk(size);
if (mem == (void *)-1) {
SET_POINTER(error_p, MPOOL_ERROR_NO_MEM);
return NULL;
}
fill = (unsigned long)mem % mp_p->mp_page_size;
if (fill > 0) {
fill = mp_p->mp_page_size - fill;
fill_mem = sbrk(fill);
if (fill_mem == (void *)-1) {
SET_POINTER(error_p, MPOOL_ERROR_NO_MEM);
return NULL;
}
if ((char *)fill_mem != (char *)mem + size) {
SET_POINTER(error_p, MPOOL_ERROR_SBRK_CONTIG);
return NULL;
}
mem = (char *)mem + fill;
}
}
else {
state = MAP_PRIVATE;
#ifdef MAP_FILE
#if defined(MAP_FILE)
state |= MAP_FILE;
#endif
#ifdef MAP_VARIABLE
#if defined(MAP_VARIABLE)
state |= MAP_VARIABLE;
#endif
/* mmap from /dev/zero */
mem = mmap((caddr_t)mp_p->mp_addr, size, PROT_READ | PROT_WRITE, state,
mem = mmap(mp_p->mp_addr, size, PROT_READ | PROT_WRITE, state | mp_p->mp_mmflags,
mp_p->mp_fd, mp_p->mp_top);
if (mem == (void *)MAP_FAILED) {
if (errno == ENOMEM) {
SET_POINTER(error_p, MPOOL_ERROR_NO_MEM);
}
else {
} else {
SET_POINTER(error_p, MPOOL_ERROR_MMAP);
}
return NULL;
}
mp_p->mp_top += size;
if (mp_p->mp_addr != NULL) {
mp_p->mp_addr = (char *)mp_p->mp_addr + size;
}
}
mp_p->mp_page_c += page_n;
@ -317,13 +319,10 @@ static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n,
*
* sbrk_b -> Set to one if the pages were allocated with sbrk else mmap.
*/
static int free_pages(void *pages, const unsigned long size,
const int sbrk_b)
{
if (! sbrk_b) {
(void)munmap((caddr_t)pages, size);
}
static int free_pages(void *pages, const unsigned long size)
{
(void)munmap(pages, size);
return MPOOL_ERROR_NONE;
}
@ -883,12 +882,11 @@ static int free_mem(mpool_t *mp_p, void *addr, const unsigned long size)
* multiple of the getpagesize() value. Set to 0 for the default.
*
* start_addr -> Starting address to try and allocate memory pools.
* This is ignored if the MPOOL_FLAG_USE_SBRK is enabled.
*
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
KS_DECLARE(mpool_t *) mpool_open(const unsigned int flags, const unsigned int page_size,
void *start_addr, int *error_p)
{
mpool_block_t *block_p;
@ -937,22 +935,23 @@ mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
}
}
if (BIT_IS_SET(flags, MPOOL_FLAG_USE_SBRK)) {
mp.mp_mmflags = 0;
if (BIT_IS_SET(flags, MPOOL_FLAG_ANONYMOUS)) {
mp.mp_fd = -1;
mp.mp_addr = NULL;
mp.mp_top = 0;
}
else {
mp.mp_mmflags |= MAP_ANON;
} else {
/* open dev-zero for our mmaping */
mp.mp_fd = open("/dev/zero", O_RDWR, 0);
if (mp.mp_fd < 0) {
SET_POINTER(error_p, MPOOL_ERROR_OPEN_ZERO);
return NULL;
}
}
mp.mp_addr = start_addr;
/* we start at the front of the file */
mp.mp_top = 0;
}
/*
* Find out how many pages we need for our mpool structure.
@ -1001,8 +1000,8 @@ mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
mp.mp_fd = -1;
}
/* NOTE: after this line mp_p will be invalid */
(void)free_pages(block_p, SIZE_OF_PAGES(&mp, page_n),
BIT_IS_SET(flags, MPOOL_FLAG_USE_SBRK));
(void)free_pages(block_p, SIZE_OF_PAGES(&mp, page_n));
SET_POINTER(error_p, ret);
return NULL;
}
@ -1050,7 +1049,7 @@ mpool_t *mpool_open(const unsigned int flags, const unsigned int page_size,
*
* mp_p <-> Pointer to our memory pool.
*/
int mpool_close(mpool_t *mp_p)
KS_DECLARE(int) mpool_close(mpool_t *mp_p)
{
mpool_block_t *block_p, *next_p;
void *addr;
@ -1088,8 +1087,8 @@ int mpool_close(mpool_t *mp_p)
block_p->mb_magic2 = 0;
/* record the next pointer because it might be invalidated below */
next_p = block_p->mb_next_p;
ret = free_pages(block_p, (char *)block_p->mb_bounds_p - (char *)block_p,
BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_USE_SBRK));
ret = free_pages(block_p, (char *)block_p->mb_bounds_p - (char *)block_p);
if (ret != MPOOL_ERROR_NONE) {
final = ret;
}
@ -1105,9 +1104,6 @@ int mpool_close(mpool_t *mp_p)
mp_p->mp_magic = 0;
mp_p->mp_magic2 = 0;
/* last we munmap the mpool pointer itself */
if (! BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_USE_SBRK)) {
/* if we are heavy packing then we need to free the 1st block later */
if (BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_HEAVY_PACKING)) {
addr = (char *)mp_p - sizeof(mpool_block_t);
@ -1117,8 +1113,8 @@ int mpool_close(mpool_t *mp_p)
}
size = SIZE_OF_PAGES(mp_p, PAGES_IN_SIZE(mp_p, sizeof(mpool_t)));
(void)munmap((caddr_t)addr, size);
}
(void)munmap(addr, size);
return final;
}
@ -1140,7 +1136,7 @@ int mpool_close(mpool_t *mp_p)
*
* mp_p <-> Pointer to our memory pool.
*/
int mpool_clear(mpool_t *mp_p)
KS_DECLARE(int) mpool_clear(mpool_t *mp_p)
{
mpool_block_t *block_p;
int final = MPOOL_ERROR_NONE, bit_n, ret;
@ -1211,7 +1207,7 @@ int mpool_clear(mpool_t *mp_p)
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
void *mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
KS_DECLARE(void *) mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
int *error_p)
{
void *addr;
@ -1278,7 +1274,7 @@ void *mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
void *mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
KS_DECLARE(void *) mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
const unsigned long ele_size, int *error_p)
{
void *addr;
@ -1347,7 +1343,7 @@ void *mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
*
* size -> Size of the address being freed.
*/
int mpool_free(mpool_t *mp_p, void *addr, const unsigned long size)
KS_DECLARE(int) mpool_free(mpool_t *mp_p, void *addr, const unsigned long size)
{
if (mp_p == NULL) {
/* special case -- do a normal free */
@ -1406,7 +1402,7 @@ int mpool_free(mpool_t *mp_p, void *addr, const unsigned long size)
* error_p <- Pointer to integer which, if not NULL, will be set with
* a mpool error code.
*/
void *mpool_resize(mpool_t *mp_p, void *old_addr,
KS_DECLARE(void *) mpool_resize(mpool_t *mp_p, void *old_addr,
const unsigned long old_byte_size,
const unsigned long new_byte_size,
int *error_p)
@ -1563,7 +1559,7 @@ void *mpool_resize(mpool_t *mp_p, void *old_addr,
* will be set to the total amount of space (including administrative
* overhead) used by the pool.
*/
int mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
KS_DECLARE(int) mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
unsigned long *num_alloced_p,
unsigned long *user_alloced_p,
unsigned long *max_alloced_p,
@ -1609,7 +1605,7 @@ int mpool_stats(const mpool_t *mp_p, unsigned int *page_size_p,
* log_func -> Log function (defined in mpool.h) which will be called
* with each mpool transaction.
*/
int mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func)
KS_DECLARE(int) mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func)
{
if (mp_p == NULL) {
return MPOOL_ERROR_ARG_NULL;
@ -1651,7 +1647,7 @@ int mpool_set_log_func(mpool_t *mp_p, mpool_log_func_t log_func)
*
* max_pages -> Maximum number of pages used by the library.
*/
int mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages)
KS_DECLARE(int) mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages)
{
if (mp_p == NULL) {
return MPOOL_ERROR_ARG_NULL;
@ -1694,7 +1690,7 @@ int mpool_set_max_pages(mpool_t *mp_p, const unsigned int max_pages)
*
* error -> Error number that we are converting.
*/
const char *mpool_strerror(const int error)
KS_DECLARE(const char *) mpool_strerror(const int error)
{
switch (error) {
case MPOOL_ERROR_NONE:
@ -1748,9 +1744,6 @@ const char *mpool_strerror(const int error)
case MPOOL_ERROR_FREE_ADDR:
return "invalid internal free address";
break;
case MPOOL_ERROR_SBRK_CONTIG:
return "sbrk did not return contiguous memory";
break;
case MPOOL_ERROR_NO_PAGES:
return "no available pages left in pool";
break;
@ -1766,3 +1759,15 @@ const char *mpool_strerror(const int error)
return "invalid error code";
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -26,12 +26,14 @@
#include <errno.h> /* for setting errno */
#include <sys/types.h>
#ifndef _WIN32
/* not in Windows! */
/* not in Windows! */
# include <unistd.h>
# include <stdint.h>
#else
#include <Windows.h>
#endif
#ifndef SIMCLIST_NO_DUMPRESTORE
/* includes for dump/restore */
/* includes for dump/restore */
# include <time.h>
# include <sys/uio.h> /* for READ_ERRCHECK() and write() */
# include <fcntl.h> /* for open() etc */
@ -55,6 +57,9 @@
#if defined(_MSC_VER) || defined(__MINGW32__)
/* provide gettimeofday() missing in Windows */
#ifdef _MSC_VER
#pragma comment(lib, "Winmm.lib")
#endif
int gettimeofday(struct timeval *tp, void *tzp) {
DWORD t;
@ -100,7 +105,7 @@ typedef INT64 int64_t;
} while (0);
/* convert 64bit integers from host to network format */
#define hton64(x) (\
#define hton64(x) ( \
htons(1) == 1 ? \
(uint64_t)x /* big endian */ \
: /* little endian */ \
@ -1523,3 +1528,13 @@ static int list_attrOk(const list_t *restrict l) {
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -34,7 +34,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef unix
#if defined(unix) || defined(__APPLE__)
#include <unistd.h>
@ -43,8 +43,12 @@
#include <io.h>
#include <malloc.h>
#define NO_MMAP
#ifndef open
#define open _open
#endif
#ifndef fdopen
#define fdopen _fdopen
#endif
#endif
#ifndef NO_MMAP
@ -627,7 +631,7 @@ static int external_compare(const void *p1, const void *p2,
*
* err_bp - Pointer to an integer which will be set with 1 if an error
* has occurred. It cannot be NULL.
*/
*/
static int external_compare_pos(const void *p1, const void *p2,
table_compare_t user_compare,
const table_t *table_p, int *err_bp)
@ -4077,3 +4081,14 @@ const char *table_strerror(const int error)
return INVALID_ERROR;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -293,3 +293,14 @@ int main(int argc, char **argv)
exit(0);
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

180
libs/libks/src/win/mman.c Normal file
View File

@ -0,0 +1,180 @@
#include <windows.h>
#include <errno.h>
#include <io.h>
#include "mman.h"
#ifndef FILE_MAP_EXECUTE
#define FILE_MAP_EXECUTE 0x0020
#endif /* FILE_MAP_EXECUTE */
static int __map_mman_error(const DWORD err, const int deferr)
{
if (err == 0)
return 0;
//TODO: implement
return err;
}
static DWORD __map_mmap_prot_page(const int prot)
{
DWORD protect = 0;
if (prot == PROT_NONE)
return protect;
if ((prot & PROT_EXEC) != 0)
{
protect = ((prot & PROT_WRITE) != 0) ?
PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
}
else
{
protect = ((prot & PROT_WRITE) != 0) ?
PAGE_READWRITE : PAGE_READONLY;
}
return protect;
}
static DWORD __map_mmap_prot_file(const int prot)
{
DWORD desiredAccess = 0;
if (prot == PROT_NONE)
return desiredAccess;
if ((prot & PROT_READ) != 0)
desiredAccess |= FILE_MAP_READ;
if ((prot & PROT_WRITE) != 0)
desiredAccess |= FILE_MAP_WRITE;
if ((prot & PROT_EXEC) != 0)
desiredAccess |= FILE_MAP_EXECUTE;
return desiredAccess;
}
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
{
HANDLE fm, h;
void * map = MAP_FAILED;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4293)
#endif
const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
const DWORD protect = __map_mmap_prot_page(prot);
const DWORD desiredAccess = __map_mmap_prot_file(prot);
const off_t maxSize = off + (off_t)len;
const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
errno = 0;
if (len == 0
/* Unsupported flag combinations */
|| (flags & MAP_FIXED) != 0
/* Usupported protection combinations */
|| prot == PROT_EXEC)
{
errno = EINVAL;
return MAP_FAILED;
}
h = ((flags & MAP_ANONYMOUS) == 0) ?
(HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return MAP_FAILED;
}
fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
if (fm == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}
map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
CloseHandle(fm);
if (map == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}
return map;
}
int munmap(void *addr, size_t len)
{
if (UnmapViewOfFile(addr))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int _mprotect(void *addr, size_t len, int prot)
{
DWORD newProtect = __map_mmap_prot_page(prot);
DWORD oldProtect = 0;
if (VirtualProtect(addr, len, newProtect, &oldProtect))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int msync(void *addr, size_t len, int flags)
{
if (FlushViewOfFile(addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int mlock(const void *addr, size_t len)
{
if (VirtualLock((LPVOID)addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int munlock(const void *addr, size_t len)
{
if (VirtualUnlock((LPVOID)addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}

View File

@ -0,0 +1,55 @@
/*
* sys/mman.h
* mman-win32
*/
#ifndef _SYS_MMAN_H_
#define _SYS_MMAN_H_
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
/* All the headers include this file. */
#ifndef _MSC_VER
#include <_mingw.h>
#endif
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define MAP_FILE 0
#define MAP_SHARED 1
#define MAP_PRIVATE 2
#define MAP_TYPE 0xf
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *)-1)
/* Flags for msync. */
#define MS_ASYNC 1
#define MS_SYNC 2
#define MS_INVALIDATE 4
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
int munmap(void *addr, size_t len);
int _mprotect(void *addr, size_t len, int prot);
int msync(void *addr, size_t len, int flags);
int mlock(const void *addr, size_t len);
int munlock(const void *addr, size_t len);
#ifdef __cplusplus
};
#endif
#endif /* _SYS_MMAN_H_ */

View File

@ -0,0 +1,47 @@
#include <stdlib.h>
#include <stdio.h>
#include "mpool.h"
#include <string.h>
int main(int argc, char **argv)
{
mpool_t *pool;
int err = 0;
char *str = NULL;
int x = 0;
int bytes = 1024;
if (argc > 1) {
int tmp = atoi(argv[1]);
if (tmp > 0) {
bytes = tmp;
} else {
fprintf(stderr, "INVALID\n");
exit(255);
}
}
pool = mpool_open(MPOOL_FLAG_ANONYMOUS, 0, NULL, &err);
if (!pool || err != MPOOL_ERROR_NONE) {
fprintf(stderr, "ERR: %d [%s]\n", err, mpool_strerror(err));
exit(255);
}
str = mpool_alloc(pool, bytes, &err);
memset(str+x, '.', bytes -1);
*(str+(bytes-1)) = '\0';
printf("%s\n", str);
//mpool_clear(pool);
err = mpool_close(pool);
if (err != MPOOL_ERROR_NONE) {
fprintf(stderr, "ERR: [%s]\n", mpool_strerror(err));
exit(255);
}
exit(0);
}

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{766F7FF4-CF39-4CDF-ABDC-4E9C88568F1F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>testpools</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\testpools.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\libks.vcxproj">
<Project>{70d178d8-1100-4152-86c0-809a91cff832}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\testpools.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,26 +1 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
Wed Feb 11 12:35:25 EST 2015
=======
=======
>>>>>>> sofia rebuild
=======
>>>>>>> sofia rebuild
<<<<<<< HEAD
Wed Jan 7 11:24:56 PST 2015
=======
Tue Jan 6 20:12:24 CST 2015
>>>>>>> sofia update
<<<<<<< HEAD
>>>>>>> sofia update
=======
=======
Wed Jan 7 11:18:02 CST 2015
>>>>>>> sofia rebuild
<<<<<<< HEAD
=======
=======
Mon Jan 12 11:34:52 CST 2015
>>>>>>> sofia rebuild
>>>>>>> sofia rebuild
Wed Sep 9 12:25:38 CDT 2015

View File

@ -1593,10 +1593,6 @@ int nua_client_next_request(nua_client_request_t *cr, int invite)
for (; cr; cr = cr->cr_next) {
if (cr->cr_method == sip_method_cancel)
continue;
if (invite
? cr->cr_method == sip_method_invite
: cr->cr_method != sip_method_invite)
break;
}

View File

@ -10,3 +10,5 @@ src/v27ter_tx_4800_rrc.h
src/v29rx_rrc.h
src/v29tx_rrc.h
INSTALL
test-data/itu/tiff-fx/Makefile
test-data/itu/tiff-fx/Makefile.in

View File

@ -113,7 +113,7 @@ typedef struct _null_hdr
typedef struct _ipv6_hdr
{
char dontcare[6];
u_int8_t nxt_header; /* we only need the next header, so we can determine, if the next header is UDP or not */
uint8_t nxt_header; /* we only need the next header, so we can determine, if the next header is UDP or not */
char dontcare2[33];
} ipv6_hdr;
#endif

View File

@ -52,7 +52,6 @@ switch_log.c
switch_xml.c
switch_config.c
switch_time.c
switch_stfu.c
switch_cpp.cpp
g711.c
switch_pcm.c

View File

@ -309,16 +309,10 @@ struct switch_session_manager {
uint32_t session_limit;
switch_size_t session_id;
switch_queue_t *thread_queue;
switch_thread_t *manager_thread;
switch_mutex_t *mutex;
switch_thread_cond_t *cond;
switch_mutex_t *cond_mutex;
switch_mutex_t *cond2_mutex;
int ready;
int running;
int busy;
int popping;
int starting;
};
extern struct switch_session_manager session_manager;

View File

@ -111,7 +111,6 @@
#include "switch_platform.h"
#include "switch_types.h"
#include "switch_stfu.h"
#include "switch_apr.h"
#include "switch_mprintf.h"
#include "switch_core_db.h"
@ -144,6 +143,7 @@
#include "switch_limit.h"
#include "switch_core_media.h"
#include "switch_core_video.h"
#include "switch_jitterbuffer.h"
#include <libteletone.h>

View File

@ -659,6 +659,8 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypop(switch_queue_t *queue, void
SWITCH_DECLARE(switch_status_t) switch_queue_interrupt_all(switch_queue_t *queue);
SWITCH_DECLARE(switch_status_t) switch_queue_term(switch_queue_t *queue);
/**
* push/add a object to the queue, returning immediatly if the queue is full
*

View File

@ -861,7 +861,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_ses
*/
SWITCH_DECLARE(switch_log_level_t) switch_core_session_get_loglevel(switch_core_session_t *session);
SWITCH_DECLARE(stfu_instance_t *) switch_core_session_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(switch_jb_t *) switch_core_session_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_session_soft_lock(switch_core_session_t *session, uint32_t sec);
SWITCH_DECLARE(void) switch_core_session_soft_unlock(switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_session_set_dmachine(switch_core_session_t *session, switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target);
@ -1651,6 +1651,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode_video(switch_codec_t *c
\param cmd the command to send
\param ctype the type of the arguement
\param cmd_data a void pointer to the data matching the passed type
\param atype the type of the extra arguement
\param cmd_arg a void pointer to the data matching the passed type
\param rtype the type of the response if any
\param ret_data a void pointer to a pointer of return data
\return SWITCH_STATUS_SUCCESS if the command was received
@ -1659,6 +1661,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_control(switch_codec_t *codec,
switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
void **ret_data);

View File

@ -1,3 +1,4 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
@ -107,6 +108,8 @@ typedef struct switch_core_media_params_s {
char *local_sdp_str;
char *last_sdp_str;
char *last_sdp_response;
char *prev_sdp_str;
char *prev_sdp_response;
char *stun_ip;
switch_port_t stun_port;
@ -253,7 +256,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_udptl_mode(switch_core_session
SWITCH_DECLARE(void) switch_core_media_set_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag);
SWITCH_DECLARE(void) switch_core_media_clear_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag);
SWITCH_DECLARE(stfu_instance_t *) switch_core_media_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(switch_jb_t *) switch_core_media_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool);
@ -307,15 +310,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_sess
switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
void **ret_data);
#define switch_core_media_gen_key_frame(_session) switch_core_media_codec_control(_session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_WRITE, \
SCC_VIDEO_REFRESH, SCCT_NONE, NULL, NULL, NULL) \
SCC_VIDEO_GEN_KEYFRAME, SCCT_NONE, NULL, SCCT_NONE, NULL, NULL, NULL) \
#define switch_core_media_write_bandwidth(_session, _val) switch_core_media_codec_control(_session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_WRITE, \
SCC_VIDEO_BANDWIDTH, SCCT_STRING, _val, NULL, NULL) \
SCC_VIDEO_BANDWIDTH, SCCT_STRING, _val, SCCT_NONE, NULL, NULL, NULL) \
SWITCH_DECLARE(switch_timer_t *) switch_core_media_get_timer(switch_core_session_t *session, switch_media_type_t mtype);

View File

@ -254,6 +254,8 @@ SWITCH_DECLARE(void) switch_event_prep_for_delivery_detailed(const char *file, c
SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback,
void *user_data);
SWITCH_DECLARE(switch_status_t) switch_event_get_custom_events(switch_console_callback_match_t **matches);
/*!
\brief Bind an event callback to a specific event
\param id an identifier token of the binder

View File

@ -122,6 +122,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_signal_data(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_signal_data(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_process_indications(switch_core_session_t *session, switch_core_session_message_t *message);
/*!

View File

@ -0,0 +1,79 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_jitterbuffer.h -- Audio/Video Jitter Buffer
*
*/
#ifndef SWITCH_VIDDERBUFFER_H
#define SWITCH_VIDDERBUFFER_H
typedef enum {
SJB_QUEUE_ONLY = (1 << 0)
} switch_jb_flag_t;
typedef enum {
SJB_VIDEO = 0,
SJB_AUDIO
} switch_jb_type_t;
SWITCH_BEGIN_EXTERN_C
SWITCH_DECLARE(switch_status_t) switch_jb_create(switch_jb_t **jbp, switch_jb_type_t type,
uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_jb_set_frames(switch_jb_t *jb, uint32_t min_frame_len, uint32_t max_frame_len);
SWITCH_DECLARE(switch_status_t) switch_jb_peek_frame(switch_jb_t *jb, uint32_t ts, uint16_t seq, int peek, switch_frame_t *frame);
SWITCH_DECLARE(switch_status_t) switch_jb_get_frames(switch_jb_t *jb, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len);
SWITCH_DECLARE(switch_status_t) switch_jb_destroy(switch_jb_t **jbp);
SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb);
SWITCH_DECLARE(void) switch_jb_debug_level(switch_jb_t *jb, uint8_t level);
SWITCH_DECLARE(int) switch_jb_frame_count(switch_jb_t *jb);
SWITCH_DECLARE(int) switch_jb_poll(switch_jb_t *jb);
SWITCH_DECLARE(switch_status_t) switch_jb_put_packet(switch_jb_t *jb, switch_rtp_packet_t *packet, switch_size_t len);
SWITCH_DECLARE(switch_size_t) switch_jb_get_last_read_len(switch_jb_t *jb);
SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp_packet_t *packet, switch_size_t *len);
SWITCH_DECLARE(uint32_t) switch_jb_pop_nack(switch_jb_t *jb);
SWITCH_DECLARE(switch_status_t) switch_jb_get_packet_by_seq(switch_jb_t *jb, uint16_t seq, switch_rtp_packet_t *packet, switch_size_t *len);
SWITCH_DECLARE(void) switch_jb_set_session(switch_jb_t *jb, switch_core_session_t *session);
SWITCH_DECLARE(void) switch_jb_ts_mode(switch_jb_t *jb, uint32_t samples_per_frame, uint32_t samples_per_second);
SWITCH_DECLARE(void) switch_jb_set_flag(switch_jb_t *jb, switch_jb_flag_t flag);
SWITCH_DECLARE(void) switch_jb_clear_flag(switch_jb_t *jb, switch_jb_flag_t flag);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -119,7 +119,7 @@ typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_t *);
typedef switch_status_t (*switch_io_state_run_t) (switch_core_session_t *);
typedef switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
typedef switch_status_t (*switch_io_write_video_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
typedef stfu_instance_t *(*switch_io_get_jb_t) (switch_core_session_t *, switch_media_type_t);
typedef switch_jb_t *(*switch_io_get_jb_t) (switch_core_session_t *, switch_media_type_t);
typedef enum {
SWITCH_IO_OUTGOING_CHANNEL,

View File

@ -128,6 +128,7 @@ typedef int gid_t;
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif // _MSC_VER
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234

View File

@ -328,8 +328,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
SWITCH_DECLARE(switch_timer_t *) switch_rtp_get_media_timer(switch_rtp_t *rtp_session);
SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames);
SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session);
SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames, uint32_t max_frames);
SWITCH_DECLARE(switch_status_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len);
/*!
\brief Acvite a jitter buffer on an RTP session
@ -340,13 +340,13 @@ SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_sess
SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
uint32_t queue_frames,
uint32_t max_queue_frames,
uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift);
uint32_t samples_per_packet, uint32_t samples_per_second);
SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name);
SWITCH_DECLARE(switch_status_t) switch_rtp_deactivate_jitter_buffer(switch_rtp_t *rtp_session);
SWITCH_DECLARE(switch_status_t) switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp_session, switch_bool_t pause);
SWITCH_DECLARE(stfu_instance_t *) switch_rtp_get_jitter_buffer(switch_rtp_t *rtp_session);
SWITCH_DECLARE(switch_jb_t *) switch_rtp_get_jitter_buffer(switch_rtp_t *rtp_session);

View File

@ -1,206 +0,0 @@
/*
* STFU (S)ort (T)ransportable (F)ramed (U)tterances
* Copyright (c) 2007-2014 Anthony Minessale II <anthm@freeswitch.org>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* THOSE WHO DISAGREE MAY CERTAINLY STFU
*/
#ifndef STFU_H
#define STFU_H
#include <switch.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __STUPIDFORMATBUG__
}
#endif
#if !defined(MACOSX) && !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__cplusplus)
#define _XOPEN_SOURCE 600
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#if (_MSC_VER >= 1400) // VC8+
#define stfu_assert(expr) assert(expr);__analysis_assume( expr )
#endif
#ifndef stfu_assert
#define stfu_assert(_x) assert(_x)
#endif
#ifdef _MSC_VER
#if _MSC_VER < 1900
#if !defined(_STDINT) && !defined(uint32_t)
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned long in_addr_t;
#endif
#define snprintf _snprintf
#endif
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <inttypes.h>
#endif
#include <assert.h>
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
typedef SOCKET stfu_socket_t;
#ifndef _STDINT
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef __int8 int8_t;
#endif
typedef intptr_t stfu_ssize_t;
typedef int stfu_filehandle_t;
#define STFU_SOCK_INVALID INVALID_SOCKET
#define strerror_r(num, buf, size) strerror_s(buf, size, num)
#else
#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define STFU_SOCK_INVALID -1
typedef int stfu_socket_t;
typedef ssize_t stfu_ssize_t;
typedef int stfu_filehandle_t;
#endif
#define STFU_PRE __FILE__, __SWITCH_FUNC__, __LINE__
#define STFU_LOG_LEVEL_DEBUG 7
#define STFU_LOG_LEVEL_INFO 6
#define STFU_LOG_LEVEL_NOTICE 5
#define STFU_LOG_LEVEL_WARNING 4
#define STFU_LOG_LEVEL_ERROR 3
#define STFU_LOG_LEVEL_CRIT 2
#define STFU_LOG_LEVEL_ALERT 1
#define STFU_LOG_LEVEL_EMERG 0
#define STFU_LOG_DEBUG STFU_PRE, STFU_LOG_LEVEL_DEBUG
#define STFU_LOG_INFO STFU_PRE, STFU_LOG_LEVEL_INFO
#define STFU_LOG_NOTICE STFU_PRE, STFU_LOG_LEVEL_NOTICE
#define STFU_LOG_WARNING STFU_PRE, STFU_LOG_LEVEL_WARNING
#define STFU_LOG_ERROR STFU_PRE, STFU_LOG_LEVEL_ERROR
#define STFU_LOG_CRIT STFU_PRE, STFU_LOG_LEVEL_CRIT
#define STFU_LOG_ALERT STFU_PRE, STFU_LOG_LEVEL_ALERT
#define STFU_LOG_EMERG STFU_PRE, STFU_LOG_LEVEL_EMERG
typedef void (*stfu_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
int stfu_vasprintf(char **ret, const char *fmt, va_list ap);
extern stfu_logger_t stfu_log;
/*! Sets the logger for libstfu. Default is the null_logger */
void stfu_global_set_logger(stfu_logger_t logger);
/*! Sets the default log level for libstfu */
void stfu_global_set_default_logger(int level);
#define STFU_DATALEN 16384
#define STFU_QLEN 300
#define STFU_MAX_TRACK 256
typedef enum {
STFU_IT_FAILED,
STFU_IT_WORKED,
STFU_IM_DONE,
STFU_ITS_TOO_LATE
} stfu_status_t;
struct stfu_frame {
uint32_t ts;
uint16_t seq;
uint32_t pt;
uint8_t data[STFU_DATALEN];
size_t dlen;
uint8_t was_read;
uint8_t plc;
};
typedef struct stfu_frame stfu_frame_t;
struct stfu_instance;
typedef struct stfu_instance stfu_instance_t;
typedef struct {
uint32_t qlen;
uint32_t packet_in_count;
uint32_t clean_count;
uint32_t consecutive_good_count;
uint32_t consecutive_bad_count;
double period_jitter_percent;
double period_missing_percent;
} stfu_report_t;
typedef void (*stfu_n_call_me_t)(stfu_instance_t *i, void *);
void stfu_n_report(stfu_instance_t *i, stfu_report_t *r);
void stfu_n_destroy(stfu_instance_t **i);
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms);
stfu_status_t _stfu_n_resize(stfu_instance_t *i, uint32_t qlen, int line);
#define stfu_n_resize(_i, _ql) _stfu_n_resize(_i, _ql, __LINE__)
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint16_t seq, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last);
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i);
SWITCH_DECLARE(int32_t) stfu_n_peek_frame(stfu_instance_t *jb, uint32_t timestamp, uint16_t seq, uint16_t distance, stfu_frame_t **rframe);
void _stfu_n_reset(stfu_instance_t *i, const char *file, const char *func, int line);
#define stfu_n_reset(_i) _stfu_n_reset(_i, STFU_PRE)
stfu_status_t stfu_n_sync(stfu_instance_t *i, uint32_t packets);
void stfu_n_call_me(stfu_instance_t *i, stfu_n_call_me_t callback, void *udata);
void stfu_n_debug(stfu_instance_t *i, const char *name);
int32_t stfu_n_get_drift(stfu_instance_t *i);
int32_t stfu_n_get_most_qlen(stfu_instance_t *i);
#define stfu_im_done(i) stfu_n_add_data(i, 0, 0, NULL, 0, 0, 1)
#define stfu_n_eat(i,t,s,p,d,l,tt) stfu_n_add_data(i, t, s, p, d, l, tt, 0)
#ifdef __cplusplus
}
#endif
#endif /*STFU_H*/

View File

@ -752,6 +752,7 @@ typedef enum {
SWITCH_RTP_FLAG_MUTE,
SWITCH_RTP_FLAG_NACK,
SWITCH_RTP_FLAG_TMMBR,
SWITCH_RTP_FLAG_GEN_TS_DELTA,
SWITCH_RTP_FLAG_INVALID
} switch_rtp_flag_t;
@ -1077,6 +1078,8 @@ typedef enum {
SWITCH_MESSAGE_INDICATE_HARD_MUTE,
SWITCH_MESSAGE_INDICATE_BITRATE_REQ,
SWITCH_MESSAGE_INDICATE_BITRATE_ACK,
SWITCH_MESSAGE_INDICATE_CODEC_DEBUG_REQ,
SWITCH_MESSAGE_INDICATE_CODEC_SPECIFIC_REQ,
SWITCH_MESSAGE_REFER_EVENT,
SWITCH_MESSAGE_ANSWER_EVENT,
SWITCH_MESSAGE_PROGRESS_EVENT,
@ -1473,6 +1476,7 @@ typedef enum {
CF_3PCC,
CF_VIDEO_PASSIVE,
CF_NOVIDEO,
CF_VIDEO_BITRATE_UNMANAGABLE,
CF_VIDEO_ECHO,
CF_VIDEO_BLANK,
CF_SLA_INTERCEPT,
@ -2240,10 +2244,12 @@ typedef switch_status_t (*switch_core_codec_video_encode_func_t) (switch_codec_t
typedef switch_status_t (*switch_core_codec_video_decode_func_t) (switch_codec_t *codec, switch_frame_t *frame);
typedef enum {
SCC_VIDEO_REFRESH = 0,
SCC_VIDEO_GEN_KEYFRAME = 0,
SCC_VIDEO_BANDWIDTH,
SCC_VIDEO_RESET,
SCC_AUDIO_PACKET_LOSS
SCC_AUDIO_PACKET_LOSS,
SCC_DEBUG,
SCC_CODEC_SPECIFIC
} switch_codec_control_command_t;
typedef enum {
@ -2261,6 +2267,8 @@ typedef switch_status_t (*switch_core_codec_control_func_t) (switch_codec_t *cod
switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
void **ret_data);
@ -2554,8 +2562,8 @@ typedef struct switch_waitlist_s {
uint32_t revents;
} switch_waitlist_t;
struct switch_vb_s;
typedef struct switch_vb_s switch_vb_t;
struct switch_jb_s;
typedef struct switch_jb_s switch_jb_t;
struct switch_img_txt_handle_s;
typedef struct switch_img_txt_handle_s switch_img_txt_handle_t;

View File

@ -110,10 +110,4 @@ SWITCH_DECLARE(int) switch_u8_strlen(char *s);
SWITCH_DECLARE(int) switch_u8_is_locale_utf8(char *locale);
/* printf where the format string and arguments may be in UTF-8.
you can avoid this function and just use ordinary printf() if the current
locale is UTF-8. */
SWITCH_DECLARE(int) switch_u8_vprintf(char *fmt, va_list ap);
SWITCH_DECLARE(int) switch_u8_printf(char *fmt, ...);
SWITCH_DECLARE(uint32_t) switch_u8_get_char(char *s, int *i);

View File

@ -1,70 +0,0 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_vidderbuffer.h -- Video Buffer
*
*/
#ifndef SWITCH_VIDDERBUFFER_H
#define SWITCH_VIDDERBUFFER_H
typedef enum {
SVB_QUEUE_ONLY = (1 << 0)
} switch_vb_flag_t;
SWITCH_BEGIN_EXTERN_C
SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_vb_set_frames(switch_vb_t *vb, uint32_t min_frame_len, uint32_t max_frame_len);
SWITCH_DECLARE(switch_status_t) switch_vb_get_frames(switch_vb_t *vb, uint32_t *min_frame_len, uint32_t *max_frame_len);
SWITCH_DECLARE(switch_status_t) switch_vb_destroy(switch_vb_t **vbp);
SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb);
SWITCH_DECLARE(void) switch_vb_debug_level(switch_vb_t *vb, uint8_t level);
SWITCH_DECLARE(int) switch_vb_frame_count(switch_vb_t *vb);
SWITCH_DECLARE(int) switch_vb_poll(switch_vb_t *vb);
SWITCH_DECLARE(switch_status_t) switch_vb_push_packet(switch_vb_t *vb, switch_rtp_packet_t *packet, switch_size_t len);
SWITCH_DECLARE(switch_status_t) switch_vb_put_packet(switch_vb_t *vb, switch_rtp_packet_t *packet, switch_size_t len);
SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp_packet_t *packet, switch_size_t *len);
SWITCH_DECLARE(uint32_t) switch_vb_pop_nack(switch_vb_t *vb);
SWITCH_DECLARE(switch_status_t) switch_vb_get_packet_by_seq(switch_vb_t *vb, uint16_t seq, switch_rtp_packet_t *packet, switch_size_t *len);
SWITCH_DECLARE(void) switch_vb_set_flag(switch_vb_t *vb, switch_vb_flag_t flag);
SWITCH_DECLARE(void) switch_vb_clear_flag(switch_vb_t *vb, switch_vb_flag_t flag);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -1284,6 +1284,8 @@ static switch_status_t switch_h264_control(switch_codec_t *codec,
switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
void **ret_data) {
@ -1292,7 +1294,7 @@ static switch_status_t switch_h264_control(switch_codec_t *codec,
h264_codec_context_t *context = (h264_codec_context_t *)codec->private_info;
switch(cmd) {
case SCC_VIDEO_REFRESH:
case SCC_VIDEO_GEN_KEYFRAME:
context->need_key_frame = 1;
break;
case SCC_VIDEO_BANDWIDTH:

View File

@ -139,9 +139,11 @@ typedef struct record_helper_s {
AVFormatContext *fc;
MediaStream *video_st;
switch_timer_t *timer;
switch_timer_t *other_timer;
int in_callback;
switch_queue_t *video_queue;
switch_thread_t *video_thread;
switch_mm_t *mm;
} record_helper_t;
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
@ -242,7 +244,8 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
}
mst->st->id = fc->nb_streams - 1;
c = mst->st->codec;
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "id:%d den:%d num:%d\n", mst->st->id, mst->st->time_base.den, mst->st->time_base.num);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "id:%d den:%d num:%d\n", mst->st->id, mst->st->time_base.den, mst->st->time_base.num);
if (threads > 4) {
threads = 4;
@ -256,6 +259,11 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
c->channels = mst->channels;
c->channel_layout = av_get_default_channel_layout(c->channels);
mst->st->time_base.den = 1000;
mst->st->time_base.num = 1;
c->time_base.den = 1000;
c->time_base.num = 1;
if (mm) {
if (mm->ab) {
c->bit_rate = mm->ab * 1024;
@ -273,7 +281,11 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
if (mm->vbuf) {
buffer_bytes = mm->vbuf;
}
if (mm->fps) {
fps = mm->fps;
} else {
mm->fps = fps;
}
if (mm->vw && mm->vh) {
mst->width = mm->vw;
@ -469,26 +481,50 @@ static switch_status_t open_audio(AVFormatContext *fc, AVCodec *codec, MediaStre
return SWITCH_STATUS_SUCCESS;
}
static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *obj)
{
record_helper_t *eh = (record_helper_t *) obj;
void *pop;
switch_image_t *img, *last_img = NULL, *tmp_img = NULL;
switch_size_t size;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "video thread start\n");
for(;;) {
AVPacket pkt = { 0 };
int got_packet;
int ret = -1;
int ret = -1, popped = 0;
do {
switch_status_t status;
img = NULL;
if (switch_queue_pop_timeout(eh->video_queue, &pop, 66000) == SWITCH_STATUS_SUCCESS) {
if (!pop) break;
img = (switch_image_t *) pop;
if (!popped) {
status = switch_queue_pop(eh->video_queue, &pop);
popped++;
} else {
status = switch_queue_trypop(eh->video_queue, &pop);
}
if (status == SWITCH_STATUS_SUCCESS) {
switch_img_free(&img);
if (!pop) {
goto endfor;
}
img = (switch_image_t *)pop;
} else {
if (img) {
break;
} else {
popped = 0;
continue;
}
}
size = switch_queue_size(eh->video_queue);
} while(img && size > 1);
if (last_img && (last_img->d_w != img->d_w || last_img->d_h != img->d_h)) {
/* scale to match established stream */
@ -500,17 +536,6 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
switch_img_free(&last_img);
last_img = img;
} else {
if (last_img) {
img = last_img;
} else {
continue;
}
}
if (!img) {
continue;
}
//switch_mutex_lock(eh->mutex);
@ -527,6 +552,14 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
fill_avframe(eh->video_st->frame, img);
switch_core_timer_sync(eh->timer);
if (eh->other_timer) {
if (eh->timer->samplecount > eh->other_timer->samplecount) {
int sleepfor = (eh->timer->samplecount - eh->other_timer->samplecount) * 1000;
switch_yield(sleepfor);
switch_core_timer_sync(eh->timer);
}
}
if (eh->video_st->frame->pts == eh->timer->samplecount) {
// never use the same pts, or the encoder coughs
eh->video_st->frame->pts++;
@ -555,6 +588,8 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
//switch_mutex_unlock(eh->mutex);
}
endfor:
switch_img_free(&last_img);
while(switch_queue_trypop(eh->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
@ -1041,7 +1076,8 @@ struct av_file_context {
switch_mutex_t *mutex;
switch_buffer_t *buf;
switch_buffer_t *audio_buffer;
switch_timer_t timer;
switch_timer_t video_timer;
switch_timer_t audio_timer;
int offset;
int audio_start;
int vid_ready;
@ -1398,9 +1434,6 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
}
switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
switch_core_timer_init(&context->timer, "soft", 1, 1000, context->pool);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "init timer\n");
switch_buffer_create_dynamic(&context->audio_buffer, 512, 512, 0);
if (!context->audio_buffer) {
@ -1529,6 +1562,10 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
handle->speed = 0;
handle->pos = 0;
switch_core_timer_init(&context->audio_timer, "soft", 1, 1, /*handle->samplerate / 1000,*/ context->pool);
switch_core_timer_init(&context->video_timer, "soft", 1, 1, context->pool);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz %s\n",
file, handle->samplerate, switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) ? " with VIDEO" : "");
@ -1540,8 +1577,12 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
mod_avformat_destroy_output_context(context);
}
if (context->timer.interval) {
switch_core_timer_destroy(&context->timer);
if (context->video_timer.interval) {
switch_core_timer_destroy(&context->video_timer);
}
if (context->audio_timer.interval) {
switch_core_timer_destroy(&context->audio_timer);
}
if (context->audio_buffer) {
@ -1599,8 +1640,12 @@ static switch_status_t av_file_close(switch_file_handle_t *handle)
mod_avformat_destroy_output_context(context);
}
if (context->timer.interval) {
switch_core_timer_destroy(&context->timer);
if (context->video_timer.interval) {
switch_core_timer_destroy(&context->video_timer);
}
if (context->audio_timer.interval) {
switch_core_timer_destroy(&context->audio_timer);
}
switch_img_free(&context->last_img);
@ -1684,15 +1729,13 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
context->offset = 0;
}
switch_buffer_write(context->audio_buffer, data, datalen);
bytes = context->audio_st.frame->nb_samples * 2 * context->audio_st.st->codec->channels;
//inuse = switch_buffer_inuse(context->audio_buffer);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "inuse: %d samples: %d bytes: %d\n", inuse, context->audio_st.frame->nb_samples, bytes);
while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes * 5) {
while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes) {
AVPacket pkt = { 0 };
int got_packet = 0;
int ret;
@ -1718,13 +1761,15 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
context->audio_st.tmp_frame->pts = context->audio_st.next_pts;
context->audio_st.next_pts += context->audio_st.frame->nb_samples;
ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.tmp_frame, &got_packet);
} else {
av_frame_make_writable(context->audio_st.frame);
switch_buffer_read(context->audio_buffer, context->audio_st.frame->data[0], bytes);
context->audio_st.frame->pts = context->audio_st.next_pts;
context->audio_st.next_pts += context->audio_st.frame->nb_samples;
switch_core_timer_sync(&context->audio_timer);
context->audio_st.frame->pts = context->audio_timer.samplecount;
//context->audio_st.frame->pts = context->audio_st.next_pts;
//context->audio_st.next_pts += context->audio_st.frame->nb_samples;
ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.frame, &got_packet);
}
@ -1744,6 +1789,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
}
}
break;
}
@ -1917,11 +1963,9 @@ static switch_status_t av_file_write_video(switch_file_handle_t *handle, switch_
context->eh.mutex = context->mutex;
context->eh.video_st = &context->video_st;
context->eh.fc = context->fc;
if (switch_core_timer_init(&context->timer, "soft", 1, 1, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Activation Fail\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
context->eh.timer = &context->timer;
context->eh.mm = &handle->mm;
context->eh.timer = &context->video_timer;
context->eh.other_timer = &context->audio_timer;
switch_queue_create(&context->eh.video_queue, SWITCH_CORE_QUEUE_LEN, handle->memory_pool);
switch_threadattr_create(&thd_attr, handle->memory_pool);

View File

@ -216,6 +216,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
if (switch_event_reserve_subclass(AVMD_EVENT_BEEP) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", AVMD_EVENT_BEEP);
return SWITCH_STATUS_TERM;
}
switch_log_printf(
SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE,
@ -322,6 +329,8 @@ SWITCH_STANDARD_APP(avmd_start_function)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
{
switch_event_free_subclass(AVMD_EVENT_BEEP);
#ifdef FASTMATH
destroy_fast_acosf();
#endif

View File

@ -377,6 +377,24 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load)
{
switch_application_interface_t *app_interface = NULL;
if (switch_event_reserve_subclass(BERT_EVENT_TIMEOUT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_TIMEOUT);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(BERT_EVENT_LOST_SYNC) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_LOST_SYNC);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(BERT_EVENT_IN_SYNC) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_IN_SYNC);
return SWITCH_STATUS_TERM;
}
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE);
@ -385,6 +403,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_bert_shutdown)
{
switch_event_free_subclass(BERT_EVENT_TIMEOUT);
switch_event_free_subclass(BERT_EVENT_LOST_SYNC);
switch_event_free_subclass(BERT_EVENT_IN_SYNC);
return SWITCH_STATUS_UNLOAD;
}

View File

@ -3421,6 +3421,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
switch_api_interface_t *api_interface;
switch_status_t status;
if (switch_event_reserve_subclass(CALLCENTER_EVENT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", CALLCENTER_EVENT);
return SWITCH_STATUS_TERM;
}
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
@ -3495,6 +3501,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown)
switch_ssize_t keylen;
int sanity = 0;
switch_event_free_subclass(CALLCENTER_EVENT);
switch_mutex_lock(globals.mutex);
if (globals.running == 1) {
globals.running = 0;

View File

@ -4086,6 +4086,100 @@ SWITCH_STANDARD_API(uuid_video_bitrate_function)
return SWITCH_STATUS_SUCCESS;
}
#define CODEC_DEBUG_SYNTAX "<uuid> audio|video <level>"
SWITCH_STANDARD_API(uuid_codec_debug_function)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *mycmd = NULL, *argv[3] = { 0 };
int argc = 0;
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 3) {
stream->write_function(stream, "-USAGE: %s\n", CODEC_DEBUG_SYNTAX);
} else {
switch_core_session_t *lsession = NULL;
if ((lsession = switch_core_session_locate(argv[0]))) {
int level = atoi(argv[2]);
switch_media_type_t type = SWITCH_MEDIA_TYPE_AUDIO;
switch_core_session_message_t msg = { 0 };
if (!strcasecmp(argv[1], "video")) {
type = SWITCH_MEDIA_TYPE_VIDEO;
}
if (level < 0) level = 0;
msg.message_id = SWITCH_MESSAGE_INDICATE_CODEC_DEBUG_REQ;
msg.numeric_arg = level;
msg.numeric_reply = type;
msg.from = __FILE__;
switch_core_session_receive_message(lsession, &msg);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
#define CODEC_PARAM_SYNTAX "<uuid> audio|video read|write <param> <val>"
SWITCH_STANDARD_API(uuid_codec_param_function)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *mycmd = NULL, *argv[5] = { 0 };
int argc = 0;
switch_core_session_message_t msg = { 0 };
msg.string_array_arg[4] = "NOT SENT";
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 3) {
stream->write_function(stream, "-USAGE: %s\n", CODEC_PARAM_SYNTAX);
} else {
switch_core_session_t *lsession = NULL;
if ((lsession = switch_core_session_locate(argv[0]))) {
msg.message_id = SWITCH_MESSAGE_INDICATE_CODEC_SPECIFIC_REQ;
msg.string_array_arg[0] = argv[1];
msg.string_array_arg[1] = argv[2];
msg.string_array_arg[2] = argv[3];
msg.string_array_arg[3] = argv[4];
msg.from = __FILE__;
switch_core_session_receive_message(lsession, &msg);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Command sent reply: [%s]\n", msg.string_array_arg[4]);
} else {
stream->write_function(stream, "-ERR Operation Failed [%s]\n", msg.string_array_arg[4]);
}
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
#define DEBUG_MEDIA_SYNTAX "<uuid> <read|write|both|vread|vwrite|vboth|all> <on|off>"
SWITCH_STANDARD_API(uuid_debug_media_function)
@ -6967,6 +7061,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "Execute dialplan application", uuid_broadcast_function, BROADCAST_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_buglist", "List media bugs on a session", uuid_buglist_function, BUGLIST_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_chat", "Send a chat message", uuid_chat, UUID_CHAT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_codec_debug", "Send codec a debug message", uuid_codec_debug_function, CODEC_DEBUG_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_codec_param", "Send codec a param", uuid_codec_param_function, CODEC_PARAM_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_debug_media", "Debug media", uuid_debug_media_function, DEBUG_MEDIA_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_deflect", "Send a deflect", uuid_deflect, UUID_DEFLECT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_displace", "Displace audio", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
@ -7144,6 +7240,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
switch_console_set_complete("add uuid_broadcast ::console::list_uuid");
switch_console_set_complete("add uuid_buglist ::console::list_uuid");
switch_console_set_complete("add uuid_chat ::console::list_uuid");
switch_console_set_complete("add uuid_codec_debug ::console::list_uuid audio");
switch_console_set_complete("add uuid_codec_debug ::console::list_uuid video");
switch_console_set_complete("add uuid_codec_param ::console::list_uuid audio read");
switch_console_set_complete("add uuid_codec_param ::console::list_uuid audio write");
switch_console_set_complete("add uuid_codec_param ::console::list_uuid video read");
switch_console_set_complete("add uuid_codec_param ::console::list_uuid video write");
switch_console_set_complete("add uuid_debug_media ::console::list_uuid");
switch_console_set_complete("add uuid_deflect ::console::list_uuid");
switch_console_set_complete("add uuid_displace ::console::list_uuid");

View File

@ -401,7 +401,7 @@ switch_status_t conference_api_sub_conference_video_vmute_snap(conference_member
if (member == NULL)
return SWITCH_STATUS_GENERR;
if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
return SWITCH_STATUS_SUCCESS;
}
@ -430,7 +430,7 @@ switch_status_t conference_api_sub_vmute(conference_member_t *member, switch_str
if (member == NULL)
return SWITCH_STATUS_GENERR;
if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
return SWITCH_STATUS_SUCCESS;
}
@ -486,7 +486,7 @@ switch_status_t conference_api_sub_unvmute(conference_member_t *member, switch_s
if (member == NULL)
return SWITCH_STATUS_GENERR;
if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
return SWITCH_STATUS_SUCCESS;
}

View File

@ -378,7 +378,7 @@ void conference_event_la_command_handler(switch_live_array_t *la, const char *cm
void conference_event_adv_la(conference_obj_t *conference, conference_member_t *member, switch_bool_t join)
{
//if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
//if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
switch_channel_set_flag(member->channel, CF_VIDEO_REFRESH_REQ);
switch_core_media_gen_key_frame(member->session);
//}

View File

@ -170,7 +170,7 @@ void conference_member_update_status_field(conference_member_t *member)
if (switch_channel_test_flag(member->channel, CF_VIDEO) || member->avatar_png_img) {
video = cJSON_CreateObject();
cJSON_AddItemToObject(video, "avatarPresented", cJSON_CreateBool(!!member->avatar_png_img));
cJSON_AddItemToObject(video, "mediaFlow", cJSON_CreateString(member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY ? "sendOnly" : "sendRecv"));
cJSON_AddItemToObject(video, "mediaFlow", cJSON_CreateString(switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY ? "sendOnly" : "sendRecv"));
cJSON_AddItemToObject(video, "muted", cJSON_CreateBool(!conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN)));
cJSON_AddItemToObject(video, "floor", cJSON_CreateBool(member && member->id == member->conference->video_floor_holder));
if (member && member->id == member->conference->video_floor_holder && conference_utils_test_flag(member->conference, CFLAG_VID_FLOOR_LOCK)) {
@ -702,10 +702,6 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
switch_mutex_unlock(conference->canvas_mutex);
}
if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
conference_utils_member_clear_flag_locked(member, MFLAG_CAN_BE_SEEN);
}
conference->members = member;
conference_utils_member_set_flag_locked(member, MFLAG_INTREE);
switch_mutex_unlock(conference->member_mutex);
@ -713,6 +709,11 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
if (!conference_utils_member_test_flag(member, MFLAG_NOCHANNEL)) {
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
conference_utils_member_clear_flag_locked(member, MFLAG_CAN_BE_SEEN);
}
if (conference_utils_member_test_flag(member, MFLAG_GHOST)) {
conference->count_ghosts++;
} else {
@ -728,7 +729,6 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
conference_send_presence(conference);
channel = switch_core_session_get_channel(member->session);
member->video_flow = switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO);
conference_video_check_avatar(member, SWITCH_FALSE);
@ -922,6 +922,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
member->status_field = cJSON_CreateString("");
cJSON_AddItemToArray(member->json, member->status_field);
if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) {
switch_channel_get_variables(member->channel, &var_event);
dvars = cJSON_CreateObject();
@ -939,6 +940,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
cJSON_AddItemToArray(member->json, dvars);
switch_event_destroy(&var_event);
}
cJSON_AddItemToArray(member->json, cJSON_CreateNull());
@ -1158,6 +1160,8 @@ switch_status_t conference_member_del(conference_obj_t *conference, conference_m
conference->count--;
}
conference_video_check_flush(member);
if (conference_utils_member_test_flag(member, MFLAG_ENDCONF)) {
if (!--conference->end_count) {
//conference_utils_set_flag_locked(conference, CFLAG_DESTRUCT);

View File

@ -888,7 +888,7 @@ switch_status_t conference_video_attach_video_layer(conference_member_t *member,
return SWITCH_STATUS_FALSE;
}
if (member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY && !member->avatar_png_img) {
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY && !member->avatar_png_img) {
return SWITCH_STATUS_FALSE;
}
@ -1200,7 +1200,7 @@ void conference_video_destroy_canvas(mcu_canvas_t **canvasP) {
void conference_video_write_canvas_image_to_codec_group(conference_obj_t *conference, mcu_canvas_t *canvas, codec_set_t *codec_set,
int codec_index, uint32_t timestamp, switch_bool_t need_refresh,
switch_bool_t need_keyframe, switch_bool_t need_reset)
switch_bool_t send_keyframe, switch_bool_t need_reset)
{
conference_member_t *imember;
@ -1219,12 +1219,12 @@ void conference_video_write_canvas_image_to_codec_group(conference_obj_t *confer
if (need_reset) {
int type = 1; // sum flags: 1 encoder; 2; decoder
switch_core_codec_control(&codec_set->codec, SCC_VIDEO_RESET, SCCT_INT, (void *)&type, NULL, NULL);
switch_core_codec_control(&codec_set->codec, SCC_VIDEO_RESET, SCCT_INT, (void *)&type, SCCT_NONE, NULL, NULL, NULL);
need_refresh = SWITCH_TRUE;
}
if (need_refresh || need_keyframe) {
switch_core_codec_control(&codec_set->codec, SCC_VIDEO_REFRESH, SCCT_NONE, NULL, NULL, NULL);
if (send_keyframe) {
switch_core_codec_control(&codec_set->codec, SCC_VIDEO_GEN_KEYFRAME, SCCT_NONE, NULL, SCCT_NONE, NULL, NULL, NULL);
}
do {
@ -1264,18 +1264,15 @@ void conference_video_write_canvas_image_to_codec_group(conference_obj_t *confer
continue;
}
if (imember->video_flow == SWITCH_MEDIA_FLOW_RECVONLY) {
continue;
}
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
continue;
}
//if (need_refresh) {
// switch_core_session_request_video_refresh(imember->session);
//}
if (need_refresh) {
switch_core_session_request_video_refresh(imember->session);
}
//switch_core_session_write_encoded_video_frame(imember->session, frame, 0, 0);
switch_set_flag(frame, SFF_ENCODED);
@ -1432,6 +1429,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_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);
}
@ -1459,13 +1457,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
void *pop;
switch_frame_t *frame;
int loops = 0;
switch_time_t last = 0;
if (switch_thread_rwlock_tryrdlock(member->rwlock) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
while(conference_utils_member_test_flag(member, MFLAG_RUNNING)) {
if (conference_utils_member_test_flag(member, MFLAG_RUNNING)) {
if (switch_queue_pop(member->mux_out_queue, &pop) == SWITCH_STATUS_SUCCESS) {
mcu_layer_t *layer = NULL;
mcu_canvas_t *canvas = NULL;
@ -1489,6 +1487,21 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
switch_core_session_write_video_frame(member->session, frame, SWITCH_IO_FLAG_NONE, 0);
}
if (!switch_test_flag(frame, SFF_ENCODED) || frame->m) {
switch_time_t now = switch_time_now();
if (last) {
int delta = now - last;
if (delta > member->conference->video_fps.ms * 2) {
switch_core_session_request_video_refresh(member->session);
}
}
last = now;
}
switch_frame_buffer_free(member->fb, &frame);
}
@ -1515,7 +1528,6 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
}
}
}
}
while (switch_queue_trypop(member->mux_out_queue, &pop) == SWITCH_STATUS_SUCCESS) {
if (pop) {
@ -1571,7 +1583,7 @@ void conference_video_check_avatar(conference_member_t *member, switch_bool_t fo
canvas = member->conference->canvases[member->canvas_id];
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS) &&
(!switch_channel_test_flag(member->channel, CF_VIDEO) || member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY)) {
(!switch_channel_test_flag(member->channel, CF_VIDEO) || switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY)) {
return;
}
@ -1581,7 +1593,7 @@ void conference_video_check_avatar(conference_member_t *member, switch_bool_t fo
member->avatar_patched = 0;
if (!force && switch_channel_test_flag(member->channel, CF_VIDEO) && member->video_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
if (!force && switch_channel_test_flag(member->channel, CF_VIDEO) && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
conference_utils_member_set_flag_locked(member, MFLAG_ACK_VIDEO);
} else {
if (member->conference->no_video_avatar) {
@ -1705,7 +1717,7 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca
if (!layer &&
(canvas->layers_used < canvas->total_layers ||
(avatar_layers && !member->avatar_png_img) || conference_utils_member_test_flag(member, MFLAG_MOD)) &&
(member->avatar_png_img || member->video_flow != SWITCH_MEDIA_FLOW_SENDONLY)) {
(member->avatar_png_img || switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY)) {
/* find an empty layer */
for (i = 0; i < canvas->total_layers; i++) {
mcu_layer_t *xlayer = &canvas->layers[i];
@ -1778,7 +1790,7 @@ void conference_video_pop_next_image(conference_member_t *member, switch_image_t
size = switch_queue_size(member->video_queue);
} while(size > 1);
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) && member->video_layer_id > -1 && member->video_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) && member->video_layer_id > -1 && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
if (img) {
member->good_img++;
if ((member->good_img % (int)(member->conference->video_fps.fps * 10)) == 0) {
@ -1817,7 +1829,10 @@ void conference_video_pop_next_image(conference_member_t *member, switch_image_t
void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_t *layer)
{
if (conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) && !member->managed_kps) {
if (switch_channel_test_flag(member->channel, CF_VIDEO_BITRATE_UNMANAGABLE)) {
member->managed_kps = 0;
} else if (conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) && !member->managed_kps) {
switch_core_session_message_t msg = { 0 };
int kps;
int w = 320;
@ -1902,7 +1917,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
packet = switch_core_alloc(conference->pool, SWITCH_RTP_MAX_BUF_LEN);
while (conference_globals.running && !conference_utils_test_flag(conference, CFLAG_DESTRUCT) && conference_utils_test_flag(conference, CFLAG_VIDEO_MUXING)) {
switch_bool_t need_refresh = SWITCH_FALSE, need_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
switch_bool_t need_refresh = SWITCH_FALSE, send_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
switch_time_t now;
int min_members = 0;
int count_changed = 0;
@ -1970,7 +1985,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (count_changed) {
need_refresh = 1;
need_keyframe = 1;
send_keyframe = 1;
do_refresh = 100;
}
@ -2030,7 +2045,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (imember->watching_canvas_id == canvas->canvas_id && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
}
if (conference_utils_test_flag(conference, CFLAG_MINIMIZE_VIDEO_ENCODING) &&
@ -2129,7 +2144,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_img_free(&img);
}
if (!layer && (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS) || ((switch_channel_test_flag(imember->channel, CF_VIDEO) && imember->video_flow != SWITCH_MEDIA_FLOW_SENDONLY)))) {
if (!layer && (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS) || ((switch_channel_test_flag(imember->channel, CF_VIDEO) && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY)))) {
if (conference_video_find_layer(conference, canvas, imember, &layer) == SWITCH_STATUS_SUCCESS) {
imember->layer_timeout = 0;
} else {
@ -2220,7 +2235,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
conference_member_t *omember;
if (video_key_freq && (now - last_key_time) > video_key_freq) {
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
last_key_time = now;
}
@ -2245,7 +2260,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
}
if (count_changed) {
@ -2255,7 +2270,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
total += conference->members_with_avatar;
}
if (imember->video_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
total--;
}
@ -2268,7 +2283,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
}
if (imember->video_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
conference_video_pop_next_image(imember, &imember->pcanvas_img);
}
@ -2299,7 +2314,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
for (imember = conference->members; imember; imember = imember->next) {
int i = 0;
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO || imember->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) ||
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO || 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) {
continue;
}
@ -2308,7 +2323,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
mcu_layer_t *layer = NULL;
switch_image_t *use_img = NULL;
if (!omember->session || !switch_channel_test_flag(omember->channel, CF_VIDEO) || omember->video_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
if (!omember->session || !switch_channel_test_flag(omember->channel, CF_VIDEO) || switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
continue;
}
@ -2418,7 +2433,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_core_session_request_video_refresh(imember->session);
}
if (need_keyframe) {
if (send_keyframe) {
switch_core_media_gen_key_frame(imember->session);
}
@ -2468,7 +2483,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
if (layer->cur_img) {
if (layer->member) {
if (layer->member && switch_core_cpu_count() > 2) {
layer->need_patch = 1;
} else {
conference_video_scale_and_patch(layer, NULL, SWITCH_FALSE);
@ -2510,14 +2525,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (canvas->send_keyframe > 0) {
if (canvas->send_keyframe == 1 || (canvas->send_keyframe % 10) == 0) {
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
need_refresh = SWITCH_TRUE;
}
canvas->send_keyframe--;
}
if (video_key_freq && (now - last_key_time) > video_key_freq) {
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
last_key_time = now;
}
@ -2547,12 +2562,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
write_frame.img = write_img;
wait_for_canvas(canvas);
if (canvas->recording) {
conference_video_check_recording(conference, canvas, &write_frame);
}
wait_for_canvas(canvas);
if (conference->canvas_count > 1) {
switch_image_t *img_copy = NULL;
@ -2567,10 +2582,11 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
for (i = 0; write_codecs[i] && switch_core_codec_ready(&write_codecs[i]->codec) && i < MAX_MUX_CODECS; i++) {
write_codecs[i]->frame.img = write_img;
conference_video_write_canvas_image_to_codec_group(conference, canvas, write_codecs[i], i,
timestamp, need_refresh, need_keyframe, need_reset);
timestamp, need_refresh, send_keyframe, need_reset);
if (canvas->video_write_bandwidth) {
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH, SCCT_INT, &canvas->video_write_bandwidth, NULL, NULL);
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
canvas->video_write_bandwidth = 0;
}
@ -2588,19 +2604,16 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
}
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
continue;
}
if (imember->video_flow == SWITCH_MEDIA_FLOW_RECVONLY) {
continue;
}
if (need_refresh) {
switch_core_session_request_video_refresh(imember->session);
}
if (need_keyframe) {
if (send_keyframe) {
switch_core_media_gen_key_frame(imember->session);
}
@ -2707,7 +2720,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
packet = switch_core_alloc(conference->pool, SWITCH_RTP_MAX_BUF_LEN);
while (conference_globals.running && !conference_utils_test_flag(conference, CFLAG_DESTRUCT) && conference_utils_test_flag(conference, CFLAG_VIDEO_MUXING)) {
switch_bool_t need_refresh = SWITCH_FALSE, need_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
switch_bool_t need_refresh = SWITCH_FALSE, send_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
switch_time_t now;
int min_members = 0;
int count_changed = 0;
@ -2741,14 +2754,14 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
if (canvas->send_keyframe > 0) {
if (canvas->send_keyframe == 1 || (canvas->send_keyframe % 10) == 0) {
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
need_refresh = SWITCH_TRUE;
}
canvas->send_keyframe--;
}
if (video_key_freq && (now - last_key_time) > video_key_freq) {
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
last_key_time = now;
}
@ -2792,7 +2805,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
if (imember->watching_canvas_id == canvas->canvas_id && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
need_keyframe = SWITCH_TRUE;
send_keyframe = SWITCH_TRUE;
}
if (conference_utils_test_flag(conference, CFLAG_MINIMIZE_VIDEO_ENCODING) &&
@ -2912,10 +2925,11 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
if (min_members && conference_utils_test_flag(conference, CFLAG_MINIMIZE_VIDEO_ENCODING)) {
for (i = 0; write_codecs[i] && switch_core_codec_ready(&write_codecs[i]->codec) && i < MAX_MUX_CODECS; i++) {
write_codecs[i]->frame.img = write_img;
conference_video_write_canvas_image_to_codec_group(conference, canvas, write_codecs[i], i, timestamp, need_refresh, need_keyframe, need_reset);
conference_video_write_canvas_image_to_codec_group(conference, canvas, write_codecs[i], i, timestamp, need_refresh, send_keyframe, need_reset);
if (canvas->video_write_bandwidth) {
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH, SCCT_INT, &canvas->video_write_bandwidth, NULL, NULL);
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
canvas->video_write_bandwidth = 0;
}
}
@ -2931,7 +2945,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
continue;
}
if (imember->video_flow == SWITCH_MEDIA_FLOW_RECVONLY) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY) {
continue;
}
@ -2944,7 +2958,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
switch_core_session_request_video_refresh(imember->session);
}
if (need_keyframe) {
if (send_keyframe) {
switch_core_media_gen_key_frame(imember->session);
}
@ -3024,7 +3038,7 @@ void conference_video_find_floor(conference_member_t *member, switch_bool_t ente
continue;
}
if (imember->video_flow == SWITCH_MEDIA_FLOW_SENDONLY && !imember->avatar_png_img) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY && !imember->avatar_png_img) {
continue;
}
@ -3080,7 +3094,7 @@ void conference_video_set_floor_holder(conference_obj_t *conference, conference_
return;
}
if (member && member->video_flow == SWITCH_MEDIA_FLOW_SENDONLY && !member->avatar_png_img) {
if (member && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY && !member->avatar_png_img) {
return;
}
@ -3264,13 +3278,27 @@ void conference_video_write_frame(conference_obj_t *conference, conference_membe
switch_core_session_rwunlock(isession);
}
if (want_refresh) {
for (imember = conference->members; imember; imember = imember->next) {
switch_core_session_t *isession = imember->session;
if (!isession || switch_core_session_read_lock(isession) != SWITCH_STATUS_SUCCESS) {
continue;
}
if (!isession || !switch_channel_test_flag(imember->channel, CF_VIDEO) ) {
continue;
}
switch_core_session_request_video_refresh(imember->session);
switch_core_session_rwunlock(isession);
}
}
switch_mutex_unlock(conference->member_mutex);
switch_img_free(&tmp_frame.img);
if (want_refresh && floor_holder->session) {
switch_core_session_request_video_refresh(floor_holder->session);
}
}
switch_status_t conference_video_thread_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
@ -3286,6 +3314,9 @@ switch_status_t conference_video_thread_callback(switch_core_session_t *session,
return SWITCH_STATUS_SUCCESS;
}
if (switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
return SWITCH_STATUS_SUCCESS;
}
if (switch_thread_rwlock_tryrdlock(member->conference->rwlock) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;

View File

@ -288,13 +288,29 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
if (conference_utils_member_test_flag(imember, MFLAG_RUNNING) && imember->session) {
switch_channel_t *channel = switch_core_session_get_channel(imember->session);
switch_media_flow_t video_media_flow;
if ((!floor_holder || (imember->score_iir > SCORE_IIR_SPEAKING_MAX && (floor_holder->score_iir < SCORE_IIR_SPEAKING_MIN)))) {// &&
//(!conference_utils_test_flag(conference, CFLAG_VID_FLOOR) || switch_channel_test_flag(channel, CF_VIDEO))) {
floor_holder = imember;
}
if (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_VIDEO) && imember->video_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
video_media_flow = switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO);
if (video_media_flow != imember->video_media_flow) {
imember->video_media_flow = video_media_flow;
if (imember->video_media_flow == SWITCH_MEDIA_FLOW_SENDONLY) {
conference_utils_member_clear_flag(imember, MFLAG_CAN_BE_SEEN);
conference_video_find_floor(imember, SWITCH_FALSE);
} else {
conference_utils_member_set_flag(imember, MFLAG_CAN_BE_SEEN);
conference_video_find_floor(imember, SWITCH_TRUE);
switch_core_session_request_video_refresh(imember->session);
}
}
if (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_VIDEO) && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY) {
members_with_video++;
}

View File

@ -744,7 +744,6 @@ struct conference_member {
char *video_logo;
char *video_mute_png;
char *video_reservation_id;
switch_media_flow_t video_flow;
switch_frame_buffer_t *fb;
switch_image_t *avatar_png_img;
switch_image_t *video_mute_img;
@ -755,6 +754,7 @@ struct conference_member {
int good_img;
int auto_avatar;
int avatar_patched;
switch_media_flow_t video_media_flow;
mcu_canvas_t *canvas;
switch_image_t *pcanvas_img;
};
@ -917,6 +917,7 @@ void conference_video_layer_set_banner(conference_member_t *member, mcu_layer_t
void conference_video_layer_set_logo(conference_member_t *member, mcu_layer_t *layer, const char *path);
void conference_video_detach_video_layer(conference_member_t *member);
void conference_video_check_used_layers(mcu_canvas_t *canvas);
void conference_video_check_flush(conference_member_t *member);
void conference_video_set_canvas_letterbox_bgcolor(mcu_canvas_t *canvas, char *color);
void conference_video_set_canvas_bgcolor(mcu_canvas_t *canvas, char *color);
void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg, switch_bool_t freeze);

View File

@ -1014,6 +1014,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
{
switch_api_interface_t *api_interface;
switch_application_interface_t *app_interface;
if (switch_event_reserve_subclass(HTTP_SENDFILE_ACK_EVENT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", HTTP_SENDFILE_ACK_EVENT);
return SWITCH_STATUS_TERM;
}
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@ -1037,6 +1043,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
Macro expands to: switch_status_t mod_cidlookup_shutdown() */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown)
{
switch_event_free_subclass(HTTP_SENDFILE_ACK_EVENT);
/* Cleanup dynamically allocated config settings */
return SWITCH_STATUS_SUCCESS;
}

View File

@ -1334,6 +1334,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load)
switch_application_interface_t *app_interface;
switch_api_interface_t *api_interface;
if (switch_event_reserve_subclass(MY_EVENT_VIDEO_DETECT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_VIDEO_DETECT);
return SWITCH_STATUS_TERM;
}
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
MODULE_INTERFACE = *module_interface;
@ -1354,6 +1359,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown)
{
switch_event_free_subclass(MY_EVENT_VIDEO_DETECT);
return SWITCH_STATUS_UNLOAD;
}

View File

@ -5909,6 +5909,11 @@ SWITCH_STANDARD_APP(deduplicate_dtmf_app_function)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown)
{
switch_event_free_subclass(FILE_STRING_CLOSE);
switch_event_free_subclass(FILE_STRING_FAIL);
switch_event_free_subclass(FILE_STRING_OPEN);
switch_event_unbind_callback(pickup_pres_event_handler);
switch_mutex_destroy(globals.pickup_mutex);
switch_core_hash_destroy(&globals.pickup_hash);
@ -5926,6 +5931,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
switch_chat_interface_t *chat_interface;
switch_file_interface_t *file_interface;
if (switch_event_reserve_subclass(FILE_STRING_CLOSE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_CLOSE);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(FILE_STRING_FAIL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_FAIL);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(FILE_STRING_OPEN) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_OPEN);
return SWITCH_STATUS_TERM;
}
globals.pool = pool;
switch_core_hash_init(&globals.pickup_hash);
switch_mutex_init(&globals.pickup_mutex, SWITCH_MUTEX_NESTED, globals.pool);

View File

@ -2,5 +2,6 @@
2. add lock for hiredis_profile for destroy vs running commands
3. Look into refactor/cleanup of xml processing
4. Add tab complete for profile names for APIs, and possibly for supported actions(and in theory look into key listing from redis)
5. Add linked list session pvt structure for keeping track of limit incr's on a session by session basis

View File

@ -143,6 +143,11 @@ switch_status_t hiredis_profile_execute_sync(hiredis_profile_t *profile, const c
response = redisCommand(profile->conn->context, data);
if ( !response ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hiredis: empty response received\n");
return SWITCH_STATUS_GENERR;
}
switch(response->type) {
case REDIS_REPLY_STATUS: /* fallthrough */
case REDIS_REPLY_STRING:

Some files were not shown because too many files have changed in this diff Show More