Merge branch 'master' into v1.6 for v1.6.2
This commit is contained in:
commit
f6ab7ff6ae
|
@ -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 \
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"/>-->
|
||||
|
|
|
@ -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>
|
||||
|
|
13
configure.ac
13
configure.ac
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -370,7 +371,7 @@ Description: Cross-Platform Scalable Multi-Protocol Soft Switch
|
|||
.
|
||||
This package contains the FreeSWITCH core library.
|
||||
|
||||
Package: python-esl
|
||||
Package: python-esl
|
||||
Section: python
|
||||
Architecture: any
|
||||
Depends: \${shlibs:Depends}, \${misc:Depends}, \${python:Depends}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -488,27 +488,27 @@ License: BSD-2-clause
|
|||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* This work was supported in part by funding from the Defense Advanced
|
||||
* Research Projects Agency and the National Science Foundation of the
|
||||
* This work was supported in part by funding from the Defense Advanced
|
||||
* Research Projects Agency and the National Science Foundation of the
|
||||
* United States of America, and the CMU Sphinx Speech Consortium.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
|
||||
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
|
||||
* ANY EXPRESSED 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 CARNEGIE MELLON UNIVERSITY
|
||||
* NOR ITS EMPLOYEES 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
|
||||
* 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.
|
||||
*
|
||||
* ====================================================================
|
||||
|
@ -1515,24 +1515,24 @@ License: BSD-3-clause
|
|||
Files: libs/libsndfile/src/GSM610/*
|
||||
Copyright: 1992, 1993, 1994 by Jutta Degener and Carsten Bormann
|
||||
License:
|
||||
Their work was released under the following license which is
|
||||
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)
|
||||
|
@ -1863,7 +1863,7 @@ Copyright: 2004 Polycom, Inc
|
|||
2006 Michael Jerris
|
||||
2001-2009 Steve Underwood <steveu@coppice.org>
|
||||
2001-2006 Steve Underwood
|
||||
Comment: Disclaimer: non-comercial use,gital Equipment Corporation, Maynard, Massachusetts.
|
||||
Comment: Disclaimer: non-comercial use,gital Equipment Corporation, Maynard, Massachusetts.
|
||||
License: patent-mess
|
||||
|
||||
Files: libs/libg722_1/autogen.sh
|
||||
|
@ -1878,24 +1878,24 @@ License: LGPL-2.1
|
|||
License: OpenLDAP
|
||||
/* Portions Copyright 1998-2002 The OpenLDAP Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted only as authorized by the OpenLDAP
|
||||
* Public License. A copy of this license is available at
|
||||
* http://www.OpenLDAP.org/license.html or in file LICENSE in the
|
||||
* top-level directory of the distribution.
|
||||
*
|
||||
*
|
||||
* OpenLDAP is a registered trademark of the OpenLDAP Foundation.
|
||||
*
|
||||
*
|
||||
* Individual files and/or contributed packages may be copyright by
|
||||
* other parties and subject to additional restrictions.
|
||||
*
|
||||
*
|
||||
* This work is derived from the University of Michigan LDAP v3.3
|
||||
* distribution. Information concerning this software is available
|
||||
* at: http://www.umich.edu/~dirsvcs/ldap/
|
||||
*
|
||||
*
|
||||
* This work also contains materials derived from public sources.
|
||||
*
|
||||
*
|
||||
* Additional information about OpenLDAP can be obtained at:
|
||||
* http://www.openldap.org/
|
||||
*/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/usr/lib/python*/*-packages/freeswitch.py
|
|
@ -1 +0,0 @@
|
|||
d /run/freeswitch 0755 freeswitch freeswitch -
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
/lib/systemd/system/freeswitch.service
|
||||
/usr/lib/tmpfiles.d/freeswitch.conf
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ case "$1" in
|
|||
chown freeswitch $x
|
||||
done
|
||||
if [ ! -d "/etc/freeswitch" ]; then
|
||||
mkdir -p /etc/freeswitch/tls/
|
||||
cp -a /usr/share/freeswitch/conf/vanilla/* /etc/freeswitch/
|
||||
|
||||
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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -468,7 +468,7 @@ commands:
|
|||
-j Build debs in parallel
|
||||
-k Don't override pbuilder image configurations
|
||||
-K [/path/to/keyring.asc]
|
||||
Use custom keyring file for sources.list in build environment
|
||||
Use custom keyring file for sources.list in build environment
|
||||
in the format of: apt-key exportall > /path/to/file.asc
|
||||
-l <modules>
|
||||
-m [ quicktest | non-dfsg ]
|
||||
|
@ -497,7 +497,7 @@ commands:
|
|||
-d Enable cowbuilder debug hook
|
||||
-k Don't override pbuilder image configurations
|
||||
-K [/path/to/keyring.asc]
|
||||
Use custom keyring file for sources.list in build environment
|
||||
Use custom keyring file for sources.list in build environment
|
||||
in the format of: apt-key exportall > /path/to/file.asc
|
||||
-t Use system /etc/apt/sources.list in build environment
|
||||
-T [/path/to/sources.list]
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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?" <":" <")+dialog.params.remote_caller_id_number+(enc?">":">");return party;};$.verto.dialog.prototype.sendMessage=function(msg,params){var dialog=this;if(dialog.callbacks.onMessage){dialog.callbacks.onMessage(dialog.verto,dialog,msg,params);}};$.verto.dialog.prototype.handleInfo=function(params){var dialog=this;dialog.sendMessage($.verto.enum.message.info,params.msg);};$.verto.dialog.prototype.handleDisplay=function(params){var dialog=this;if(params.display_name){dialog.params.remote_caller_id_name=params.display_name;}
|
||||
if(params.display_number){dialog.params.remote_caller_id_number=params.display_number;}
|
||||
dialog.sendMessage($.verto.enum.message.display,{});};$.verto.dialog.prototype.handleMedia=function(params){var dialog=this;if(dialog.state.val>=$.verto.enum.state.early.val){return;}
|
||||
dialog.gotEarly=true;dialog.rtc.answer(params.sdp,function(){console.log("Dialog "+dialog.callID+"Establishing early media");dialog.setState($.verto.enum.state.early);if(dialog.gotAnswer){console.log("Dialog "+dialog.callID+"Answering Channel");dialog.setState($.verto.enum.state.active);}},function(e){console.error(e);dialog.hangup();});console.log("Dialog "+dialog.callID+"EARLY SDP",params.sdp);};$.verto.ENUM=function(s){var i=0,o={};s.split(" ").map(function(x){o[x]={name:x,val:i++};});return Object.freeze(o);};$.verto.enum={};$.verto.enum.states=Object.freeze({new:{requesting:1,recovering:1,ringing:1,destroy:1,answering:1,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);
|
|
@ -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;
|
||||
|
||||
// Append stereo=1 to fmtp line.
|
||||
sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat('; stereo=1');
|
||||
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; 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) {
|
||||
self.localStream.stop();
|
||||
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) {
|
||||
self.options.localVideoStream.stop();
|
||||
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};
|
||||
|
@ -536,7 +552,7 @@ var iceTimer;
|
|||
self.constraints.mandatory.OfferToReceiveVideo = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.peer = RTCPeerConnection({
|
||||
type: self.type,
|
||||
attachStream: self.localStream,
|
||||
|
@ -604,12 +620,13 @@ var iceTimer;
|
|||
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'
|
||||
};
|
||||
|
@ -655,104 +672,74 @@ var iceTimer;
|
|||
openOffererChannel();
|
||||
var x = 0;
|
||||
|
||||
peer.onicecandidate = function(event) {
|
||||
if (event.candidate) {
|
||||
options.onICE(event.candidate);
|
||||
clearTimeout(iceTimer);
|
||||
iceTimer = setTimeout(function() {
|
||||
iceTimerSent = 1;
|
||||
function ice_handler() {
|
||||
|
||||
if (iceTimerCompleted == 0) {
|
||||
done = true;
|
||||
gathering = null;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
done = true;
|
||||
|
||||
if (gathering) {
|
||||
clearTimeout(gathering);
|
||||
gathering = null;
|
||||
}
|
||||
|
||||
ice_handler();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// attachStream = MediaStream;
|
||||
if (options.attachStream) peer.addStream(options.attachStream);
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -281,6 +281,7 @@ module.exports = function (grunt) {
|
|||
src: [
|
||||
'*.{ico,png,txt}',
|
||||
'*.html',
|
||||
'*.json',
|
||||
'partials/**/*.html',
|
||||
'images/{,*/}*.{webp}',
|
||||
'css/fonts/{,*/}*.*',
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"login": "1008",
|
||||
"password": "1234"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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>"
|
||||
]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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 class="form-group text-right">
|
||||
<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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -4,39 +4,40 @@
|
|||
.module('storageService')
|
||||
.service('storage', ['$rootScope', '$localStorage',
|
||||
function($rootScope, $localStorage) {
|
||||
var data = $localStorage;
|
||||
var data = $localStorage,
|
||||
defaultSettings = {
|
||||
ui_connected: false,
|
||||
ws_connected: false,
|
||||
cur_call: 0,
|
||||
called_number: '',
|
||||
useVideo: true,
|
||||
call_history: {},
|
||||
history_control: [],
|
||||
call_start: false,
|
||||
name: '',
|
||||
email: '',
|
||||
login: '',
|
||||
password: '',
|
||||
userStatus: 'disconnected',
|
||||
mutedVideo: false,
|
||||
mutedMic: false,
|
||||
selectedVideo: null,
|
||||
selectedAudio: null,
|
||||
selectedShare: null,
|
||||
useStereo: true,
|
||||
useSTUN: true,
|
||||
useDedenc: false,
|
||||
mirrorInput: false,
|
||||
outgoingBandwidth: 'default',
|
||||
incomingBandwidth: 'default',
|
||||
vidQual: undefined,
|
||||
askRecoverCall: false,
|
||||
googNoiseSuppression: true,
|
||||
googHighpassFilter: true,
|
||||
googEchoCancellation: true
|
||||
};
|
||||
|
||||
data.$default({
|
||||
ui_connected: false,
|
||||
ws_connected: false,
|
||||
cur_call: 0,
|
||||
called_number: '',
|
||||
useVideo: true,
|
||||
call_history: {},
|
||||
history_control: [],
|
||||
call_start: false,
|
||||
name: '',
|
||||
email: '',
|
||||
login: '',
|
||||
password: '',
|
||||
userStatus: 'disconnected',
|
||||
mutedVideo: false,
|
||||
mutedMic: false,
|
||||
selectedVideo: null,
|
||||
selectedAudio: null,
|
||||
selectedShare: null,
|
||||
useStereo: true,
|
||||
useSTUN: true,
|
||||
useDedenc: false,
|
||||
mirrorInput: false,
|
||||
outgoingBandwidth: 'default',
|
||||
incomingBandwidth: 'default',
|
||||
vidQual: undefined,
|
||||
askRecoverCall: false,
|
||||
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);
|
||||
},
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
|
|
@ -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',
|
||||
|
@ -95,4 +91,4 @@
|
|||
}
|
||||
]);
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -31,7 +31,18 @@
|
|||
* fill dialpad via querystring [?autocall=\d+]
|
||||
*/
|
||||
if ($location.search().autocall) {
|
||||
$rootScope.dialpadNumber = $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);
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
if (storage.data.videoCall) {
|
||||
$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() {
|
||||
|
@ -78,4 +86,4 @@
|
|||
|
||||
}
|
||||
]);
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -1,25 +1,60 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('vertoControllers')
|
||||
.controller('LoginController', ['$scope', '$http', '$location',
|
||||
'verto',
|
||||
function($scope, $http, $location, verto) {
|
||||
$scope.checkBrowser();
|
||||
angular
|
||||
.module('vertoControllers')
|
||||
.controller('LoginController', ['$scope', '$http', '$location', 'verto',
|
||||
function($scope, $http, $location, verto) {
|
||||
$scope.checkBrowser();
|
||||
|
||||
/**
|
||||
* using stored data (localStorage) for logon
|
||||
*/
|
||||
verto.data.name = $scope.storage.data.name;
|
||||
verto.data.email = $scope.storage.data.email;
|
||||
if ($scope.storage.data.login != '' && $scope.storage.data.password != '') {
|
||||
verto.data.login = $scope.storage.data.login;
|
||||
verto.data.password = $scope.storage.data.password;
|
||||
}
|
||||
/*
|
||||
* Load the Configs before logging in
|
||||
* with cache buster
|
||||
*/
|
||||
|
||||
$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.');
|
||||
}
|
||||
]);
|
||||
|
||||
})();
|
||||
|
||||
console.debug('Executing LoginController.');
|
||||
}
|
||||
]);
|
||||
|
||||
})();
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -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
|
|
@ -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>
|
|
@ -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>
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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:
|
||||
*/
|
|
@ -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:
|
||||
*/
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef __MPOOL_H__
|
||||
#define __MPOOL_H__
|
||||
|
||||
#include "ks.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
|
@ -34,7 +35,7 @@
|
|||
* Choose a best fit algorithm not first fit. This takes more CPU
|
||||
* time but will result in a tighter heap.
|
||||
*/
|
||||
#define MPOOL_FLAG_BEST_FIT (1<<0)
|
||||
#define MPOOL_FLAG_BEST_FIT (1<<0)
|
||||
|
||||
/*
|
||||
* By default the library adds 2 bytes onto all allocations to insert
|
||||
|
@ -43,7 +44,7 @@
|
|||
* going to be performed on the pool and to not waste memory on these
|
||||
* bytes.
|
||||
*/
|
||||
#define MPOOL_FLAG_NO_FREE (1<<1)
|
||||
#define MPOOL_FLAG_NO_FREE (1<<1)
|
||||
|
||||
/*
|
||||
* This enables very heavy packing at the possible expense of CPU.
|
||||
|
@ -58,48 +59,47 @@
|
|||
* and then it will give up. This flag forces it to look until it
|
||||
* finds it.
|
||||
*/
|
||||
#define MPOOL_FLAG_HEAVY_PACKING (1<<2)
|
||||
#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
|
||||
*/
|
||||
#define MPOOL_ERROR_NONE 1 /* no error */
|
||||
#define MPOOL_ERROR_ARG_NULL 2 /* function argument is null */
|
||||
#define MPOOL_ERROR_ARG_INVALID 3 /* function argument is invalid */
|
||||
#define MPOOL_ERROR_PNT 4 /* invalid mpool pointer */
|
||||
#define MPOOL_ERROR_POOL_OVER 5 /* mpool structure was overwritten */
|
||||
#define MPOOL_ERROR_PAGE_SIZE 6 /* could not get system page-size */
|
||||
#define MPOOL_ERROR_OPEN_ZERO 7 /* could not open /dev/zero */
|
||||
#define MPOOL_ERROR_NO_MEM 8 /* no memory available */
|
||||
#define MPOOL_ERROR_MMAP 9 /* problems with mmap */
|
||||
#define MPOOL_ERROR_SIZE 10 /* error processing requested size */
|
||||
#define MPOOL_ERROR_TOO_BIG 11 /* allocation exceeded max size */
|
||||
#define MPOOL_ERROR_MEM 12 /* invalid memory address */
|
||||
#define MPOOL_ERROR_MEM_OVER 13 /* memory lower bounds overwritten */
|
||||
#define MPOOL_ERROR_NOT_FOUND 14 /* memory block not found in pool */
|
||||
#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_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 */
|
||||
#define MPOOL_ERROR_NONE 1 /* no error */
|
||||
#define MPOOL_ERROR_ARG_NULL 2 /* function argument is null */
|
||||
#define MPOOL_ERROR_ARG_INVALID 3 /* function argument is invalid */
|
||||
#define MPOOL_ERROR_PNT 4 /* invalid mpool pointer */
|
||||
#define MPOOL_ERROR_POOL_OVER 5 /* mpool structure was overwritten */
|
||||
#define MPOOL_ERROR_PAGE_SIZE 6 /* could not get system page-size */
|
||||
#define MPOOL_ERROR_OPEN_ZERO 7 /* could not open /dev/zero */
|
||||
#define MPOOL_ERROR_NO_MEM 8 /* no memory available */
|
||||
#define MPOOL_ERROR_MMAP 9 /* problems with mmap */
|
||||
#define MPOOL_ERROR_SIZE 10 /* error processing requested size */
|
||||
#define MPOOL_ERROR_TOO_BIG 11 /* allocation exceeded max size */
|
||||
#define MPOOL_ERROR_MEM 12 /* invalid memory address */
|
||||
#define MPOOL_ERROR_MEM_OVER 13 /* memory lower bounds overwritten */
|
||||
#define MPOOL_ERROR_NOT_FOUND 14 /* memory block not found in pool */
|
||||
#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_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 */
|
||||
|
||||
/*
|
||||
* Mpool function IDs for the mpool_log_func callback function.
|
||||
*/
|
||||
#define MPOOL_FUNC_CLOSE 1 /* mpool_close function called */
|
||||
#define MPOOL_FUNC_CLEAR 2 /* mpool_clear function called */
|
||||
#define MPOOL_FUNC_ALLOC 3 /* mpool_alloc function called */
|
||||
#define MPOOL_FUNC_CALLOC 4 /* mpool_calloc function called */
|
||||
#define MPOOL_FUNC_FREE 5 /* mpool_free function called */
|
||||
#define MPOOL_FUNC_RESIZE 6 /* mpool_resize function called */
|
||||
#define MPOOL_FUNC_CLOSE 1 /* mpool_close function called */
|
||||
#define MPOOL_FUNC_CLEAR 2 /* mpool_clear function called */
|
||||
#define MPOOL_FUNC_ALLOC 3 /* mpool_alloc function called */
|
||||
#define MPOOL_FUNC_CALLOC 4 /* mpool_calloc function called */
|
||||
#define MPOOL_FUNC_FREE 5 /* mpool_free function called */
|
||||
#define MPOOL_FUNC_RESIZE 6 /* mpool_resize function called */
|
||||
|
||||
/*
|
||||
* void mpool_log_func_t
|
||||
|
@ -133,12 +133,12 @@
|
|||
* old_byte_size -> Optionally specified old byte size. For
|
||||
* mpool_resize only.
|
||||
*/
|
||||
typedef void (*mpool_log_func_t)(const void *mp_p,
|
||||
const int func_id,
|
||||
const unsigned long byte_size,
|
||||
const unsigned long ele_n,
|
||||
const void *old_addr, const void *new_addr,
|
||||
const unsigned long old_byte_size);
|
||||
typedef void (*mpool_log_func_t)(const void *mp_p,
|
||||
const int func_id,
|
||||
const unsigned long byte_size,
|
||||
const unsigned long ele_n,
|
||||
const void *old_addr, const void *new_addr,
|
||||
const unsigned long old_byte_size);
|
||||
|
||||
#ifdef MPOOL_MAIN
|
||||
|
||||
|
@ -147,7 +147,7 @@ typedef void (*mpool_log_func_t)(const void *mp_p,
|
|||
#else
|
||||
|
||||
/* generic mpool type */
|
||||
typedef void mpool_t;
|
||||
typedef void mpool_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -181,9 +181,8 @@ 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,
|
||||
void *start_addr, int *error_p);
|
||||
KS_DECLARE(mpool_t *) mpool_open(const unsigned int flags, const unsigned int page_size,
|
||||
void *start_addr, int *error_p);
|
||||
|
||||
/*
|
||||
* int mpool_close
|
||||
|
@ -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,9 +246,8 @@ 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,
|
||||
int *error_p);
|
||||
KS_DECLARE(void *) mpool_alloc(mpool_t *mp_p, const unsigned long byte_size,
|
||||
int *error_p);
|
||||
|
||||
/*
|
||||
* void *mpool_calloc
|
||||
|
@ -279,9 +275,8 @@ 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,
|
||||
const unsigned long ele_size, int *error_p);
|
||||
KS_DECLARE(void *)mpool_calloc(mpool_t *mp_p, const unsigned long ele_n,
|
||||
const unsigned long ele_size, int *error_p);
|
||||
|
||||
/*
|
||||
* int mpool_free
|
||||
|
@ -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,11 +334,10 @@ 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,
|
||||
const unsigned long old_byte_size,
|
||||
const unsigned long new_byte_size,
|
||||
int *error_p);
|
||||
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);
|
||||
|
||||
/*
|
||||
* int mpool_stats
|
||||
|
@ -379,12 +373,11 @@ 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,
|
||||
unsigned long *num_alloced_p,
|
||||
unsigned long *user_alloced_p,
|
||||
unsigned long *max_alloced_p,
|
||||
unsigned long *tot_alloced_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,
|
||||
unsigned long *tot_alloced_p);
|
||||
|
||||
/*
|
||||
* int mpool_set_log_func
|
||||
|
@ -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:
|
||||
*/
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
#define BIT_IS_SET(v,f) ((v) & (f))
|
||||
#define BIT_TOGGLE(v,f) (v) ^= (f)
|
||||
|
||||
#define SET_POINTER(pnt, val) \
|
||||
do { \
|
||||
if ((pnt) != NULL) { \
|
||||
(*(pnt)) = (val); \
|
||||
} \
|
||||
} while(0)
|
||||
#define SET_POINTER(pnt, val) \
|
||||
do { \
|
||||
if ((pnt) != NULL) { \
|
||||
(*(pnt)) = (val); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define BLOCK_FLAG_USED BIT_FLAG(0) /* block is used */
|
||||
#define BLOCK_FLAG_FREE BIT_FLAG(1) /* block is free */
|
||||
|
@ -56,39 +56,40 @@
|
|||
#define DEFAULT_PAGE_MULT 16 /* pagesize = this * getpagesize*/
|
||||
|
||||
/* How many pages SIZE bytes resides in. We add in the block header. */
|
||||
#define PAGES_IN_SIZE(mp_p, size) (((size) + sizeof(mpool_block_t) + \
|
||||
(mp_p)->mp_page_size - 1) / \
|
||||
(mp_p)->mp_page_size)
|
||||
#define PAGES_IN_SIZE(mp_p, size) (((size) + sizeof(mpool_block_t) + \
|
||||
(mp_p)->mp_page_size - 1) / \
|
||||
(mp_p)->mp_page_size)
|
||||
#define SIZE_OF_PAGES(mp_p, page_n) ((page_n) * (mp_p)->mp_page_size)
|
||||
#define MAX_BITS 30 /* we only can allocate 1gb chunks */
|
||||
|
||||
#define MAX_BLOCK_USER_MEMORY(mp_p) ((mp_p)->mp_page_size - \
|
||||
sizeof(mpool_block_t))
|
||||
#define FIRST_ADDR_IN_BLOCK(block_p) (void *)((char *)(block_p) + \
|
||||
sizeof(mpool_block_t))
|
||||
#define MEMORY_IN_BLOCK(block_p) ((char *)(block_p)->mb_bounds_p - \
|
||||
((char *)(block_p) + \
|
||||
sizeof(mpool_block_t)))
|
||||
sizeof(mpool_block_t))
|
||||
#define FIRST_ADDR_IN_BLOCK(block_p) (void *)((char *)(block_p) + \
|
||||
sizeof(mpool_block_t))
|
||||
#define MEMORY_IN_BLOCK(block_p) ((char *)(block_p)->mb_bounds_p - \
|
||||
((char *)(block_p) + \
|
||||
sizeof(mpool_block_t)))
|
||||
|
||||
typedef struct {
|
||||
unsigned int mp_magic; /* magic number for struct */
|
||||
unsigned int mp_flags; /* flags for the struct */
|
||||
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 */
|
||||
unsigned int mp_page_c; /* number of pages allocated */
|
||||
unsigned int mp_max_pages; /* maximum number of pages to use */
|
||||
unsigned int mp_page_size; /* page-size of our system */
|
||||
int mp_fd; /* fd for /dev/zero if mmap-ing */
|
||||
off_t mp_top; /* top of our allocations in fd */
|
||||
mpool_log_func_t mp_log_func; /* log callback function */
|
||||
void *mp_addr; /* current address for mmaping */
|
||||
void *mp_min_p; /* min address in pool for checks */
|
||||
void *mp_bounds_p; /* max address in pool for checks */
|
||||
struct mpool_block_st *mp_first_p; /* first memory block we are using */
|
||||
struct mpool_block_st *mp_last_p; /* last memory block we are using */
|
||||
struct mpool_block_st *mp_free[MAX_BITS + 1]; /* free lists based on size */
|
||||
unsigned int mp_magic2; /* upper magic for overwrite sanity */
|
||||
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 */
|
||||
unsigned int mp_page_c; /* number of pages allocated */
|
||||
unsigned int mp_max_pages; /* maximum number of pages to use */
|
||||
unsigned int mp_page_size; /* page-size of our system */
|
||||
int mp_fd; /* fd for /dev/zero if mmap-ing */
|
||||
off_t mp_top; /* top of our allocations in fd */
|
||||
mpool_log_func_t mp_log_func; /* log callback function */
|
||||
void *mp_addr; /* current address for mmaping */
|
||||
void *mp_min_p; /* min address in pool for checks */
|
||||
void *mp_bounds_p; /* max address in pool for checks */
|
||||
struct mpool_block_st *mp_first_p; /* first memory block we are using */
|
||||
struct mpool_block_st *mp_last_p; /* last memory block we are using */
|
||||
struct mpool_block_st *mp_free[MAX_BITS + 1]; /* free lists based on size */
|
||||
unsigned int mp_magic2; /* upper magic for overwrite sanity */
|
||||
} mpool_t;
|
||||
|
||||
/* for debuggers to be able to interrogate the generic type in the .h file */
|
||||
|
@ -99,18 +100,29 @@ typedef mpool_t mpool_ext_t;
|
|||
* aligned.
|
||||
*/
|
||||
typedef struct mpool_block_st {
|
||||
unsigned int mb_magic; /* magic number for block header */
|
||||
void *mb_bounds_p; /* block boundary location */
|
||||
struct mpool_block_st *mb_next_p; /* linked list next pointer */
|
||||
unsigned int mb_magic2; /* upper magic for overwrite sanity */
|
||||
unsigned int mb_magic; /* magic number for block header */
|
||||
void *mb_bounds_p; /* block boundary location */
|
||||
struct mpool_block_st *mb_next_p; /* linked list next pointer */
|
||||
unsigned int mb_magic2; /* upper magic for overwrite sanity */
|
||||
} mpool_block_t;
|
||||
|
||||
/*
|
||||
* Free list structure.
|
||||
*/
|
||||
typedef struct {
|
||||
void *mf_next_p; /* pointer to the next free address */
|
||||
unsigned long mf_size; /* size of the free block */
|
||||
void *mf_next_p; /* pointer to the next free address */
|
||||
unsigned long mf_size; /* size of the free block */
|
||||
} 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:
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -83,25 +83,25 @@
|
|||
* were about 2^68 hashes to choose from. I only tested about a
|
||||
* billion of those.
|
||||
*/
|
||||
#define HASH_MIX(a, b, c) \
|
||||
do { \
|
||||
a -= b; a -= c; a ^= (c >> 13); \
|
||||
b -= c; b -= a; b ^= (a << 8); \
|
||||
c -= a; c -= b; c ^= (b >> 13); \
|
||||
a -= b; a -= c; a ^= (c >> 12); \
|
||||
b -= c; b -= a; b ^= (a << 16); \
|
||||
c -= a; c -= b; c ^= (b >> 5); \
|
||||
a -= b; a -= c; a ^= (c >> 3); \
|
||||
b -= c; b -= a; b ^= (a << 10); \
|
||||
c -= a; c -= b; c ^= (b >> 15); \
|
||||
} while(0)
|
||||
#define HASH_MIX(a, b, c) \
|
||||
do { \
|
||||
a -= b; a -= c; a ^= (c >> 13); \
|
||||
b -= c; b -= a; b ^= (a << 8); \
|
||||
c -= a; c -= b; c ^= (b >> 13); \
|
||||
a -= b; a -= c; a ^= (c >> 12); \
|
||||
b -= c; b -= a; b ^= (a << 16); \
|
||||
c -= a; c -= b; c ^= (b >> 5); \
|
||||
a -= b; a -= c; a ^= (c >> 3); \
|
||||
b -= c; b -= a; b ^= (a << 10); \
|
||||
c -= a; c -= b; c ^= (b >> 15); \
|
||||
} while(0)
|
||||
|
||||
#define SET_POINTER(pnt, val) \
|
||||
do { \
|
||||
if ((pnt) != NULL) { \
|
||||
(*(pnt)) = (val); \
|
||||
} \
|
||||
} while(0)
|
||||
#define SET_POINTER(pnt, val) \
|
||||
do { \
|
||||
if ((pnt) != NULL) { \
|
||||
(*(pnt)) = (val); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* The following macros take care of the mmap case. When we are
|
||||
|
@ -117,9 +117,9 @@
|
|||
|
||||
#else
|
||||
|
||||
#define TABLE_POINTER(tab_p, type, pnt) \
|
||||
((tab_p)->ta_mmap == NULL || (pnt) == NULL ? (pnt) : \
|
||||
(type)((char *)((tab_p)->ta_mmap) + (long)(pnt)))
|
||||
#define TABLE_POINTER(tab_p, type, pnt) \
|
||||
((tab_p)->ta_mmap == NULL || (pnt) == NULL ? (pnt) : \
|
||||
(type)((char *)((tab_p)->ta_mmap) + (long)(pnt)))
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -127,8 +127,8 @@
|
|||
* Macros to get at the key and the data pointers
|
||||
*/
|
||||
#define ENTRY_KEY_BUF(entry_p) ((entry_p)->te_key_buf)
|
||||
#define ENTRY_DATA_BUF(tab_p, entry_p) \
|
||||
(ENTRY_KEY_BUF(entry_p) + (entry_p)->te_key_size)
|
||||
#define ENTRY_DATA_BUF(tab_p, entry_p) \
|
||||
(ENTRY_KEY_BUF(entry_p) + (entry_p)->te_key_size)
|
||||
|
||||
/*
|
||||
* Table structures...
|
||||
|
@ -142,10 +142,10 @@
|
|||
* faster.
|
||||
*/
|
||||
typedef struct table_shell_st {
|
||||
unsigned int te_key_size; /* size of data */
|
||||
unsigned int te_data_size; /* size of data */
|
||||
struct table_shell_st *te_next_p; /* pointer to next in the list */
|
||||
/* NOTE: this does not have the te_key_buf field here */
|
||||
unsigned int te_key_size; /* size of data */
|
||||
unsigned int te_data_size; /* size of data */
|
||||
struct table_shell_st *te_next_p; /* pointer to next in the list */
|
||||
/* NOTE: this does not have the te_key_buf field here */
|
||||
} table_shell_t;
|
||||
|
||||
/*
|
||||
|
@ -157,10 +157,10 @@ typedef struct table_shell_st {
|
|||
* changed to match.
|
||||
*/
|
||||
typedef struct table_entry_st {
|
||||
unsigned int te_key_size; /* size of data */
|
||||
unsigned int te_data_size; /* size of data */
|
||||
struct table_entry_st *te_next_p; /* pointer to next in the list */
|
||||
unsigned char te_key_buf[1]; /* 1st byte of key buf */
|
||||
unsigned int te_key_size; /* size of data */
|
||||
unsigned int te_data_size; /* size of data */
|
||||
struct table_entry_st *te_next_p; /* pointer to next in the list */
|
||||
unsigned char te_key_buf[1]; /* 1st byte of key buf */
|
||||
} table_entry_t;
|
||||
|
||||
/* external structure for debuggers be able to see void */
|
||||
|
@ -168,20 +168,20 @@ typedef table_entry_t table_entry_ext_t;
|
|||
|
||||
/* main table structure */
|
||||
typedef struct table_st {
|
||||
unsigned int ta_magic; /* magic number */
|
||||
unsigned int ta_flags; /* table's flags defined in table.h */
|
||||
unsigned int ta_bucket_n; /* num of buckets, should be 2^X */
|
||||
unsigned int ta_entry_n; /* num of entries in all buckets */
|
||||
unsigned int ta_data_align; /* data alignment value */
|
||||
table_entry_t **ta_buckets; /* array of linked lists */
|
||||
table_linear_t ta_linear; /* linear tracking */
|
||||
struct table_st *ta_mmap; /* mmaped table */
|
||||
unsigned long ta_file_size; /* size of on-disk space */
|
||||
unsigned int ta_magic; /* magic number */
|
||||
unsigned int ta_flags; /* table's flags defined in table.h */
|
||||
unsigned int ta_bucket_n; /* num of buckets, should be 2^X */
|
||||
unsigned int ta_entry_n; /* num of entries in all buckets */
|
||||
unsigned int ta_data_align; /* data alignment value */
|
||||
table_entry_t **ta_buckets; /* array of linked lists */
|
||||
table_linear_t ta_linear; /* linear tracking */
|
||||
struct table_st *ta_mmap; /* mmaped table */
|
||||
unsigned long ta_file_size; /* size of on-disk space */
|
||||
|
||||
void *ta_mem_pool; /* pointer to some memory pool */
|
||||
table_mem_alloc_t ta_alloc_func; /* memory allocation function */
|
||||
table_mem_resize_t ta_resize_func; /* memory resize function */
|
||||
table_mem_free_t ta_free_func; /* memory free function */
|
||||
void *ta_mem_pool; /* pointer to some memory pool */
|
||||
table_mem_alloc_t ta_alloc_func; /* memory allocation function */
|
||||
table_mem_resize_t ta_resize_func; /* memory resize function */
|
||||
table_mem_free_t ta_free_func; /* memory free function */
|
||||
} table_t;
|
||||
|
||||
/* external table structure for debuggers */
|
||||
|
@ -189,41 +189,53 @@ typedef table_t table_ext_t;
|
|||
|
||||
/* local comparison functions */
|
||||
typedef int (*compare_t)(const void *element1_p, const void *element2_p,
|
||||
table_compare_t user_compare,
|
||||
const table_t *table_p, int *err_bp);
|
||||
table_compare_t user_compare,
|
||||
const table_t *table_p, int *err_bp);
|
||||
|
||||
/*
|
||||
* to map error to string
|
||||
*/
|
||||
typedef struct {
|
||||
int es_error; /* error number */
|
||||
char *es_string; /* assocaited string */
|
||||
int es_error; /* error number */
|
||||
char *es_string; /* assocaited string */
|
||||
} error_str_t;
|
||||
|
||||
static error_str_t errors[] = {
|
||||
{ TABLE_ERROR_NONE, "no error" },
|
||||
{ TABLE_ERROR_PNT, "invalid table pointer" },
|
||||
{ TABLE_ERROR_ARG_NULL, "buffer argument is null" },
|
||||
{ TABLE_ERROR_SIZE, "incorrect size argument" },
|
||||
{ TABLE_ERROR_OVERWRITE, "key exists and no overwrite" },
|
||||
{ TABLE_ERROR_NOT_FOUND, "key does not exist" },
|
||||
{ TABLE_ERROR_ALLOC, "error allocating memory" },
|
||||
{ TABLE_ERROR_LINEAR, "linear access not in progress" },
|
||||
{ TABLE_ERROR_OPEN, "could not open file" },
|
||||
{ TABLE_ERROR_SEEK, "could not seek to position in file" },
|
||||
{ TABLE_ERROR_READ, "could not read from file" },
|
||||
{ TABLE_ERROR_WRITE, "could not write to file" },
|
||||
{ TABLE_ERROR_MMAP_NONE, "no mmap support compiled in library" },
|
||||
{ TABLE_ERROR_MMAP, "could not mmap the file" },
|
||||
{ TABLE_ERROR_MMAP_OP, "operation not valid on mmap files" },
|
||||
{ TABLE_ERROR_EMPTY, "table is empty" },
|
||||
{ TABLE_ERROR_NOT_EMPTY, "table contains data" },
|
||||
{ TABLE_ERROR_ALIGNMENT, "invalid alignment value" },
|
||||
{ TABLE_ERROR_COMPARE, "problems with internal comparison" },
|
||||
{ TABLE_ERROR_FREE, "memory free error" },
|
||||
{ 0 }
|
||||
{ TABLE_ERROR_NONE, "no error" },
|
||||
{ TABLE_ERROR_PNT, "invalid table pointer" },
|
||||
{ TABLE_ERROR_ARG_NULL, "buffer argument is null" },
|
||||
{ TABLE_ERROR_SIZE, "incorrect size argument" },
|
||||
{ TABLE_ERROR_OVERWRITE, "key exists and no overwrite" },
|
||||
{ TABLE_ERROR_NOT_FOUND, "key does not exist" },
|
||||
{ TABLE_ERROR_ALLOC, "error allocating memory" },
|
||||
{ TABLE_ERROR_LINEAR, "linear access not in progress" },
|
||||
{ TABLE_ERROR_OPEN, "could not open file" },
|
||||
{ TABLE_ERROR_SEEK, "could not seek to position in file" },
|
||||
{ TABLE_ERROR_READ, "could not read from file" },
|
||||
{ TABLE_ERROR_WRITE, "could not write to file" },
|
||||
{ TABLE_ERROR_MMAP_NONE, "no mmap support compiled in library" },
|
||||
{ TABLE_ERROR_MMAP, "could not mmap the file" },
|
||||
{ TABLE_ERROR_MMAP_OP, "operation not valid on mmap files" },
|
||||
{ TABLE_ERROR_EMPTY, "table is empty" },
|
||||
{ TABLE_ERROR_NOT_EMPTY, "table contains data" },
|
||||
{ TABLE_ERROR_ALIGNMENT, "invalid alignment value" },
|
||||
{ TABLE_ERROR_COMPARE, "problems with internal comparison" },
|
||||
{ TABLE_ERROR_FREE, "memory free error" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#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:
|
||||
*/
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
|
||||
|
@ -88,31 +93,31 @@ typedef INT64 int64_t;
|
|||
/* define some commodity macros for Dump/Restore functionality */
|
||||
#ifndef SIMCLIST_NO_DUMPRESTORE
|
||||
/* write() decorated with error checking logic */
|
||||
#define WRITE_ERRCHECK(fd, msgbuf, msglen) do { \
|
||||
if (write(fd, msgbuf, msglen) < 0) return -1; \
|
||||
} while (0);
|
||||
#define WRITE_ERRCHECK(fd, msgbuf, msglen) do { \
|
||||
if (write(fd, msgbuf, msglen) < 0) return -1; \
|
||||
} while (0);
|
||||
/* READ_ERRCHECK() decorated with error checking logic */
|
||||
#define READ_ERRCHECK(fd, msgbuf, msglen) do { \
|
||||
if (read(fd, msgbuf, msglen) != msglen) { \
|
||||
/*errno = EPROTO;*/ \
|
||||
return -1; \
|
||||
} \
|
||||
} while (0);
|
||||
#define READ_ERRCHECK(fd, msgbuf, msglen) do { \
|
||||
if (read(fd, msgbuf, msglen) != msglen) { \
|
||||
/*errno = EPROTO;*/ \
|
||||
return -1; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
/* convert 64bit integers from host to network format */
|
||||
#define hton64(x) (\
|
||||
htons(1) == 1 ? \
|
||||
(uint64_t)x /* big endian */ \
|
||||
: /* little endian */ \
|
||||
((uint64_t)((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
|
||||
(((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
|
||||
(((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
|
||||
(((uint64_t)(x) & 0x00000000000000ffULL) << 56))) \
|
||||
)
|
||||
#define hton64(x) ( \
|
||||
htons(1) == 1 ? \
|
||||
(uint64_t)x /* big endian */ \
|
||||
: /* little endian */ \
|
||||
((uint64_t)((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
|
||||
(((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
|
||||
(((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
|
||||
(((uint64_t)(x) & 0x00000000000000ffULL) << 56))) \
|
||||
)
|
||||
|
||||
/* convert 64bit integers from network to host format */
|
||||
#define ntoh64(x) (hton64(x))
|
||||
|
@ -206,12 +211,12 @@ static int list_attrOk(const list_t *restrict l);
|
|||
|
||||
/* do not inline, this is recursive */
|
||||
static void list_sort_quicksort(list_t *restrict l, int versus,
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel);
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel);
|
||||
|
||||
static inline void list_sort_selectionsort(list_t *restrict l, int versus,
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel);
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel);
|
||||
|
||||
static void *list_get_minmax(const list_t *restrict l, int versus);
|
||||
|
||||
|
@ -792,8 +797,8 @@ static void *list_sort_quicksort_threadwrapper(void *wrapped_params) {
|
|||
#endif
|
||||
|
||||
static inline void list_sort_selectionsort(list_t *restrict l, int versus,
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel) {
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel) {
|
||||
struct list_entry_s *cursor, *toswap, *firstunsorted;
|
||||
void *tmpdata;
|
||||
|
||||
|
@ -813,8 +818,8 @@ static inline void list_sort_selectionsort(list_t *restrict l, int versus,
|
|||
}
|
||||
|
||||
static void list_sort_quicksort(list_t *restrict l, int versus,
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel) {
|
||||
unsigned int first, struct list_entry_s *fel,
|
||||
unsigned int last, struct list_entry_s *lel) {
|
||||
unsigned int pivotid;
|
||||
unsigned int i;
|
||||
register struct list_entry_s *pivot;
|
||||
|
@ -1094,15 +1099,15 @@ int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict
|
|||
|
||||
/**** DUMP FORMAT ****
|
||||
|
||||
[ ver timestamp | totlen numels elemlen hash | DATA ]
|
||||
[ ver timestamp | totlen numels elemlen hash | DATA ]
|
||||
|
||||
where DATA can be:
|
||||
@ for constant-size list (element size is constant; elemlen > 0)
|
||||
[ elem elem ... elem ]
|
||||
@ for other lists (element size dictated by element_meter each time; elemlen <= 0)
|
||||
[ size elem size elem ... size elem ]
|
||||
where DATA can be:
|
||||
@ for constant-size list (element size is constant; elemlen > 0)
|
||||
[ elem elem ... elem ]
|
||||
@ for other lists (element size dictated by element_meter each time; elemlen <= 0)
|
||||
[ size elem size elem ... size elem ]
|
||||
|
||||
all integers are encoded in NETWORK BYTE FORMAT
|
||||
all integers are encoded in NETWORK BYTE FORMAT
|
||||
*****/
|
||||
|
||||
|
||||
|
@ -1327,10 +1332,10 @@ int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len
|
|||
/* possibly verify the list consistency */
|
||||
/* wrt hash */
|
||||
/* don't do that
|
||||
if (header.listhash != 0 && header.listhash != list_hash(l)) {
|
||||
errno = ECANCELED;
|
||||
return -1;
|
||||
}
|
||||
if (header.listhash != 0 && header.listhash != list_hash(l)) {
|
||||
errno = ECANCELED;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
/* wrt header */
|
||||
|
@ -1487,14 +1492,14 @@ static int list_repOk(const list_t *restrict l) {
|
|||
struct list_entry_s *s;
|
||||
|
||||
ok = (l != NULL) && (
|
||||
/* head/tail checks */
|
||||
(l->head_sentinel != NULL && l->tail_sentinel != NULL) &&
|
||||
(l->head_sentinel != l->tail_sentinel) && (l->head_sentinel->prev == NULL && l->tail_sentinel->next == NULL) &&
|
||||
/* empty list */
|
||||
(l->numels > 0 || (l->mid == NULL && l->head_sentinel->next == l->tail_sentinel && l->tail_sentinel->prev == l->head_sentinel)) &&
|
||||
/* spare elements checks */
|
||||
l->spareelsnum <= SIMCLIST_MAX_SPARE_ELEMS
|
||||
);
|
||||
/* head/tail checks */
|
||||
(l->head_sentinel != NULL && l->tail_sentinel != NULL) &&
|
||||
(l->head_sentinel != l->tail_sentinel) && (l->head_sentinel->prev == NULL && l->tail_sentinel->next == NULL) &&
|
||||
/* empty list */
|
||||
(l->numels > 0 || (l->mid == NULL && l->head_sentinel->next == l->tail_sentinel && l->tail_sentinel->prev == l->head_sentinel)) &&
|
||||
/* spare elements checks */
|
||||
l->spareelsnum <= SIMCLIST_MAX_SPARE_ELEMS
|
||||
);
|
||||
|
||||
if (!ok) return 0;
|
||||
|
||||
|
@ -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:
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,7 @@
|
|||
#include "table.h"
|
||||
|
||||
static char *rcs_id =
|
||||
"$Id: table_util.c,v 1.5 2000/03/09 03:30:42 gray Exp $";
|
||||
"$Id: table_util.c,v 1.5 2000/03/09 03:30:42 gray Exp $";
|
||||
|
||||
#define WRITE_MODE 0640 /* mode to write out table */
|
||||
#define SPECIAL_CHARS "e\033^^\"\"''\\\\n\nr\rt\tb\bf\fa\007"
|
||||
|
@ -61,67 +61,67 @@ static char *rcs_id =
|
|||
* out_size - size of the output buffer.
|
||||
*/
|
||||
int expand_chars(const void *buf, const int buf_size,
|
||||
char *out, const int out_size)
|
||||
char *out, const int out_size)
|
||||
{
|
||||
int buf_c;
|
||||
const unsigned char *buf_p, *spec_p;
|
||||
char *max_p, *out_p = out;
|
||||
int buf_c;
|
||||
const unsigned char *buf_p, *spec_p;
|
||||
char *max_p, *out_p = out;
|
||||
|
||||
/* setup our max pointer */
|
||||
max_p = out + out_size;
|
||||
/* setup our max pointer */
|
||||
max_p = out + out_size;
|
||||
|
||||
/* run through the input buffer, counting the characters as we go */
|
||||
for (buf_c = 0, buf_p = (const unsigned char *)buf;; buf_c++, buf_p++) {
|
||||
/* run through the input buffer, counting the characters as we go */
|
||||
for (buf_c = 0, buf_p = (const unsigned char *)buf;; buf_c++, buf_p++) {
|
||||
|
||||
/* did we reach the end of the buffer? */
|
||||
if (buf_size < 0) {
|
||||
if (*buf_p == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buf_c >= buf_size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* did we reach the end of the buffer? */
|
||||
if (buf_size < 0) {
|
||||
if (*buf_p == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buf_c >= buf_size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* search for special characters */
|
||||
for (spec_p = (unsigned char *)SPECIAL_CHARS + 1;
|
||||
*(spec_p - 1) != '\0';
|
||||
spec_p += 2) {
|
||||
if (*spec_p == *buf_p) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* search for special characters */
|
||||
for (spec_p = (unsigned char *)SPECIAL_CHARS + 1;
|
||||
*(spec_p - 1) != '\0';
|
||||
spec_p += 2) {
|
||||
if (*spec_p == *buf_p) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* did we find one? */
|
||||
if (*(spec_p - 1) != '\0') {
|
||||
if (out_p + 2 >= max_p) {
|
||||
break;
|
||||
}
|
||||
(void)sprintf(out_p, "\\%c", *(spec_p - 1));
|
||||
out_p += 2;
|
||||
continue;
|
||||
}
|
||||
/* did we find one? */
|
||||
if (*(spec_p - 1) != '\0') {
|
||||
if (out_p + 2 >= max_p) {
|
||||
break;
|
||||
}
|
||||
(void)sprintf(out_p, "\\%c", *(spec_p - 1));
|
||||
out_p += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* print out any 7-bit printable characters */
|
||||
if (*buf_p < 128 && isprint(*buf_p)) {
|
||||
if (out_p + 1 >= max_p) {
|
||||
break;
|
||||
}
|
||||
*out_p = *(char *)buf_p;
|
||||
out_p += 1;
|
||||
}
|
||||
else {
|
||||
if (out_p + 4 >= max_p) {
|
||||
break;
|
||||
}
|
||||
(void)sprintf(out_p, "\\%03o", *buf_p);
|
||||
out_p += 4;
|
||||
}
|
||||
}
|
||||
/* print out any 7-bit printable characters */
|
||||
if (*buf_p < 128 && isprint(*buf_p)) {
|
||||
if (out_p + 1 >= max_p) {
|
||||
break;
|
||||
}
|
||||
*out_p = *(char *)buf_p;
|
||||
out_p += 1;
|
||||
}
|
||||
else {
|
||||
if (out_p + 4 >= max_p) {
|
||||
break;
|
||||
}
|
||||
(void)sprintf(out_p, "\\%03o", *buf_p);
|
||||
out_p += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out_p - out;
|
||||
return out_p - out;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -141,22 +141,22 @@ int expand_chars(const void *buf, const int buf_size,
|
|||
*/
|
||||
static void dump_table(table_t *tab_p)
|
||||
{
|
||||
char buf[10240];
|
||||
void *key_p, *data_p;
|
||||
int ret, key_size, data_size, len, entry_c;
|
||||
char buf[10240];
|
||||
void *key_p, *data_p;
|
||||
int ret, key_size, data_size, len, entry_c;
|
||||
|
||||
for (ret = table_first(tab_p, (void **)&key_p, &key_size,
|
||||
(void **)&data_p, &data_size), entry_c = 0;
|
||||
ret == TABLE_ERROR_NONE;
|
||||
ret = table_next(tab_p, (void **)&key_p, &key_size,
|
||||
(void **)&data_p, &data_size), entry_c++) {
|
||||
/* expand the key */
|
||||
len = expand_chars(key_p, key_size, buf, sizeof(buf));
|
||||
(void)printf("%d: key '%.*s' (%d), ", entry_c, len, buf, len);
|
||||
/* now dump the data */
|
||||
len = expand_chars(data_p, data_size, buf, sizeof(buf));
|
||||
(void)printf("data '%.*s' (%d)\n", len, buf, len);
|
||||
}
|
||||
for (ret = table_first(tab_p, (void **)&key_p, &key_size,
|
||||
(void **)&data_p, &data_size), entry_c = 0;
|
||||
ret == TABLE_ERROR_NONE;
|
||||
ret = table_next(tab_p, (void **)&key_p, &key_size,
|
||||
(void **)&data_p, &data_size), entry_c++) {
|
||||
/* expand the key */
|
||||
len = expand_chars(key_p, key_size, buf, sizeof(buf));
|
||||
(void)printf("%d: key '%.*s' (%d), ", entry_c, len, buf, len);
|
||||
/* now dump the data */
|
||||
len = expand_chars(data_p, data_size, buf, sizeof(buf));
|
||||
(void)printf("data '%.*s' (%d)\n", len, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -176,120 +176,131 @@ static void dump_table(table_t *tab_p)
|
|||
*/
|
||||
static void usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"Usage: table_util\n"
|
||||
" [-b number] or --buckets num buckets to adjust table\n"
|
||||
" [-o file] or --out-file output filename\n"
|
||||
" [-v] or --verbose verbose messages\n"
|
||||
" file input table filename\n");
|
||||
exit(1);
|
||||
(void)fprintf(stderr,
|
||||
"Usage: table_util\n"
|
||||
" [-b number] or --buckets num buckets to adjust table\n"
|
||||
" [-o file] or --out-file output filename\n"
|
||||
" [-v] or --verbose verbose messages\n"
|
||||
" file input table filename\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
table_t *tab_p;
|
||||
char do_write = 0, verbose = 0;
|
||||
char *out_file = NULL, *in_file;
|
||||
int ret, entry_n, bucket_n, num_buckets = 0;
|
||||
table_t *tab_p;
|
||||
char do_write = 0, verbose = 0;
|
||||
char *out_file = NULL, *in_file;
|
||||
int ret, entry_n, bucket_n, num_buckets = 0;
|
||||
|
||||
/* process the args */
|
||||
for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) {
|
||||
/* process the args */
|
||||
for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) {
|
||||
|
||||
switch (*(*argv + 1)) {
|
||||
switch (*(*argv + 1)) {
|
||||
|
||||
case 'b':
|
||||
argc--, argv++;
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
}
|
||||
num_buckets = atoi(*argv);
|
||||
break;
|
||||
case 'b':
|
||||
argc--, argv++;
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
}
|
||||
num_buckets = atoi(*argv);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
argc--, argv++;
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
}
|
||||
out_file = *argv;
|
||||
break;
|
||||
case 'o':
|
||||
argc--, argv++;
|
||||
if (argc == 0) {
|
||||
usage();
|
||||
}
|
||||
out_file = *argv;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc != 1) {
|
||||
usage();
|
||||
}
|
||||
if (argc != 1) {
|
||||
usage();
|
||||
}
|
||||
|
||||
/* take the last argument as the input file */
|
||||
in_file = *argv;
|
||||
/* take the last argument as the input file */
|
||||
in_file = *argv;
|
||||
|
||||
/* read in the table from disk */
|
||||
tab_p = table_read(in_file, &ret);
|
||||
if (tab_p == NULL) {
|
||||
(void)fprintf(stderr, "table_util: unable to table_read from '%s': %s\n",
|
||||
in_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
/* read in the table from disk */
|
||||
tab_p = table_read(in_file, &ret);
|
||||
if (tab_p == NULL) {
|
||||
(void)fprintf(stderr, "table_util: unable to table_read from '%s': %s\n",
|
||||
in_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* get info about the table */
|
||||
ret = table_info(tab_p, &bucket_n, &entry_n);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr,
|
||||
"table_util: unable to get info on table in '%s': %s\n",
|
||||
in_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
/* get info about the table */
|
||||
ret = table_info(tab_p, &bucket_n, &entry_n);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr,
|
||||
"table_util: unable to get info on table in '%s': %s\n",
|
||||
in_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
(void)printf("Read table of %d buckets and %d entries from '%s'\n",
|
||||
bucket_n, entry_n, in_file);
|
||||
(void)printf("Read table of %d buckets and %d entries from '%s'\n",
|
||||
bucket_n, entry_n, in_file);
|
||||
|
||||
if (verbose) {
|
||||
dump_table(tab_p);
|
||||
}
|
||||
if (verbose) {
|
||||
dump_table(tab_p);
|
||||
}
|
||||
|
||||
if (num_buckets > 0) {
|
||||
/* adjust the table's buckets */
|
||||
ret = table_adjust(tab_p, num_buckets);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr,
|
||||
"table_util: unable to adjust table to %d buckets: %s\n",
|
||||
num_buckets, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
do_write = 1;
|
||||
}
|
||||
if (num_buckets > 0) {
|
||||
/* adjust the table's buckets */
|
||||
ret = table_adjust(tab_p, num_buckets);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr,
|
||||
"table_util: unable to adjust table to %d buckets: %s\n",
|
||||
num_buckets, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
do_write = 1;
|
||||
}
|
||||
|
||||
/* did we modify the table at all */
|
||||
if (do_write) {
|
||||
if (out_file == NULL) {
|
||||
out_file = in_file;
|
||||
}
|
||||
/* did we modify the table at all */
|
||||
if (do_write) {
|
||||
if (out_file == NULL) {
|
||||
out_file = in_file;
|
||||
}
|
||||
|
||||
/* write out our table */
|
||||
ret = table_write(tab_p, out_file, WRITE_MODE);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr, "table_util: unable to write table to '%s': %s\n",
|
||||
out_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
/* write out our table */
|
||||
ret = table_write(tab_p, out_file, WRITE_MODE);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr, "table_util: unable to write table to '%s': %s\n",
|
||||
out_file, table_strerror(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
(void)printf("Wrote table to '%s'\n", out_file);
|
||||
}
|
||||
(void)printf("Wrote table to '%s'\n", out_file);
|
||||
}
|
||||
|
||||
/* free the table */
|
||||
ret = table_free(tab_p);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr, "table_util: unable to free table: %s\n",
|
||||
table_strerror(ret));
|
||||
/* NOTE: not a critical error */
|
||||
}
|
||||
/* free the table */
|
||||
ret = table_free(tab_p);
|
||||
if (ret != TABLE_ERROR_NONE) {
|
||||
(void)fprintf(stderr, "table_util: unable to free table: %s\n",
|
||||
table_strerror(ret));
|
||||
/* NOTE: not a critical error */
|
||||
}
|
||||
|
||||
exit(0);
|
||||
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:
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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_ */
|
|
@ -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);
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
/*!
|
||||
|
|
|
@ -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:
|
||||
*/
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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*/
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
*/
|
|
@ -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:
|
||||
|
|
|
@ -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,8 +281,12 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||
if (mm->vbuf) {
|
||||
buffer_bytes = mm->vbuf;
|
||||
}
|
||||
fps = mm->fps;
|
||||
|
||||
if (mm->fps) {
|
||||
fps = mm->fps;
|
||||
} else {
|
||||
mm->fps = fps;
|
||||
}
|
||||
|
||||
if (mm->vw && mm->vh) {
|
||||
mst->width = mm->vw;
|
||||
mst->height = mm->vh;
|
||||
|
@ -469,49 +481,62 @@ 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;
|
||||
|
||||
img = NULL;
|
||||
|
||||
if (switch_queue_pop_timeout(eh->video_queue, &pop, 66000) == SWITCH_STATUS_SUCCESS) {
|
||||
if (!pop) break;
|
||||
img = (switch_image_t *) pop;
|
||||
|
||||
if (last_img && (last_img->d_w != img->d_w || last_img->d_h != img->d_h)) {
|
||||
/* scale to match established stream */
|
||||
switch_img_scale(img, &tmp_img, last_img->d_w, last_img->d_h);
|
||||
switch_img_free(&img);
|
||||
img = tmp_img;
|
||||
tmp_img = NULL;
|
||||
}
|
||||
|
||||
switch_img_free(&last_img);
|
||||
last_img = img;
|
||||
} else {
|
||||
if (last_img) {
|
||||
img = last_img;
|
||||
do {
|
||||
switch_status_t status;
|
||||
img = NULL;
|
||||
|
||||
if (!popped) {
|
||||
status = switch_queue_pop(eh->video_queue, &pop);
|
||||
popped++;
|
||||
} else {
|
||||
continue;
|
||||
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 (!img) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (last_img && (last_img->d_w != img->d_w || last_img->d_h != img->d_h)) {
|
||||
/* scale to match established stream */
|
||||
switch_img_scale(img, &tmp_img, last_img->d_w, last_img->d_h);
|
||||
switch_img_free(&img);
|
||||
img = tmp_img;
|
||||
tmp_img = NULL;
|
||||
}
|
||||
|
||||
switch_img_free(&last_img);
|
||||
last_img = img;
|
||||
|
||||
//switch_mutex_lock(eh->mutex);
|
||||
|
||||
eh->in_callback = 1;
|
||||
|
@ -526,6 +551,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
|
||||
|
@ -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;
|
||||
|
@ -1707,9 +1750,9 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
|||
switch_buffer_read(context->audio_buffer, context->audio_st.frame->data[0], bytes);
|
||||
/* convert to destination format */
|
||||
ret = avresample_convert(context->audio_st.resample_ctx,
|
||||
(uint8_t **)context->audio_st.frame->data, 0, out_samples,
|
||||
context->audio_st.tmp_frame->data, 0, context->audio_st.frame->nb_samples);
|
||||
|
||||
(uint8_t **)context->audio_st.frame->data, 0, out_samples,
|
||||
context->audio_st.tmp_frame->data, 0, context->audio_st.frame->nb_samples);
|
||||
|
||||
if (ret < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while converting %d samples, error text: %s\n",
|
||||
context->audio_st.frame->nb_samples, get_error_text(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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
//}
|
||||
|
|
|
@ -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)) {
|
||||
|
@ -675,7 +675,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
|||
switch_mutex_lock(member->audio_out_mutex);
|
||||
lock_member(member);
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
|
||||
|
||||
if (member->rec) {
|
||||
conference->recording_members++;
|
||||
}
|
||||
|
@ -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,24 +922,26 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
|||
member->status_field = cJSON_CreateString("");
|
||||
cJSON_AddItemToArray(member->json, member->status_field);
|
||||
|
||||
switch_channel_get_variables(member->channel, &var_event);
|
||||
if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) {
|
||||
switch_channel_get_variables(member->channel, &var_event);
|
||||
|
||||
dvars = cJSON_CreateObject();
|
||||
dvars = cJSON_CreateObject();
|
||||
|
||||
for (hi = var_event->headers; hi; hi = hi->next) {
|
||||
if (!strncasecmp(hi->name, "verto_dvar_", 11)) {
|
||||
char *var = hi->name + 11;
|
||||
|
||||
if (var) {
|
||||
cJSON_AddItemToObject(dvars, var, cJSON_CreateString(hi->value));
|
||||
for (hi = var_event->headers; hi; hi = hi->next) {
|
||||
if (!strncasecmp(hi->name, "verto_dvar_", 11)) {
|
||||
char *var = hi->name + 11;
|
||||
|
||||
if (var) {
|
||||
cJSON_AddItemToObject(dvars, var, cJSON_CreateString(hi->value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cJSON_AddItemToArray(member->json, dvars);
|
||||
|
||||
switch_event_destroy(&var_event);
|
||||
}
|
||||
|
||||
cJSON_AddItemToArray(member->json, dvars);
|
||||
|
||||
switch_event_destroy(&var_event);
|
||||
|
||||
cJSON_AddItemToArray(member->json, cJSON_CreateNull());
|
||||
|
||||
conference_member_update_status_field(member);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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,61 +1457,75 @@ 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;
|
||||
if (switch_queue_pop(member->mux_out_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||
mcu_layer_t *layer = NULL;
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
|
||||
if (!pop) {
|
||||
break;
|
||||
}
|
||||
if (!pop) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (loops == 0 || loops == 50) {
|
||||
switch_core_media_gen_key_frame(member->session);
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
if (loops == 0 || loops == 50) {
|
||||
switch_core_media_gen_key_frame(member->session);
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
}
|
||||
|
||||
loops++;
|
||||
|
||||
if ((switch_size_t)pop != 1) {
|
||||
frame = (switch_frame_t *) pop;
|
||||
if (switch_test_flag(frame, SFF_ENCODED)) {
|
||||
switch_core_session_write_encoded_video_frame(member->session, frame, 0, 0);
|
||||
} else {
|
||||
switch_core_session_write_video_frame(member->session, frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
}
|
||||
|
||||
loops++;
|
||||
|
||||
if ((switch_size_t)pop != 1) {
|
||||
frame = (switch_frame_t *) pop;
|
||||
if (switch_test_flag(frame, SFF_ENCODED)) {
|
||||
switch_core_session_write_encoded_video_frame(member->session, frame, 0, 0);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
switch_frame_buffer_free(member->fb, &frame);
|
||||
last = now;
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_mutex_lock(member->conference->canvas_mutex);
|
||||
if (member->video_layer_id > -1 && member->canvas_id > -1) {
|
||||
canvas = member->conference->canvases[member->canvas_id];
|
||||
layer = &canvas->layers[member->video_layer_id];
|
||||
switch_frame_buffer_free(member->fb, &frame);
|
||||
}
|
||||
|
||||
if (layer->need_patch) {
|
||||
switch_mutex_lock(canvas->mutex);
|
||||
} else {
|
||||
canvas = NULL;
|
||||
layer = NULL;
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(member->conference->canvas_mutex);
|
||||
switch_mutex_lock(member->conference->canvas_mutex);
|
||||
if (member->video_layer_id > -1 && member->canvas_id > -1) {
|
||||
canvas = member->conference->canvases[member->canvas_id];
|
||||
layer = &canvas->layers[member->video_layer_id];
|
||||
|
||||
if (canvas) {
|
||||
switch_thread_rwlock_rdlock(canvas->video_rwlock);
|
||||
conference_video_scale_and_patch(layer, NULL, SWITCH_FALSE);
|
||||
layer->need_patch = 0;
|
||||
switch_thread_rwlock_unlock(canvas->video_rwlock);
|
||||
switch_mutex_unlock(canvas->mutex);
|
||||
if (layer->need_patch) {
|
||||
switch_mutex_lock(canvas->mutex);
|
||||
} else {
|
||||
canvas = NULL;
|
||||
layer = NULL;
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(member->conference->canvas_mutex);
|
||||
|
||||
if (canvas) {
|
||||
switch_thread_rwlock_rdlock(canvas->video_rwlock);
|
||||
conference_video_scale_and_patch(layer, NULL, SWITCH_FALSE);
|
||||
layer->need_patch = 0;
|
||||
switch_thread_rwlock_unlock(canvas->video_rwlock);
|
||||
switch_mutex_unlock(canvas->mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1900,9 +1915,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
|||
canvas->video_timer_reset = 1;
|
||||
|
||||
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;
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,7 +1359,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load)
|
|||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown)
|
||||
{
|
||||
return SWITCH_STATUS_UNLOAD;
|
||||
|
||||
switch_event_free_subclass(MY_EVENT_VIDEO_DETECT);
|
||||
|
||||
return SWITCH_STATUS_UNLOAD;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue