public class RTTCall
extends java.lang.Object
RTTcall is one of the core classes, establishing the RTP session and interfacing with Omnitor's RFC 4103 implementation. It communicates in both directions with the layers above and below, amd coordinates the two RTP libraries underneath (JRTP and Omnitor t140). It receives information from the SIP layer above about how to set up the call, and then initiates the RTP session. It then continuously receives text input from above, which it places into the Omnitor buffer, to be sent by the lower layer. It also listens for incoming RT text from Omnitor's library, and passes it up to any TextListeners that are registered with it (this may be something of a layer violation, though TextListener is within the SIP package).
-------------- | UI layer | -------------- | -------------- | SIP layer | (SipClient) -------------- | -------------- | Call layer | (RTTCall) -------------- | -------------- | RTP layer | (JRTP, Omnitor t140) --------------
RTTCall stores the state of one call at a time, which can be calling (outgoing), ringing (incoming), connected, or ended. A new one should be created for each logical call, since each one needs its own new RTP session. Since the state transitions are caused by user interaction or SIP messages, the upper layer needs to tell RTTCall when to change state, by calling methods such as setRinging(). State changes span layers to some extent, so the RTTCall stores some SIP requests and events involved in its own creation, for later reference when the SIP layer is sending messages within dialogs or transactions. The upper layer may therefore need to call such methods as getInviteTransaction() or getCreationEvent().
Constructor and Description |
---|
RTTCall(android.javax.sip.message.Request creationRequest,
android.javax.sip.Dialog dialog,
java.util.List<TextListener> messageReceivers)
Use this constructor for an outgoing call.
|
RTTCall(android.javax.sip.RequestEvent requestEvent,
android.javax.sip.ServerTransaction transaction,
java.util.List<TextListener> messageReceivers)
Use this constructor for an incoming call.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(java.lang.String remoteIP,
int remotePort,
int localRTPPort,
int t140MapNum,
int t140RedMapNum)
Connect an incoming call that is currently ringing.
|
void |
addDialog(android.javax.sip.Dialog dialog)
Use this to change the Dialog associated with the call, especially if one was not
available at creation of the RTTCall.
|
void |
addInviteTransaction(android.javax.sip.ClientTransaction transaction)
Use this to change the ClientTransaction that was used to send the original INVITE request
e.g.
|
void |
callAccepted(java.lang.String remoteIP,
int remotePort,
int localRTPPort,
int t140MapNum,
int t140RedMapNum)
Connect an outgoing call has been accepted by the remote party, to set up the RTP
session according to the agreed parameters.
|
void |
end()
End a call at any stage.
|
boolean |
equals(RTTCall otherCall)
This is not a true equals() override, since it does not compare
arbitrary objects.
|
android.javax.sip.RequestEvent |
getCreationEvent()
This method returns the incoming RequestEvent that created the call, if any.
|
android.javax.sip.message.Request |
getCreationRequest()
This method returns the outgoing Request that created the call, if any.
|
android.javax.sip.Dialog |
getDialog()
Get the dialog for an ongoing connected call, so as to send more messages in that dialog,
for example when sending BYE.
|
android.javax.sip.ClientTransaction |
getInviteClientTransaction()
Get the ClientTransaction from the original INVITE dialog of an outgoing call.
|
android.javax.sip.ServerTransaction |
getInviteTransaction()
Get the ServerTransaction from the original INVITE dialog of an incoming call.
|
android.javax.sip.address.Address |
getOtherParty() |
boolean |
isCalling() |
boolean |
isConnected() |
boolean |
isRinging() |
void |
resetMessageReceivers(java.util.List<TextListener> messageReceivers)
Replace the existing list of TextListeners with the new one, if the list of current activities
changes.
|
void |
sendText(java.lang.String text)
The most important method: send real-time text in the connected call.
|
void |
setCalling()
Set the call to the calling state, when the SIP INVITE has been sent and before the other
party has sent a final response.
|
void |
setRinging()
Set the call to the ringing state after the incoming INVITE is received but before the user
has accepted or declined it.
|
public RTTCall(android.javax.sip.RequestEvent requestEvent, android.javax.sip.ServerTransaction transaction, java.util.List<TextListener> messageReceivers)
requestEvent
- the incoming INVITE eventtransaction
- used to send 180 Ringing, and the final response. null if no 180 has been
sent yet and therefore no transaction is used yet. In that case, only
one response can be sent,messageReceivers
- the TextListeners that need to be notified when there is incoming textpublic RTTCall(android.javax.sip.message.Request creationRequest, android.javax.sip.Dialog dialog, java.util.List<TextListener> messageReceivers)
creationRequest
- the INVITE Request sent to the other party to initiate the calldialog
- the dialog that is already created for the call is available, or null if none yetmessageReceivers
- the TextListeners that need to be notified when there is incoming textpublic android.javax.sip.ServerTransaction getInviteTransaction()
public android.javax.sip.ClientTransaction getInviteClientTransaction()
public void addDialog(android.javax.sip.Dialog dialog)
dialog
- the new Dialog to associate with the call,public void addInviteTransaction(android.javax.sip.ClientTransaction transaction)
transaction
- the new ClientTransaction to associate with the callpublic void resetMessageReceivers(java.util.List<TextListener> messageReceivers)
messageReceivers
- the new TextListenerspublic android.javax.sip.RequestEvent getCreationEvent()
public android.javax.sip.message.Request getCreationRequest()
public android.javax.sip.Dialog getDialog()
public boolean equals(RTTCall otherCall)
public void setCalling()
public void setRinging()
public void accept(java.lang.String remoteIP, int remotePort, int localRTPPort, int t140MapNum, int t140RedMapNum) throws java.lang.IllegalStateException, gov.nist.jrtp.RtpException
remoteIP
- the IP of the remote party for the RTP streamremotePort
- the port of the remote party for the RTP streamlocalRTPPort
- the local port to be used for the RTP streamt140MapNum
- the RTP payload map number corresponding to t140 in the agreed session descriptiont140RedMapNum
- must be <= 0 if not using redundancy! This is the RTP payload map number corresponding to
"red", the redundant media type, in the agreed session descriptionjava.lang.IllegalStateException
- if no call is currently ringinggov.nist.jrtp.RtpException
- if the call can't be connectedpublic void callAccepted(java.lang.String remoteIP, int remotePort, int localRTPPort, int t140MapNum, int t140RedMapNum) throws java.lang.IllegalStateException, gov.nist.jrtp.RtpException
remoteIP
- the IP of the remote party for the RTP streamremotePort
- the port of the remote party for the RTP streamlocalRTPPort
- the local port to be used for the RTP streamt140MapNum
- the RTP payload map number corresponding to t140 in the agreed session descriptiont140RedMapNum
- must be <= 0 if not using redundancy! This is the RTP payload map number corresponding to
"red", the redundant media type, in the agreed session descriptionjava.lang.IllegalStateException
- if no call is currently outgoinggov.nist.jrtp.RtpException
- if the call can't be connectedpublic void sendText(java.lang.String text)
text
- the characters to sendjava.lang.IllegalStateException
- if the call is not connected yetpublic void end()
public boolean isRinging()
public boolean isConnected()
public boolean isCalling()
public android.javax.sip.address.Address getOtherParty()