Copyright (C) 2009 Greg Dorfuss - mhspot.com

SipToSis is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
SipToSis is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this source code; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
Based on mjsip 1.6 software.
Uses skype4java,log4j,jspeex libraries and ilbc codec from sip-communicator.
mjsip, skype4java,log4j,jspeex and sip-communicator have their own license agreements.


2009/09/02
New parameters for low balance email notifcation:
    emailWhenBalanceDropsTo
	emailHost
	emailPort
	emailUsername
	emailPassword
	emailRecipients
	emailFrom
	emailTest


2009/08/29
Added new parameter replaceFromWithSkypeId to allow setting the calling skype id into the from sip address.
This makes it possible for Xlite and possibly other SIP devices to call back a missed skype call.


2009/08/22
Fix mjsip invite ack problems with error responses.
Fix 401/407/301/302 response not creating proper invite request object


2009/08/12
Documentation updates to readme.txt
Fix intermittent null exception on cancel call
Fix some junk is the stsdialresult macro


2009/08/03
Fix sipparser bug causing exception.
Display message when 4xx received from sip target.
Fix JoinManualSkypeOutboundCallToSip error at end of call.
Updated precompiled linux connectors


2009/07/28
Stop runaway call if skype connector is having problems.
Added parameter 'runConnectorReliabilityTest' for diagnostic purposes.
Changed connector command timeout to 2 seconds instead of the default of 10
Major changes to linux native connector to fix threading issues.
   If upgrading on linux, make sure to delete existing libskype.so in siptosis root folder.
Changed some default settings.

2009/07/16
Remove need to edit SipToSis_win.bat for 64 bit startup
Change basic installer to update skype.dll if wrong version.
Fix call cost missing when other party hangs up first.


2009/07/08
Fixed intermittent linux skype connector startup hang.


2009/07/03
Bunch of changes to windows skype connectors.
Added 64 bit windows startup to SipToSis_win.bat - you have to uncomment the set JAVA_HOME line for 64 bit startup.


2009/06/25
Changed history tracking - seems skype's callid doesn't stay the same and causes duplication of imported call logs.


2009/06/18
New debugging parameter skypeAPITrace.
Added check for incoming skype call cancelled before status listener added to connector.
Added ability for multiple STUN servers to be specified.

2009/06/16
Fix exceptions if incoming skype caller cancels call before the call has been answered.

2009/06/03
Fix possible error when loading call history.
Removed disabling of STUN testing if error condition detected. (Loss of internet connectivity could disable the STUN testing)
Has new version libskype.so for IA32 linux systems. (Old one is libskype_ia32_orig.so in case new one causes problems)


2009/05/26
Changed Call logging - creates csv logs by day
   New parameter: callLogPath
   Log Format: Call type,SkypeCallId,callFrom,CallTo,Date,DurationSeconds,CallCost
Call Limting enhancements
   New parameters: MaxCallTimeLimitMinutes,WarnMinutesBeforeCutoff,OverLimitWarningFile,OverUsageLimitSipResponse
   ,dailyPstnLimitMinutes,dailyPstnUniqueNumberLimit,refuseNewPstnCallsWhenRemainingMinutesUnder
   ,MaxPstnCallTimeLimitMinutes,loadSkypeClientCallHistory
Note: If you don't set loadSkypeClientCallHistory=yes, calls made outside of SipToSis will not be tracked.


2009/05/12
Added Session Progress (SIP Early Media Sending)
  New Parameter - sendSkypeEarlyMediaOverSipSessionProgress - you need to set to yes to enable this feature.
Fix null exception on reinvite with no sdp.  
Added OS X Skype Framework to auto installer.

2009/05/02
Nat enhancements to help deal with external providers and still function from internal network:
  Added new parameter 'publicIP' for static IP setting.
  Added basic STUN support - new paramters: 'stunServer' and 'stunTestInterval' - This will set the publicIP and enable above also.
   The above are used to translate the RTP connection field when the RTP endpoint is an external address.
  New parameters 'enableNatTranslate' and 'enableNatTranslateVia' will translate messages when communicating with external destinations.
Added warning message of duplicate parameters to help detect configuration mistakes.


2009/04/23
Fix cost calculation.
Added new parameter 'connectionFee' that will be added to the calculated call cost.

2009/04/22
Added call cost information.
Added display of acct balance at end of calls.
Improved connector reconnect ability.
Added 407 registration support.


2009/04/14 
Added a basic automatic installer - updated installation instructions accordingly.
Added via_addr to startup display.
Better local IP detection for linux.
Change some default settings to reduce required configuration.
Fix bug with dynamic payload if only one codec defined.
Allow 302 to work when registrar server is enabled

2009/03/31
Added skype4java source to distrib.
Fix call error causing endless message.


2009/03/28
changed Skype incoming call address to use contact_url.
Fix Keepalive Exception that may occur during restart.
Default config now has keepalive turned off - turn on only if registering to external network server.
If Skype connection lost, no longer needs to wait 30 seconds for reconnect.
Improved Skype client connection recovery for windows. Use new skype.dll in samples folder.
Added new parameter connectorWatchDogMinutes - to check skype client connection periodically. Disabled by default.
Updated OS X instructions.
Fix typo causing skypeUnPlacedResponse setting to not function.

2009/03/14
Updated to skype4java as of 2009/02/18
	Due to this, JNIConnector.dll is now known as skype.dll
New parameter skypeUserId - Allows binding to a specific skype instance to allow multiple channals in the same user.	
Fix incoming skype caller id not being sent if from_url not set.
Fixed IP address authentication security hole.


2009/02/17
Change (again) rfc2833 DTMF encoding for compatibility issues with some SIP servers.
Modify compile scripts to exclude jmf/tritonus libs by default. Set flags in top of compiles to enable.
Fixed register to use proper sequence and call-id as per rfc3261


2009/02/16
Added AMD 64 bit JNIConnector_amd_x64.dll to samples folder.
Added AMD 64 bit libskype_amd_x86_64.so to samples folder.
Fix localnet option to include 127. loopback addresses.
Moved compile scripts to separate folder.

2009/02/14
Changed rfc2833 DTMF encoding for compatibility issues with some SIP servers.
Changed default SkypeDtmfDetectorHitThreshold setting to 90 to reduce falsing - 30 is too low.
For incoming Skype calls, use info contained in registrar server user database if available. 
   This will override the registered user's ip/port that is specified in the SkypeToSipAuth.props file. 
   This allows softphone/phones like Xlite using dynamic SIP ports to be able to receive Skype calls too.
Changed sample configuration to use auto config for easier initial setup.
Changed startup display to show actual contact_url.
Added new parameter sendSkypeImDelay to allow setting delay time between IM and actual skype call to user.
Updated skype4java linux libskype.so compiling instructions in readme.txt.
Fix dynamic codec case sensitivity issue with Xlite.
Fix compatibility issue with sip devices (like Xlite) that don't put rtpmap in session descriptor for standard codecs.
Registrar server is now enabled by default. PBX users should disable this.
Added display of source of DISCARDED messages.
Added localnet keyword option in SipToSkypeAuth.props.
Fix resume of SIP hold causing temporary hang until rtp timeout period expires.


2009/01/31
Changed project name - if using default config file names, you need to rename your config files to the new name.
   You also need to use the new startup files.
Fixed incoming skype calls giving appearance of false underruns
macro-stsdialresult is now included

2009/01/10
Fix intermittent missed call crash.
Redirect Skype audio to STS audio handlers sooner than before.
Fix Skype ID not being sent to SIP target when using pin authentication.
Changed startup display to show Host via_addr instead of java's detected IP

2008/12/21
Added ability to override configured SIP outbound settings of user,password,realm and from for incoming Skype calls - See example in SkypeToSipAuth.props
Added mjsip server registrar support - your phone can now register with STS if needed to make it work. Look at the end of sample .cfg

2008/11/01
Added new parameter - JoinManualSkypeOutboundCallToSip - Enables special mode that if Skype client is used to make an outbound call,
  it will first cancel the skype call. Then a SIP call will be made based on the original called skype user id or number. 
  When the SIP destination answers, the outbound skype call will be made as if the SIP destination had made the skype call.
  Side affect is the original attempt will ping the Skype user. Can't fix that.
Added new parameter - inbandFullTimeDtmfDetection - set to no to turn off inband dtmf detection once call is active. Saves cpu once call established.
Added new parameter - FilterParams - Applies an RC or FIR filter to received skype audio before downsampling - see sample config file for settings 
Addition of "Raw" codecs, Just add RW to the end of the codec name - Removes downsampling averaging. You need to use a filter for these.

2008/10/25
Patch to ignore optional channel in codec descriptor
Fix call log showing wrong FromSIP address
Added new parameter jitterLevel
Added new parameters for setting socket buffers:
TcpRxBufferSize,TcpTxBufferSize,RtpRxBufferSize,RtpTxBufferSize
Allow manual usage of skype client to make skype call. If a SIP was call received within 5 seconds then it will be cancelled as before.
Allow manual skype call answering using skype client - SIP destination will still be attempted.
Added new parameter SkypeInboundSipDestUnavailableAction - if set to 'ring' will allow skype client to answer the call even though SIP was not available.
Added ability to use calleeid after Pin authentication
Fix intermittent UNPLACED skype status allowing skype client to continue with an uncontrolled call.


2008/10/20
Fix auth or map change not using new data if using config watcher
Fix clips not closed if hangup before completion
Fix SkypeOutDialingRules.props sample
Added speex16K codec - I can't test it.


2008/10/18
Major RTP changes, more event driven
Removed maxAudioDelayMs and useskypetimingsource - have no purpose now
Added more audio stats
Updated to skype4java as of 2008/10/18
Included skype4java is compiled for java 1.5 to eliminate an extra download

2008/10/15
  Fix bug causing maxAudioDelayMs setting to be ignored.
  Better Rtp Timing.


2008/10/11
Added parameter SipInboundAllChannelsBusyAction 
   - Allows multiple outgoing channels without a PBX by using 302 redirects to next channel. (still requires multiple instances)
   - AsteriskWin32 0.66b does not like this. Don't know about other versions.
Added new parameter configWatchInterval - checks every x minutes for config file changes and will auto reload when needed.
   - This is usefull for multiple trunks where you don't want to login to each trunk just to make a config change. 
   - Instead it will reload the changes automatically at the next check interval.
   - I suggest you try your change on a test channel first to make sure it restarts correctly
Minor default setting changes
Added 302 redirect support to mjsip
Removed audio speedup code, not pratical
Moved sample config files and skype4java libs to samples folder 
Some rtp improvements

2008/09/26
Fix - If rfc2833 dtmf payload is positioned before audio codec in invite descriptor, it can cause codec selection failure
Added configurable skype call failure response codes - see sample config file
Fix - Remote party hangup may cause Bye loop - Shows up as a series of 481 errors in logs if debugging turned on
Added parameter lockRtpSendAddressAfterPackets - normally if enableSendRTPtoReceivedAddress=yes, the first rtp packet received will lock the rtp sender address.
   By setting this new parameter, It will lock the address after receiving the number of packets specified.


2008/09/14
GSM can now be handled with either Sun's JMF or Tritonus libraries.
tritonus_gsm-0.3.6.jar and tritonus_share-0.3.6.jar can be downloaded from tritonus.org (plugins page)
Added Speex Codec - uses jspeex - (high cpu usage, poor sound, maybe you can tweek it)
Added iLBC Codec - uses ilbc code from sipcommunicator
Fix syntax errors in SipToSkypeAuth_sample.props
Allow gain level setting per codec - see sample config
audio_avp parameter is back if needed, speex and ilbc must be set - see sample config
Changes to codec selector to handle dynamic payload types
Fix Skype call not cancelled if SIP call cancelled before skype call initiated


2008/09/08
Changed to JMF GSM Decoder/Encoder
   You will need to download JMF.jar from Sun

2008/09/07
fix codec load failure message
Added GSM codec - you need to get tritonus_gsm-0.3.6.jar and tritonus_share-0.3.6.jar from tritonus.org and put in same folder


2008/09/06
Change to use common format clip files. All audio file clips now must be 16khz 16bit mono wav files.
Added codec PCMA (a-law) support - see sample config file
You can now add your own codecs by implementing local.ua.sscodecs.SSCodec interface
Ability to configure multiple codecs - see sample config file
Fix crash if placed on hold then off hold if auth sequence used.
Cleanup some funky dtmf sdp code
New parameter noRtpReceivedAutoHangupSeconds to help with silence suppression causing hangups
obsoleted parameters
   audio_sample_rate
   audio_sample_size
   audio_avp
Fix intermittant problem with Asterisk rtp connection reset by peer message which causes immediate hangup
Asterisk compatability enhancements canreinvite=yes now works (for me anyway)


2008/08/28
Fix some exception handlers
Minor changes to some messages

2008/08/23
Get rid of warn errors due to received sip messages before initialize has completed
Added new params to help with nat issues
    sendResponseUsingOutboundProxy
	useViaRport
	useViaReceived
Change to call logging
    make sure to overwrite log.properties	

2008/08/18
Fix send dtmf to skype bug
New parameter enableSendRTPtoReceivedAddress to help with one way audio

2008/08/14
Fix wrong underrun count when on SIP hold
Some cleanup


2008/08/13
Fix intermittent speedup noise
More RTP enhancements


2008/08/12
Added Freeswitch reg example
Some comment changes/additions
New parameter audioPriorityIncrease
Modified audio speedup code to be variable
Added more audio stats
Fix connector load library error display


2008/08/09
Added load lib test if skype4java fails to load connector so the real error is seen
Change to startup scripts to specify lib path for connector libraries
Connector libraries have been extracted into the program root
Change behavior of maxAudioDelayMs - it will double speed the overage, if it too far behind resort to chopping
Added display of chopping,compress, underruns stats if any performed.
Added new Parameter useskypetimingsource
Added different status codes depending on skype call failure reason
	603 Refused
	404 Failed, Invalid user, no skype credit (Can't tell the difference)
	408 UNPLACED whatever that means
	600 Busy
	403 Anything else


2008/08/05
Project Renamed
manual compile script fixes
removed extraneous stuff
updated sample config comments

2008/08/03
Added new param maxAudioDelayMs
Fixed All Channels full 486 response ACK loop bug

2008/08/02
added manual build scripts - linux version no tested at all
fix registration warn messages
quiet down the console when not in debug mode

Added SIP Inband DTMF detection

new params: 
  SkypeDtmfDetectorHitThreshold
  SkypeDtmfDetectorSilenceThreshold
  enableSIPInbandDtmfDetector
  SipDtmfDetectorHitThreshold
  SipDtmfDetectorSilenceThreshold
  SipOutDialingRulesFile

SkypeDTMF Detection is now working. To activate, set:
  enableSkypeDtmfDetector=yes

For SIP Inband, set:
  enableSIPInbandDtmfDetector=yes 
  You should disable rfc2833 and info in this mode
  
  

2008/07/28
debugging changes


2008/07/25
Fixed call logging
Fixed dialing rules file case
New param logConfigFile
RTP enhancements


2008/07/22 - first version of v3 - limited testing
---- You must add some new parameters if upgrading from v2----
Changed linux startup script to linux/unix format
Fix EarlyMedia with pin issue.
Added exit code so scripts can detect startup failure.
Parameters skype_audioinport and skype_audiooutport merged to new single parameter skype_audioportbase
New parameter concurrentcalllimit
New parameter skypeclientsupportsmulticalls
Refactored to handle multiple call streams - Win Skype Clients 3.6 - 3.8 do not support multi active calls - do any?
  A non supporting skype client will show on console "A call exists in INPROGRESS" if attempting multiple outbound calls.
Now supports SIP Hold
Now supports Skype Hold
Changed to skype4java version as of 2008/07/14
New parameter SkypeOutDialingRules - set your area dialing preferences - look at cfg file for example
New parameter sendSipDtmfToSkype
New parameter sendSkypeDtmfToSip - not working
Added 401/407 INVITE Cancel patch
New parameter SkypeInboundAllChannelsBusyAction - what to do when no more available channels

2008/06/28
Added new parameter autoShutdownMinutes - shutdown after time has expired and no call in progress - 5 minute increments.
Added support for DTMF over INFO messages.
Added new parameter dtmfinfotype - set to application/dtmf or application/dtmf-relay to activate DTMF over INFO msgs.
added enableSkypeDtmfDetector to allow experiments with decoding of skype analog dtmf
Fixed blank pin not working

2008/06/16 
moved OPTIONS handler code to a earlier location to guarantee message gets intercepted.
Fixed some more java 1.5 compatibility issues.
Added 486 response to invite if no INVITE listener available.
Added new parameter skypeimmessage to set your own IM message.
Added init contact info if none specified.
 
2008/06/14
Added new parameter dtmf2833payloadtype  - default is still 101
Change RTP delay timing to adjust for cpu loading - affects playing of files and authentication only
Changed blank RTP packets to contain a valid value.
Fix some issues with SIP dtmf sending code.
Added cnonce/nc support if qop authentication specified
Reduce java requirements to java 1.5
Fix intermittant loss of INVITE handler - It would stop answering SIP calls
Refuse multiple incoming skype calls since it isn't supported.

2008/06/06
Added SIP OPTIONS message support so Asterisk can determine status
Reduced likelihood of getting a duplicate branch
Fix REGISTER www authenication not creating new branch
Fix INVITE www/proxy authenication not creating new branch
Added new parameter sendSkypeIM to send an incoming call message when calling a skype user

2008/06/01
Removed setting of skype userid in User Agent

2008/05/28
Fixed linux/mac startup script.
New experiental handleEarlyMedia flag to send Skype status audio during SkypeOut calls


2008/04/27:
  added ack 401/407 invite response to help with asterisk 491 error

2008/04/06:
  Change to mjua to reset local session when handling calls - it was using last incoming SIP call origins as it's own for outgoing SIP calls.
  Changed origin to set a session id. removed user name prefix from origin owner
  Fixed real registration problem. When provider sends multiple expires tags, mjsip was grabbing the wrong one. Changed to select the highest which should be the most recent registration.


2008/03/18:
  Updated call logging format
  Registration mystery solved. Provider sending retarded expiration times.
  Two new parameters added to help with funky registration issues.
     Added minregrenewtime to cfg file - Default is 60 seconds. A warning message will be put in log if provider tries to set below this limit.
     Added regfailretrytime to cfg file - Default is 15 seconds. If a registration fails. It will retry again in this number of seconds instead of waiting the normal expires time.

2008/03/16:
  Added function to detect when queued clips are done playing
  Added ability to play files to skype callers
  Changed to latest skype4java. Fixed dropped skype calls not being detected
  Got rid of my pipeinputstreamsizable since jre 1.6 has sizable pipes now.
  Increased pipe buffer sizes - They were getting overrun under load.

2008/03/13:
  Added RFC2833 DTMF sending to SIP caller.
  Added pin/destination retry limits.
  Added ability to change pin/dest clip files.
  Throw away any inbound rtp packets received before we are ready to process.
  Added ability to send a dtmf to sip caller on sip accept (i.e. grandcentral, etc.)
  Added new pause and dtmf commands to SipToSkypeAuth.props.
  Modification for playing of multiple files syntax - you now have to separate each file to play. Example: play:filename1;play:filename2;
  Added missing libraries for Skype4Java

2008/03/10:
  Change siptoskypeauthmapper to cycle through the list in sequence.
  Fixed bug with id pattern.
  Removed double buffering of audio.
  Changed logging to log4j - needs log4j-1.2.15, logging controlled by log.properties.
  Added logging of Sip To Skype calls.
  Allow pintimeout & destinationtimeout to be set in config file.
  Delay auth start until call is confirmed by mjsip.
  Include skype_full.jar instead of just win32.

2008/03/02:
  Fixed mjsip sdp parser problem with c parameter not above first media descriptor
  Fixed dtmf map not being removed if remote doesn't support it.

2008/03/01:
  Added RFC2833 DTMF detection from SIP side.
  Added Pin authorization and destination entry via DTMF - incoming sip callers
  Added audioClip playback to incoming sip callers
  updated explanations in SipToSkypeAuth.props and SkypeToSipAuth.props	
  Allow // to be indicate comments after parameters of SipToSkypeAuth.props and SkypeToSipAuth.props files

2008/02/23:
  Added auto hangup if loss of incoming rtp for 5 seconds

2008/02/21:
  Remove redirect_to and replaced with new authorization system
  see SipToSkypeAuth.props and SkypeToSipAuth.props
  Got rid of annoying sounds playing on computer

2008/02/20:
  Fixed registration bug.
  Updated dial plan in readme to use # not * to avoid conflict.
  Added registration example in cfg file.
