com.sipresponse.flibblecallmgr
Class CallManager

java.lang.Object
  extended by com.sipresponse.flibblecallmgr.CallManager

public class CallManager
extends java.lang.Object

Object is central to flibble-voip. Allows for call control and media control. Provides a simple to use interface for controlling SIP based calls.

Author:
Mike Cohen

Field Summary
static java.lang.String AUTO_DISCOVER
           
 
Constructor Summary
CallManager()
          Constructor.
 
Method Summary
 FlibbleResult acceptCall(java.lang.String callHandle, int statusCode)
          Accepts an invite from a remote party, sending a non final response
 java.lang.String addLine(java.lang.String sipUriString, java.lang.String displayName, boolean register, int registerPeriod, java.lang.String password)
          Creates a line entity associated with a SIP URL (display name + uri).
 void addListener(FlibbleListener listener)
          Sets an object to receive Flibble Events.
 FlibbleResult answerCall(java.lang.String callHandle, MediaSourceType mediaSourceType, java.lang.String mediaFilename, boolean loop, int initialVolume, int initialGain)
          Answers an invite from a remote party, sending a final 200 OK response
 FlibbleResult blindTransfer(java.lang.String callHandle, java.lang.String targetUri)
          Transfers a currently connected call by sending a REFER message to the remote party.
 FlibbleResult changeMediaSource(java.lang.String callHandle, MediaSourceType mediaSourceType, java.lang.String mediaFilename, boolean loop)
          Changes the media source for a call in progress.
 java.lang.String createCall(java.lang.String lineHandle, java.lang.String sipUriString)
          Creates a call entity on the requested line
 void destroyCallManager()
          Tears down this call manager.
 FlibbleResult enableEchoSuppression(boolean enable, float percentSuppression)
          Enables local echo suppression.
 FlibbleResult endCall(java.lang.String callHandle)
          Ends a currently connected call by sending a BYE message to the remote party.
 CallData getCallData(java.lang.String callHandle)
           
 java.lang.String getContactIp()
           
 java.lang.String getDomain()
           
 java.lang.String getLocalIp()
           
 int getMediaPortEnd()
           
 int getMediaPortStart()
           
 java.lang.String getProxyAddress()
           
 int getProxyPort()
           
 java.lang.String getPublicIp()
           
 java.lang.String getStunServer()
           
 int getUdpSipPort()
           
 java.lang.String getUserAgent()
           
 boolean getUseSoundCard()
           
 FlibbleResult holdCall(java.lang.String callHandle, boolean hold, int volume)
          Puts a call on hold, or takes a call off hold, in a asynchronous manner.
 FlibbleResult holdCallSynchronous(java.lang.String callHandle, boolean hold, int volume, int timeout)
          Puts a call on hold, or takes a call off hold, in a synchronous manner.
 FlibbleResult initialize()
          Initializes the CallManager by loading the default property file, "flibble.properties",
 FlibbleResult initialize(java.lang.String filename)
          Initializes the CallManager by loading the default property file specified by the filename
 FlibbleResult initialize(java.lang.String localIp, int udpSipPort, int mediaPortStart, int mediaPortEnd, java.lang.String domain, java.lang.String proxyAddress, int proxyPort, java.lang.String stunServer, java.lang.String userAgent, boolean useSoundCard, java.lang.String mediaPluginClass)
          Initializes the CallManager.
 FlibbleResult joinCalls(CallData[] calls)
          Joins currently connected calls into a conference (CURRENTLY UNIMPLEMENTED)
 FlibbleResult joinCalls(java.util.Vector<CallData> calls)
          Joins currently connected calls into a conference (CURRENTLY UNIMPLEMENTED)
 FlibbleResult placeCall(java.lang.String callHandle, MediaSourceType mediaSourceType, java.lang.String filename, boolean loop, int initialVolume, int initialGain)
          Sends an INVITE to the remote party.
 FlibbleResult playFileLocally(java.net.URL url, boolean loop, int volume)
          Plays a media file to the system's audio playout device.
 void removeAllListeners()
          Removes aLL objectS from the list of objects to receive Flibble Events.
 void removeListener(FlibbleListener listener)
          Removes an object from the list of objects to receive Flibble Events.
 void sendDtmf(java.lang.String callHandle, int dtmfCode)
          Sends a dtmf event to the remote party of the call.
 FlibbleResult setCallVolume(java.lang.String callHandle, int vol)
          Sets the call playout volume for a specific call.
 FlibbleResult setGain(int gain)
          Sets the microphone gain level.
 void setPublicIp(java.lang.String publicIp)
           
 void setUdpSipPort(int udpSipPort)
           
 void setVolume(int vol)
          Sets the audio playout volume for non-call related scenarios, such as local media file playout.
 FlibbleResult stopFileLocally(java.net.URL url)
          Stops local playout of a media file.
 FlibbleResult stopLocalPlayoutAll()
          Stops local playout of all media files.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTO_DISCOVER

public static final java.lang.String AUTO_DISCOVER
See Also:
Constant Field Values
Constructor Detail

CallManager

public CallManager()
Constructor.

Method Detail

initialize

public FlibbleResult initialize()
                         throws java.io.IOException,
                                java.lang.IllegalArgumentException
Initializes the CallManager by loading the default property file, "flibble.properties",

Returns:
Result of initialization
Throws:
java.io.IOException
java.lang.IllegalArgumentException

initialize

public FlibbleResult initialize(java.lang.String filename)
                         throws java.io.IOException,
                                java.lang.IllegalArgumentException
Initializes the CallManager by loading the default property file specified by the filename

Parameters:
filename - The filename of property file to be used for initialization.
Returns:
Result of initialization
Throws:
java.io.IOException
java.lang.IllegalArgumentException

initialize

public FlibbleResult initialize(java.lang.String localIp,
                                int udpSipPort,
                                int mediaPortStart,
                                int mediaPortEnd,
                                java.lang.String domain,
                                java.lang.String proxyAddress,
                                int proxyPort,
                                java.lang.String stunServer,
                                java.lang.String userAgent,
                                boolean useSoundCard,
                                java.lang.String mediaPluginClass)
                         throws java.lang.IllegalArgumentException
Initializes the CallManager. The object must not be used before initialization (with the exception of addListener).

Parameters:
localIp - - The IP address to be bound to for receiving SIP messages. This address (or the associated public address, if STUN is enabled) will appear in the SIP contact and via headers, and in the SDP's origin and destination headers.
udpSipPort - The udp port for receiving and sending SIP messages.
mediaPortStart - The start of the range of allowable ports for use with RTP.
mediaPortEnd - The end of the range of allowable ports for use with RTP.
proxyAddress - SIP proxy address or host name.
proxyPort - Port value for the SIP proxy.
stunServer - The stun server name or address to be used for STUN discovery.
useSoundCard - True if the application wishes to use an audio hardware device. Otherwise, false.
mediaPluginClass - Full classpath and name of the the media plugin class. Can be set to null to indicate usage of the default media plugin.
Throws:
java.lang.IllegalArgumentException

addLine

public java.lang.String addLine(java.lang.String sipUriString,
                                java.lang.String displayName,
                                boolean register,
                                int registerPeriod,
                                java.lang.String password)
Creates a line entity associated with a SIP URL (display name + uri). The line can be registered with a proxy, or provisioned.

Parameters:
sipUriString - - The SIP uri associated with this line. eg "sip:foo@example.com"
displayName - - Display name portion of the SIP URL for this line. Useful for caller ID.
register - - Whether or not to perform SIP registration with the proxy.
registerPeriod - - The requested period (in seconds) of the registration.
password - - A password used for registration authentication.
Returns:
Line handle associated with the line entity.

createCall

public java.lang.String createCall(java.lang.String lineHandle,
                                   java.lang.String sipUriString)
Creates a call entity on the requested line

Parameters:
lineHandle - The line handle to be used for the call.
sipUriString - The callee's SIP uri.
Returns:
Call handle of the newly created call entity.

placeCall

public FlibbleResult placeCall(java.lang.String callHandle,
                               MediaSourceType mediaSourceType,
                               java.lang.String filename,
                               boolean loop,
                               int initialVolume,
                               int initialGain)
Sends an INVITE to the remote party. The response to the invite will come in the form of an event. See FlibbleListener.onEvent.

Parameters:
callHandle - The call handle obtained by invoking createCall.
mediaSourceType - Type of media source to send to the remote endpoint of the call.
filename - For file media types, the filename of the .wav file to be used as a media source.
loop - For file media types, and indication of the desired looping behavior
initialVolume - Initial volume for audio playout. Valid values are between 0 and 100, inclusive
initialGain - Initial microphone gain. Valid values are between 0 and 100, inclusive
Returns:
A result indicating the validity of the parameters. Actual results of the INVITE will come in the form of an event See FlibbleListener.onEvent.

joinCalls

public FlibbleResult joinCalls(CallData[] calls)
Joins currently connected calls into a conference (CURRENTLY UNIMPLEMENTED)

Parameters:
calls - array of calls to be joined into a conference.
Returns:
The result of the join.

joinCalls

public FlibbleResult joinCalls(java.util.Vector<CallData> calls)
Joins currently connected calls into a conference (CURRENTLY UNIMPLEMENTED)

Parameters:
calls - array of calls to be joined into a conference.
Returns:
The result of the join.

endCall

public FlibbleResult endCall(java.lang.String callHandle)
Ends a currently connected call by sending a BYE message to the remote party.

Parameters:
callHandle - Handle of the call to end.
Returns:
A result indicating the validity of the parameters. Actual results of the BYE will come in the form of an event See FlibbleListener.onEvent.

acceptCall

public FlibbleResult acceptCall(java.lang.String callHandle,
                                int statusCode)
Accepts an invite from a remote party, sending a non final response

Parameters:
callHandle - - Handle of the call to be accepted
statusCode - - The non final response code to send back to the remote party. For example, a 180 Ringing response.

answerCall

public FlibbleResult answerCall(java.lang.String callHandle,
                                MediaSourceType mediaSourceType,
                                java.lang.String mediaFilename,
                                boolean loop,
                                int initialVolume,
                                int initialGain)
Answers an invite from a remote party, sending a final 200 OK response

Parameters:
callHandle - Handle of the call to be answered.
mediaSourceType - Type of media source to send to the remote endpoint of the call.
filename - For file media types, the filename of the .wav file to be used as a media source.
loop - For file media types, and indication of the desired looping behavior
initialVolume - Initial volume for audio playout. Valid values are between 0 and 100, inclusive
initialGain - Initial microphone gain. Valid values are between 0 and 100, inclusive

changeMediaSource

public FlibbleResult changeMediaSource(java.lang.String callHandle,
                                       MediaSourceType mediaSourceType,
                                       java.lang.String mediaFilename,
                                       boolean loop)
Changes the media source for a call in progress.

Parameters:
callHandle - Handle of the call.
mediaSourceType - Type of media source to send to the remote endpoint of the call.
filename - For file media types, the filename of the .wav file to be used as a media source.
loop - For file media types, and indication of the desired looping behavior
initialVolume - Initial volume for audio playout. Valid values are between 0 and 100, inclusive
initialGain - Initial microphone gain. Valid values are between 0 and 100, inclusive

enableEchoSuppression

public FlibbleResult enableEchoSuppression(boolean enable,
                                           float percentSuppression)
Enables local echo suppression. The effect of echo suppression will be that, during local audio playout of remote audio, the microphone capture will be suppressed, or partially suppressed.

Parameters:
enable - Enables or disables echo suppression.
percentSuppression - The percent of echo suppression to use. (100% will mute the microphone during above-threshold local audio playout)
Returns:

setGain

public FlibbleResult setGain(int gain)
Sets the microphone gain level.

Parameters:
gain - Gain level (valid values are 0 - 100)
Returns:

setCallVolume

public FlibbleResult setCallVolume(java.lang.String callHandle,
                                   int vol)
Sets the call playout volume for a specific call.

Parameters:
callHandle -
vol -
Returns:

setVolume

public void setVolume(int vol)
Sets the audio playout volume for non-call related scenarios, such as local media file playout.

Parameters:
vol -

playFileLocally

public FlibbleResult playFileLocally(java.net.URL url,
                                     boolean loop,
                                     int volume)
Plays a media file to the system's audio playout device.

Parameters:
url - - Url of the media file.
loop - - Looping preference.
volume - Volume (valid values are 0 - 100)
Returns:

stopFileLocally

public FlibbleResult stopFileLocally(java.net.URL url)
Stops local playout of a media file.

Parameters:
url - Url of the media file to be stopped.
Returns:

stopLocalPlayoutAll

public FlibbleResult stopLocalPlayoutAll()
Stops local playout of all media files.

Returns:

holdCallSynchronous

public FlibbleResult holdCallSynchronous(java.lang.String callHandle,
                                         boolean hold,
                                         int volume,
                                         int timeout)
Puts a call on hold, or takes a call off hold, in a synchronous manner.

Parameters:
callHandle - The call to put on or off hold.
hold - On-hold or off-hold preference
volume - For off-hold operations, the local playout volume at which to resume the call.
timeout - Maximum time to wait for a hold operation to complete
Returns:

holdCall

public FlibbleResult holdCall(java.lang.String callHandle,
                              boolean hold,
                              int volume)
Puts a call on hold, or takes a call off hold, in a asynchronous manner.

Parameters:
callHandle - The call to put on or off hold.
hold - On-hold or off-hold preference
volume - For off-hold operations, the local playout volume at which to resume the call.
Returns:

blindTransfer

public FlibbleResult blindTransfer(java.lang.String callHandle,
                                   java.lang.String targetUri)
Transfers a currently connected call by sending a REFER message to the remote party.

Parameters:
callHandle - Handle of the call to transfer.
targetUri - URI of the transfer target.
Returns:
A result indicating the validity of the parameters. Actual results of the transfer will come in the form of an event See FlibbleListener.onEvent.

sendDtmf

public void sendDtmf(java.lang.String callHandle,
                     int dtmfCode)
Sends a dtmf event to the remote party of the call.

Parameters:
callHandle - - Handle of the call for the sending of dtmf.
dtmfCode - - 0-9 for digits 0 to 9, * is 10, # is 11.

addListener

public void addListener(FlibbleListener listener)
Sets an object to receive Flibble Events.

Parameters:
listener - Listener to add.

removeListener

public void removeListener(FlibbleListener listener)
Removes an object from the list of objects to receive Flibble Events.

Parameters:
listener - Listener to remove.

removeAllListeners

public void removeAllListeners()
Removes aLL objectS from the list of objects to receive Flibble Events.


getLocalIp

public java.lang.String getLocalIp()

getMediaPortEnd

public int getMediaPortEnd()

getMediaPortStart

public int getMediaPortStart()

getDomain

public java.lang.String getDomain()

getProxyAddress

public java.lang.String getProxyAddress()

getProxyPort

public int getProxyPort()

getUdpSipPort

public int getUdpSipPort()

setUdpSipPort

public void setUdpSipPort(int udpSipPort)

getUseSoundCard

public boolean getUseSoundCard()

getCallData

public CallData getCallData(java.lang.String callHandle)

getPublicIp

public java.lang.String getPublicIp()

setPublicIp

public void setPublicIp(java.lang.String publicIp)

getContactIp

public java.lang.String getContactIp()

getUserAgent

public java.lang.String getUserAgent()

getStunServer

public java.lang.String getStunServer()

destroyCallManager

public void destroyCallManager()
Tears down this call manager.