|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.echarts.test.sip.SIPAgentImpl
public class SIPAgentImpl
For internal use only
Method Summary | |
---|---|
void |
addMessageModifier(MessageModifier modifier)
Adds a message modifier. |
void |
afterSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context)
|
void |
afterSIPMessageSent(org.echarts.jain.sip.InterceptorContext context)
|
CommandId |
answer()
Send a 200 OK response to the peer endpoint |
void |
beforeSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context)
|
void |
beforeSIPMessageSent(org.echarts.jain.sip.InterceptorContext context)
|
CommandId |
call(SIPAgent callee)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee |
CommandId |
call(SIPAgent callee,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee and with the
additional headers specified |
CommandId |
call(SIPAgent callee,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap,
java.lang.String fromUri)
|
CommandId |
call(SIPAgent callee,
java.lang.String fromUri)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee and From header
containing the value specified in fromUri . |
CommandId |
call(java.lang.String sipuri)
Sends an INVITE with the request URI containing the value specified in calleeUri |
CommandId |
call(java.lang.String ruri,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Sends an INVITE with the request URI containing the value specified in sipuri and with the additional
headers specified |
CommandId |
call(java.lang.String ruri,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap,
java.lang.String fromUri)
|
CommandId |
call(java.lang.String sipuri,
java.lang.String fromUri)
Sends an INVITE with the request URI containing the value specified in calleeUri and From header containing
the value specified in fromUri . |
CommandId |
callNoSdp(SIPAgent callee)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(SIPAgent callee,
java.lang.String fromUri)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(java.lang.String sipuri)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(java.lang.String sipuri,
java.lang.String fromuri)
Variant of call method where no SDP is sent |
CommandId |
cancel()
Send a CANCEL to the peer endpoint |
void |
clearMediaBuffer()
This primitive clears the internal data structures within a agent used to keep track of the received RTP packets. |
void |
close()
|
void |
enableAutoAnswer()
Sends a 200 OK response to an incoming INVITE without any explicit answer() command from the test case. |
CommandId |
end()
Send a BYE to the peer endpoint |
CommandId |
execUserCommand(UserCommand command)
Execute user command. |
BaseState |
getCurrentState()
Get the current state of the agent state machine |
java.lang.String |
getDisplayName()
|
java.lang.String |
getDTMFReceived()
Gets the DTMF digits that were received earlier as part of the RTP stream and then stored in a buffer. |
java.lang.String |
getLastRecvdSDPAsString()
Get the last received SDP in string format |
long |
getLastRecvdSDPTimeStamp()
|
java.lang.String |
getMarkedSDPAsString()
|
long |
getMarkedSDPTimeStamp()
|
java.util.List<MessageExchangeRecord> |
getMessageHistory()
|
java.lang.String |
getMessageHistoryAsString()
|
java.lang.String |
getMessageHistorySummary()
|
java.lang.String |
getName()
Get the name of the agent |
java.lang.String |
getProxy()
Get the SIP address of the proxy server this agent points to. |
java.util.List<Response> |
getResponses(CommandId cmdId,
int respCode)
Returns the list of responses for the request indicated by cmdId and with response code respCode . |
java.lang.String |
getRTPCaptureFileName()
Returns the name of the file in which the RTP packets are captured. |
java.lang.String |
getRTPIP()
Gets the IP address being used for listening in RTP sessions |
int |
getRTPPort()
Gets port number being used for listening in RTP sessions |
SipURI |
getSipURI()
Get the SIP URI of this agent as a SipURI so that it can be used in methods like call , answer . |
java.lang.String |
getSipURIAsString()
Get the SIP URI of this agent as a string so that it can be used in methods like call , answer . |
CommandId |
info(java.lang.String contentType,
java.lang.String contentSubType,
java.lang.String content)
Send a INFO message to the peer endpoint with the specified content type, content subtype and content. |
boolean |
isMediaBufferEmpty()
|
void |
markSDP()
Saves the latest SDP received from the peer agent as a result of session negotiation. |
void |
msgRecvd(BaseState state,
Message msg)
|
void |
msgSent(BaseState state,
Message msg)
|
void |
playAudio(java.io.InputStream is)
Play raw audio from the specified input stream. |
void |
playAudio(java.lang.String fileName)
Play raw audio from the file name specified. |
void |
printMessageHistory()
Print the history of SIP messages received/sent by this agent |
void |
pushRoute(java.lang.String route)
Specify route header(s) that needs to be included as part of an initial INVITE message that may be sent later. |
void |
pushSelfRoute()
Specify a self route header that needs to be sent as part of an initial INVITE message that may be sent later. |
void |
recycle()
Resets the agent and makes it ready for use again even after an end |
CommandId |
redirect(int redirectCode,
Address address)
Send a 302 redirect response to the peer endpoint with the specified contact address in the response |
CommandId |
redirect(int redirectCode,
SipURI sipuri)
Send a 302 redirect response to the peer endpoint with the specified contact URI in the response |
CommandId |
redirect(int redirectCode,
java.lang.String addr)
Send a 302 redirect response to the peer endpoint with the specified contact address in the response |
CommandId |
register(java.lang.String domain,
java.lang.String user,
java.lang.String passwd)
Sends a REGISTER message. |
CommandId |
register(java.lang.String domain,
java.lang.String user,
java.lang.String passwd,
int expires)
Sends a REGISTER message. |
CommandId |
reinvite()
Send a re-INVITE to the peer endpoint with no change in SDPs. |
CommandId |
reinvite(SDPModifier sdpModifier)
Send a re-INVITE to the peer endpoint with changes in SDP, the changes specified using the SDPModifier. |
CommandId |
reinviteHold()
Send a re-INVITE to the peer endpoint with a hold SDP (a=sendonly media attribute). |
CommandId |
reinviteNoSdp()
Send a re-INVITE with no SDP to solicit an offer from the peer endpoint. |
CommandId |
reinviteResume()
Send a re-INVITE to the peer endpoint with a normal SDP (a=sendrecv media attribute). |
void |
removeAllMessageModifiers()
Removes all previously added message modifiers. |
void |
removeMessageModifier(MessageModifier modifier)
Removes a previously added message modifier. |
CommandId |
sendDTMF(java.lang.String keys)
Sends DTMF keys to the remote SIP agent with which this agent has already established a SIP dialog and started an RTP session. |
CommandId |
sendResponse(int responseCode)
Send a response to the peer end point with the response code specified as parameter |
CommandId |
sendResponse(int responseCode,
java.util.LinkedHashMap<java.lang.String,java.util.List<java.lang.String>> headerMap)
|
void |
setProxy(java.lang.String proxy)
Sets the proxy for this agent. |
void |
setStepMode(boolean b)
Turns on/off user agent step execution mode. |
CommandId |
shutdown()
|
void |
step()
Takes default action for the most recently received message. |
CommandId |
subscribe(java.lang.String eventType,
java.lang.String acceptContentType,
java.lang.String acceptContentSubType,
java.lang.String msgContentType,
java.lang.String msgContentSubType,
java.lang.String msgContent,
int expires)
|
java.lang.String |
toString()
|
int |
waitForRtpAbsence(int silenceDuration,
int maxWait)
EXPERIMENTAL. |
int |
waitForRtpPresence(int maxWait)
EXPERIMENTAL. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public java.lang.String getName()
SIPAgent
getName
in interface SIPAgent
public java.lang.String getDisplayName()
public void setProxy(java.lang.String proxy) throws CATException
SIPAgent
setProxy
in interface SIPAgent
CATException
public void setStepMode(boolean b) throws java.lang.Exception
SIPAgent
SIPAgent caller = createAgent("caller");
SIPAgent callee = createAgent("callee");
CommandId inv = caller.call(callee);
processSIP(1000);
assertThat(callee, invited());
callee.answer();
processSIP(1000);
assertThat(callee, connectedTo(caller));
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//send a error response to the BYE.
caller.sendResponse(500);
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 500));
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//resume default execution. this causes callee to
//send a default 200 OK response to the BYE.
callee.setStepMode(false);
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 200));
setStepMode
in interface SIPAgent
java.lang.Exception
public java.lang.String getProxy()
SIPAgent
getProxy
in interface SIPAgent
public java.lang.String getSipURIAsString() throws CATException
SIPAgent
call
, answer
.
getSipURIAsString
in interface SIPAgent
CATException
- If an exception occuredpublic SipURI getSipURI() throws CATException
SIPAgent
call
, answer
.
getSipURI
in interface SIPAgent
CATException
- If an exception occuredpublic CommandId execUserCommand(UserCommand command) throws CATException
SIPAgent
execUserCommand
in interface SIPAgent
CATException
public CommandId sendDTMF(java.lang.String keys) throws CATException
SIPAgent
sendDTMF
in interface SIPAgent
CATException
public CommandId register(java.lang.String domain, java.lang.String user, java.lang.String passwd) throws CATException
SIPAgent
sip:domain
, From header contains
sip:agentName@domain
, To header contains
sip:agentName@domain
. The userid and passwd
parameters are used only for MD5 digest authentication after
the agent receives a challenge response. If no authentication
is needed, these fields can be empty. The registration expiry
time is internally set to 3600. The expiry time is sent in the
REGISTER message using an Expiry header although this may be
subject to change in the future.
register
in interface SIPAgent
domain
- domain for registrationuser
- userid for registrationpasswd
- password for registration
CATException
public CommandId register(java.lang.String domain, java.lang.String user, java.lang.String passwd, int expires) throws CATException
SIPAgent
sip:domain
, From header contains
sip:agentName@domain
, To header contains
sip:agentName@domain
. The userid and passwd
parameters are used only for MD5 digest authentication after
the agent receives a challenge response. If no authentication
is needed, these fields can be empty. The specified expiry
time is sent in the REGISTER message using an Expiry header
although this may be subject to change in the future.
register
in interface SIPAgent
domain
- domain for registrationuser
- userid for registrationpasswd
- password for registrationexpires
- registration expiry
CATException
public void pushRoute(java.lang.String route) throws CATException
SIPAgent
agent1.pushRoute("sip:R1.abc.com;lr");
agent1.pushRoute("sip:R2.xyz.com;lr");
agent1.pushSelfRoute();
The above example will result in the following route headers in
the initial INVITE message
Route: <sip:thisagent@this.host;lr>,
<sip:R2.xyz.com;lr>,
<sip:R1.abc.com;lr>
Note that using the setProxy
method adds another
route header to the specified proxy at the very top. In the
above example, the addition of the following statement
agent.setProxy("proxy.lmn.com");
results in the addition of a route header to the proxy as the
very first route header irrespective of the relative ordering
of the setProxy
and the pushRoute
calls. The resulting route headers will be as follows:
Route: <sip:proxy.lmn.com;lr>,
<sip:thisagent@this.host;lr>,
<sip:R2.xyz.com;lr>,
<sip:R1.abc.com;lr>
pushRoute
in interface SIPAgent
CATException
public void pushSelfRoute() throws CATException
SIPAgent
pushSelfRoute
in interface SIPAgent
CATException
public CommandId call(java.lang.String sipuri) throws CATException
SIPAgent
calleeUri
call
in interface SIPAgent
CATException
public CommandId call(java.lang.String sipuri, java.lang.String fromUri) throws CATException
SIPAgent
calleeUri
and From header containing
the value specified in fromUri
.
call
in interface SIPAgent
CATException
public CommandId call(java.lang.String ruri, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap) throws CATException
SIPAgent
sipuri
and with the additional
headers specified
call
in interface SIPAgent
CATException
public CommandId call(java.lang.String ruri, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap, java.lang.String fromUri) throws CATException
CATException
public CommandId call(SIPAgent callee, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap, java.lang.String fromUri) throws CATException
CATException
public CommandId call(SIPAgent callee, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap) throws CATException
SIPAgent
callee
and with the
additional headers specified
call
in interface SIPAgent
CATException
public CommandId call(SIPAgent callee) throws CATException
SIPAgent
callee
call
in interface SIPAgent
CATException
public CommandId call(SIPAgent callee, java.lang.String fromUri) throws CATException
SIPAgent
callee
and From header
containing the value specified in fromUri
.
call
in interface SIPAgent
CATException
public CommandId sendResponse(int responseCode) throws CATException
SIPAgent
sendResponse
in interface SIPAgent
CATException
public CommandId sendResponse(int responseCode, java.util.LinkedHashMap<java.lang.String,java.util.List<java.lang.String>> headerMap) throws CATException
CATException
public CommandId cancel() throws CATException
SIPAgent
cancel
in interface SIPAgent
CATException
public CommandId callNoSdp(java.lang.String sipuri) throws CATException
SIPAgent
call
method where no SDP is sent
callNoSdp
in interface SIPAgent
CATException
public CommandId callNoSdp(java.lang.String sipuri, java.lang.String fromuri) throws CATException
SIPAgent
call
method where no SDP is sent
callNoSdp
in interface SIPAgent
CATException
public CommandId callNoSdp(SIPAgent callee) throws CATException
SIPAgent
call
method where no SDP is sent
callNoSdp
in interface SIPAgent
CATException
public CommandId callNoSdp(SIPAgent callee, java.lang.String fromUri) throws CATException
SIPAgent
call
method where no SDP is sent
callNoSdp
in interface SIPAgent
CATException
public CommandId answer() throws CATException
SIPAgent
answer
in interface SIPAgent
CATException
public CommandId redirect(int redirectCode, java.lang.String addr) throws CATException
SIPAgent
redirect
in interface SIPAgent
CATException
public CommandId redirect(int redirectCode, SipURI sipuri) throws CATException
SIPAgent
redirect
in interface SIPAgent
CATException
public CommandId redirect(int redirectCode, Address address) throws CATException
SIPAgent
redirect
in interface SIPAgent
CATException
public CommandId end() throws CATException
SIPAgent
end
in interface SIPAgent
CATException
public CommandId shutdown() throws CATException
CATException
public void step() throws java.lang.Exception
SIPAgent
SIPAgent.setStepMode(boolean)
(true)). Invoking
this method causes an agent to proceed with default execution
until the next "breakpoint".
......caller connected to callee at this point.......
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//perform default execution which sends a 200
//OK response to BYE
caller.step();
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 200));
//resume default execution for callee
callee.setStepMode(false);
step
in interface SIPAgent
java.lang.Exception
public CommandId info(java.lang.String contentType, java.lang.String contentSubType, java.lang.String content) throws CATException
SIPAgent
info
in interface SIPAgent
CATException
public CommandId subscribe(java.lang.String eventType, java.lang.String acceptContentType, java.lang.String acceptContentSubType, java.lang.String msgContentType, java.lang.String msgContentSubType, java.lang.String msgContent, int expires) throws CATException
CATException
public CommandId reinvite() throws CATException
SIPAgent
reinvite
in interface SIPAgent
CATException
public CommandId reinvite(SDPModifier sdpModifier) throws CATException
SIPAgent
reinvite
in interface SIPAgent
CATException
public CommandId reinviteHold() throws CATException
SIPAgent
reinviteHold
in interface SIPAgent
CATException
public CommandId reinviteResume() throws CATException
SIPAgent
reinviteResume
in interface SIPAgent
CATException
public CommandId reinviteNoSdp() throws CATException
SIPAgent
reinviteNoSdp
in interface SIPAgent
CATException
public BaseState getCurrentState()
SIPAgent
getCurrentState
in interface SIPAgent
public boolean isMediaBufferEmpty()
public void clearMediaBuffer()
SIPAgent
//assume agent1 and agent2 are in a call
agent1.clearMediaBuffer();
agent2.playAudio("hello.raw");
processSIP(3000);
assertThat(agent1, has (incomingMedia()));
agent1
first and send audio packets to
agent1
. Then we assert whether any RTP packets
were received by agent1
.
Irrespective of calls to this primitive, all the RTP packets
received by an agent over its lifetime are stored in an
agent-specific disk file.
clearMediaBuffer
in interface SIPAgent
public void playAudio(java.lang.String fileName) throws CATException
SIPAgent
playAudio
in interface SIPAgent
CATException
public void playAudio(java.io.InputStream is) throws CATException
SIPAgent
playAudio
in interface SIPAgent
CATException
public void close() throws CATException
CATException
public void recycle() throws CATException
SIPAgent
recycle
in interface SIPAgent
CATException
public java.lang.String getLastRecvdSDPAsString()
SIPAgent
getLastRecvdSDPAsString
in interface SIPAgent
public long getLastRecvdSDPTimeStamp()
public void markSDP()
SIPAgent
CATMatchers.recvdNewSDP()
.
markSDP
in interface SIPAgent
public java.lang.String getMarkedSDPAsString()
public long getMarkedSDPTimeStamp()
public java.lang.String getRTPIP()
SIPAgent
getRTPIP
in interface SIPAgent
public int getRTPPort()
SIPAgent
getRTPPort
in interface SIPAgent
public void beforeSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context) throws java.lang.Exception
beforeSIPMessageProcessed
in interface org.echarts.jain.sip.Interceptor
java.lang.Exception
public void afterSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context) throws java.lang.Exception
afterSIPMessageProcessed
in interface org.echarts.jain.sip.Interceptor
java.lang.Exception
public void beforeSIPMessageSent(org.echarts.jain.sip.InterceptorContext context) throws java.lang.Exception
beforeSIPMessageSent
in interface org.echarts.jain.sip.Interceptor
java.lang.Exception
public void afterSIPMessageSent(org.echarts.jain.sip.InterceptorContext context) throws java.lang.Exception
afterSIPMessageSent
in interface org.echarts.jain.sip.Interceptor
java.lang.Exception
public void msgRecvd(BaseState state, Message msg)
public void msgSent(BaseState state, Message msg)
public void printMessageHistory()
SIPAgent
printMessageHistory
in interface SIPAgent
public java.util.List<MessageExchangeRecord> getMessageHistory()
public java.lang.String getMessageHistoryAsString()
public void addMessageModifier(MessageModifier modifier) throws CATException
SIPAgent
HeaderAddHelper
) of this
method is to add user-defined headers to ALL messages that are
sent out by an agent to which this modifier is added. For each
message that is sent out, this modifier gets invoked and this
modifier adds the specified headers to the message. To specify
additional headers only during call establishment, use the
call
method with
header map argument.
addMessageModifier
in interface SIPAgent
CATException
public void removeMessageModifier(MessageModifier modifier) throws CATException
SIPAgent
removeMessageModifier
in interface SIPAgent
CATException
public void removeAllMessageModifiers() throws CATException
SIPAgent
removeAllMessageModifiers
in interface SIPAgent
CATException
public java.lang.String getMessageHistorySummary()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRTPCaptureFileName()
SIPAgent
getRTPCaptureFileName
in interface SIPAgent
public java.util.List<Response> getResponses(CommandId cmdId, int respCode)
SIPAgent
cmdId
and with response code respCode
.
getResponses
in interface SIPAgent
public void enableAutoAnswer()
SIPAgent
enableAutoAnswer
in interface SIPAgent
public java.lang.String getDTMFReceived()
SIPAgent
getDTMFReceived
in interface SIPAgent
public int waitForRtpAbsence(int silenceDuration, int maxWait) throws CATException
SIPAgent
Wait for absence of incoming RTP
packets for a minimum duration specified by
silenceDuration
. On reaching the
maxWait
duration, returns -1, else returns 0.
waitForRtpAbsence
in interface SIPAgent
CATException
public int waitForRtpPresence(int maxWait) throws CATException
SIPAgent
Wait for presence of incoming RTP
packets. On reaching the maxWait
duration, returns
-1, else returns 0.
waitForRtpPresence
in interface SIPAgent
CATException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |