org.echarts.test.sip
Class SIPAgentImpl

java.lang.Object
  extended by org.echarts.test.sip.SIPAgentImpl
All Implemented Interfaces:
org.echarts.jain.sip.Interceptor, SIPAgent

public class SIPAgentImpl
extends java.lang.Object
implements SIPAgent, org.echarts.jain.sip.Interceptor

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

getName

public java.lang.String getName()
Description copied from interface: SIPAgent
Get the name of the agent

Specified by:
getName in interface SIPAgent
Returns:
name of this agent

getDisplayName

public java.lang.String getDisplayName()

setProxy

public void setProxy(java.lang.String proxy)
              throws CATException
Description copied from interface: SIPAgent
Sets the proxy for this agent. Once a proxy is set, the agent sends all SIP messages to the specified proxy server. This proxy server can be a SIP application server also. Currently we insert a Route header in the outgoing message. If the parameter is not prefixed with a "sip:", internally we prefix it with a "sip:". Moreover, we append a ";lr" parameter to the proxy address.

Specified by:
setProxy in interface SIPAgent
Throws:
CATException

setStepMode

public void setStepMode(boolean b)
                 throws java.lang.Exception
Description copied from interface: SIPAgent
Turns on/off user agent step execution mode. By default, the step execution mode is turned off and the following tasks are performed implicitly by an agent machine:
  1. UAS sends 200 OK response to an incoming BYE
  2. UAC sends ACK response to an incoming 2xx response to an INVITE
  3. UAS sends 200 OK response to an incoming re-INVITE and the UAC subsequently sends an ACK
  4. UAS sends 200 OK response to an incoming INFO
  5. UAC sends a new INVITE after getting a redirect response

When the step execution mode is turned on, the agent machine requires explicit instructions from the test case to perform the above tasks. When this mode is turned on, the agent machine execution is similar to that of execution within a debugger with breakpoints set. In this case, a "breakpoint" is an execution state in the agent's execution, where the agent usually does one of the above tasks by default. For example, under the step execution mode, when a BYE is received a 200 OK is NOT sent automatically. Instead, the execution has reached a "breakpoint" and the agent waits for an explicit instruction from the test case to proceed further. Once this explicit instruction is received from the test case, the agent proceeds with execution (a "step") until it hits the next "breakpoint". Turning this mode off amounts to clearing all the "breakpoints" and continue default execution. In this test below, we want to test a scenario where a callee sends an error response to a BYE from the caller. In the default execution mode, a 200 OK is automatically sent in response to a BYE. To change this default behavior, we make use of the step execution mode and then send a 500 error response to a BYE instead.

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));


The test below illustrates how setStepMode(false) causes the default execution to resume.


//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));

Specified by:
setStepMode in interface SIPAgent
Throws:
java.lang.Exception

getProxy

public java.lang.String getProxy()
Description copied from interface: SIPAgent
Get the SIP address of the proxy server this agent points to. Returns null if no proxy is set.

Specified by:
getProxy in interface SIPAgent
Returns:
SIP URI of the proxy server.

getSipURIAsString

public java.lang.String getSipURIAsString()
                                   throws CATException
Description copied from interface: SIPAgent
Get the SIP URI of this agent as a string so that it can be used in methods like call, answer.

Specified by:
getSipURIAsString in interface SIPAgent
Returns:
the SIP URI as string
Throws:
CATException - If an exception occured

getSipURI

public SipURI getSipURI()
                 throws CATException
Description copied from interface: SIPAgent
Get the SIP URI of this agent as a SipURI so that it can be used in methods like call, answer.

Specified by:
getSipURI in interface SIPAgent
Returns:
the SIP URI
Throws:
CATException - If an exception occured

execUserCommand

public CommandId execUserCommand(UserCommand command)
                          throws CATException
Description copied from interface: SIPAgent
Execute user command. This method is a generic method for executing user-specified commands. Most of the frequently used commands are supported by specific primitives - e.g call, answer, cancel. This method is useful in the context of a user-specified agent machine which executes user-specified commands. Implementation of primitives like call, answer etc. internally uses this method to pass on the command to the agent state machine. The command object in the argument to this method is directly passed to the agent machine. Unless the machine is designed to handle this command, it will throw an exception

Specified by:
execUserCommand in interface SIPAgent
Throws:
CATException

sendDTMF

public CommandId sendDTMF(java.lang.String keys)
                   throws CATException
Description copied from interface: SIPAgent
Sends DTMF keys to the remote SIP agent with which this agent has already established a SIP dialog and started an RTP session. Note that this primitive is not a blocking primitive. The RTP packets are sent in a background thread and the calling thread returns after enqueueing the RTP packets for sending.

Specified by:
sendDTMF in interface SIPAgent
Throws:
CATException

register

public CommandId register(java.lang.String domain,
                          java.lang.String user,
                          java.lang.String passwd)
                   throws CATException
Description copied from interface: SIPAgent
Sends a REGISTER message. The request URI in the REGISTER message contains 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.

Specified by:
register in interface SIPAgent
Parameters:
domain - domain for registration
user - userid for registration
passwd - password for registration
Throws:
CATException

register

public CommandId register(java.lang.String domain,
                          java.lang.String user,
                          java.lang.String passwd,
                          int expires)
                   throws CATException
Description copied from interface: SIPAgent
Sends a REGISTER message. The request URI in the REGISTER message contains 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.

Specified by:
register in interface SIPAgent
Parameters:
domain - domain for registration
user - userid for registration
passwd - password for registration
expires - registration expiry
Throws:
CATException

pushRoute

public void pushRoute(java.lang.String route)
               throws CATException
Description copied from interface: SIPAgent
Specify route header(s) that needs to be included as part of an initial INVITE message that may be sent later.

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>

Specified by:
pushRoute in interface SIPAgent
Throws:
CATException

pushSelfRoute

public void pushSelfRoute()
                   throws CATException
Description copied from interface: SIPAgent
Specify a self route header that needs to be sent as part of an initial INVITE message that may be sent later.

Specified by:
pushSelfRoute in interface SIPAgent
Throws:
CATException

call

public CommandId call(java.lang.String sipuri)
               throws CATException
Description copied from interface: SIPAgent
Sends an INVITE with the request URI containing the value specified in calleeUri

Specified by:
call in interface SIPAgent
Throws:
CATException

call

public CommandId call(java.lang.String sipuri,
                      java.lang.String fromUri)
               throws CATException
Description copied from interface: SIPAgent
Sends an INVITE with the request URI containing the value specified in calleeUri and From header containing the value specified in fromUri.

Specified by:
call in interface SIPAgent
Throws:
CATException

call

public CommandId call(java.lang.String ruri,
                      java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
               throws CATException
Description copied from interface: SIPAgent
Sends an INVITE with the request URI containing the value specified in sipuri and with the additional headers specified

Specified by:
call in interface SIPAgent
Throws:
CATException

call

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
Throws:
CATException

call

public CommandId call(SIPAgent callee,
                      java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap,
                      java.lang.String fromUri)
               throws CATException
Throws:
CATException

call

public CommandId call(SIPAgent callee,
                      java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
               throws CATException
Description copied from interface: SIPAgent
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee and with the additional headers specified

Specified by:
call in interface SIPAgent
Throws:
CATException

call

public CommandId call(SIPAgent callee)
               throws CATException
Description copied from interface: SIPAgent
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee

Specified by:
call in interface SIPAgent
Throws:
CATException

call

public CommandId call(SIPAgent callee,
                      java.lang.String fromUri)
               throws CATException
Description copied from interface: SIPAgent
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.

Specified by:
call in interface SIPAgent
Throws:
CATException

sendResponse

public CommandId sendResponse(int responseCode)
                       throws CATException
Description copied from interface: SIPAgent
Send a response to the peer end point with the response code specified as parameter

Specified by:
sendResponse in interface SIPAgent
Throws:
CATException

sendResponse

public CommandId sendResponse(int responseCode,
                              java.util.LinkedHashMap<java.lang.String,java.util.List<java.lang.String>> headerMap)
                       throws CATException
Throws:
CATException

cancel

public CommandId cancel()
                 throws CATException
Description copied from interface: SIPAgent
Send a CANCEL to the peer endpoint

Specified by:
cancel in interface SIPAgent
Throws:
CATException

callNoSdp

public CommandId callNoSdp(java.lang.String sipuri)
                    throws CATException
Description copied from interface: SIPAgent
Variant of call method where no SDP is sent

Specified by:
callNoSdp in interface SIPAgent
Throws:
CATException

callNoSdp

public CommandId callNoSdp(java.lang.String sipuri,
                           java.lang.String fromuri)
                    throws CATException
Description copied from interface: SIPAgent
Variant of call method where no SDP is sent

Specified by:
callNoSdp in interface SIPAgent
Throws:
CATException

callNoSdp

public CommandId callNoSdp(SIPAgent callee)
                    throws CATException
Description copied from interface: SIPAgent
Variant of call method where no SDP is sent

Specified by:
callNoSdp in interface SIPAgent
Throws:
CATException

callNoSdp

public CommandId callNoSdp(SIPAgent callee,
                           java.lang.String fromUri)
                    throws CATException
Description copied from interface: SIPAgent
Variant of call method where no SDP is sent

Specified by:
callNoSdp in interface SIPAgent
Throws:
CATException

answer

public CommandId answer()
                 throws CATException
Description copied from interface: SIPAgent
Send a 200 OK response to the peer endpoint

Specified by:
answer in interface SIPAgent
Throws:
CATException

redirect

public CommandId redirect(int redirectCode,
                          java.lang.String addr)
                   throws CATException
Description copied from interface: SIPAgent
Send a 302 redirect response to the peer endpoint with the specified contact address in the response

Specified by:
redirect in interface SIPAgent
Throws:
CATException

redirect

public CommandId redirect(int redirectCode,
                          SipURI sipuri)
                   throws CATException
Description copied from interface: SIPAgent
Send a 302 redirect response to the peer endpoint with the specified contact URI in the response

Specified by:
redirect in interface SIPAgent
Throws:
CATException

redirect

public CommandId redirect(int redirectCode,
                          Address address)
                   throws CATException
Description copied from interface: SIPAgent
Send a 302 redirect response to the peer endpoint with the specified contact address in the response

Specified by:
redirect in interface SIPAgent
Throws:
CATException

end

public CommandId end()
              throws CATException
Description copied from interface: SIPAgent
Send a BYE to the peer endpoint

Specified by:
end in interface SIPAgent
Throws:
CATException

shutdown

public CommandId shutdown()
                   throws CATException
Throws:
CATException

step

public void step()
          throws java.lang.Exception
Description copied from interface: SIPAgent
Takes default action for the most recently received message. If there is no default action to be performed, then this amounts to a no-op. This method should be used only in the context of a step execution mode (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);

Specified by:
step in interface SIPAgent
Throws:
java.lang.Exception

info

public CommandId info(java.lang.String contentType,
                      java.lang.String contentSubType,
                      java.lang.String content)
               throws CATException
Description copied from interface: SIPAgent
Send a INFO message to the peer endpoint with the specified content type, content subtype and content.

Specified by:
info in interface SIPAgent
Throws:
CATException

subscribe

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
Throws:
CATException

reinvite

public CommandId reinvite()
                   throws CATException
Description copied from interface: SIPAgent
Send a re-INVITE to the peer endpoint with no change in SDPs. This call is permitted only when this agent is already in a SIP dialog, otherwise it will throw an exception.

Specified by:
reinvite in interface SIPAgent
Throws:
CATException

reinvite

public CommandId reinvite(SDPModifier sdpModifier)
                   throws CATException
Description copied from interface: SIPAgent
Send a re-INVITE to the peer endpoint with changes in SDP, the changes specified using the SDPModifier. This call is permitted only when this agent is already in a SIP dialog, otherwise it will throw an exception.

Specified by:
reinvite in interface SIPAgent
Throws:
CATException

reinviteHold

public CommandId reinviteHold()
                       throws CATException
Description copied from interface: SIPAgent
Send a re-INVITE to the peer endpoint with a hold SDP (a=sendonly media attribute).

Specified by:
reinviteHold in interface SIPAgent
Throws:
CATException

reinviteResume

public CommandId reinviteResume()
                         throws CATException
Description copied from interface: SIPAgent
Send a re-INVITE to the peer endpoint with a normal SDP (a=sendrecv media attribute).

Specified by:
reinviteResume in interface SIPAgent
Throws:
CATException

reinviteNoSdp

public CommandId reinviteNoSdp()
                        throws CATException
Description copied from interface: SIPAgent
Send a re-INVITE with no SDP to solicit an offer from the peer endpoint. This call is permitted only when this agent is already in a SIP dialog, otherwise it will throw an exception.

Specified by:
reinviteNoSdp in interface SIPAgent
Throws:
CATException

getCurrentState

public BaseState getCurrentState()
Description copied from interface: SIPAgent
Get the current state of the agent state machine

Specified by:
getCurrentState in interface SIPAgent

isMediaBufferEmpty

public boolean isMediaBufferEmpty()

clearMediaBuffer

public void clearMediaBuffer()
Description copied from interface: SIPAgent
This primitive clears the internal data structures within a agent used to keep track of the received RTP packets. This is especially useful in re-INVITE scenarios where we want to check media connectivity after the re-INVITE. Typically this is used as follows:

//assume agent1 and agent2 are in a call
agent1.clearMediaBuffer();
agent2.playAudio("hello.raw");
processSIP(3000);
assertThat(agent1, has (incomingMedia()));

In the above example, we clear the media buffer in 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.

Specified by:
clearMediaBuffer in interface SIPAgent

playAudio

public void playAudio(java.lang.String fileName)
               throws CATException
Description copied from interface: SIPAgent
Play raw audio from the file name specified. Note that this primitive is not a blocking primitive. The RTP packets are sent in a background thread and the calling thread returns after enqueueing the RTP packets for sending.

Specified by:
playAudio in interface SIPAgent
Throws:
CATException

playAudio

public void playAudio(java.io.InputStream is)
               throws CATException
Description copied from interface: SIPAgent
Play raw audio from the specified input stream.

Specified by:
playAudio in interface SIPAgent
Throws:
CATException

close

public void close()
           throws CATException
Throws:
CATException

recycle

public void recycle()
             throws CATException
Description copied from interface: SIPAgent
Resets the agent and makes it ready for use again even after an end

Specified by:
recycle in interface SIPAgent
Throws:
CATException

getLastRecvdSDPAsString

public java.lang.String getLastRecvdSDPAsString()
Description copied from interface: SIPAgent
Get the last received SDP in string format

Specified by:
getLastRecvdSDPAsString in interface SIPAgent

getLastRecvdSDPTimeStamp

public long getLastRecvdSDPTimeStamp()

markSDP

public void markSDP()
Description copied from interface: SIPAgent
Saves the latest SDP received from the peer agent as a result of session negotiation. This will be used later in matchers like CATMatchers.recvdNewSDP().

Specified by:
markSDP in interface SIPAgent

getMarkedSDPAsString

public java.lang.String getMarkedSDPAsString()

getMarkedSDPTimeStamp

public long getMarkedSDPTimeStamp()

getRTPIP

public java.lang.String getRTPIP()
Description copied from interface: SIPAgent
Gets the IP address being used for listening in RTP sessions

Specified by:
getRTPIP in interface SIPAgent

getRTPPort

public int getRTPPort()
Description copied from interface: SIPAgent
Gets port number being used for listening in RTP sessions

Specified by:
getRTPPort in interface SIPAgent

beforeSIPMessageProcessed

public void beforeSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context)
                               throws java.lang.Exception
Specified by:
beforeSIPMessageProcessed in interface org.echarts.jain.sip.Interceptor
Throws:
java.lang.Exception

afterSIPMessageProcessed

public void afterSIPMessageProcessed(org.echarts.jain.sip.InterceptorContext context)
                              throws java.lang.Exception
Specified by:
afterSIPMessageProcessed in interface org.echarts.jain.sip.Interceptor
Throws:
java.lang.Exception

beforeSIPMessageSent

public void beforeSIPMessageSent(org.echarts.jain.sip.InterceptorContext context)
                          throws java.lang.Exception
Specified by:
beforeSIPMessageSent in interface org.echarts.jain.sip.Interceptor
Throws:
java.lang.Exception

afterSIPMessageSent

public void afterSIPMessageSent(org.echarts.jain.sip.InterceptorContext context)
                         throws java.lang.Exception
Specified by:
afterSIPMessageSent in interface org.echarts.jain.sip.Interceptor
Throws:
java.lang.Exception

msgRecvd

public void msgRecvd(BaseState state,
                     Message msg)

msgSent

public void msgSent(BaseState state,
                    Message msg)

printMessageHistory

public void printMessageHistory()
Description copied from interface: SIPAgent
Print the history of SIP messages received/sent by this agent

Specified by:
printMessageHistory in interface SIPAgent

getMessageHistory

public java.util.List<MessageExchangeRecord> getMessageHistory()

getMessageHistoryAsString

public java.lang.String getMessageHistoryAsString()

addMessageModifier

public void addMessageModifier(MessageModifier modifier)
                        throws CATException
Description copied from interface: SIPAgent
Adds a message modifier. You could chain message modifiers together. The invocation order will be the same as the order in which the modifiers were added. One possible use (e.g. 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.

Specified by:
addMessageModifier in interface SIPAgent
Throws:
CATException

removeMessageModifier

public void removeMessageModifier(MessageModifier modifier)
                           throws CATException
Description copied from interface: SIPAgent
Removes a previously added message modifier.

Specified by:
removeMessageModifier in interface SIPAgent
Throws:
CATException

removeAllMessageModifiers

public void removeAllMessageModifiers()
                               throws CATException
Description copied from interface: SIPAgent
Removes all previously added message modifiers.

Specified by:
removeAllMessageModifiers in interface SIPAgent
Throws:
CATException

getMessageHistorySummary

public java.lang.String getMessageHistorySummary()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRTPCaptureFileName

public java.lang.String getRTPCaptureFileName()
Description copied from interface: SIPAgent
Returns the name of the file in which the RTP packets are captured.

Specified by:
getRTPCaptureFileName in interface SIPAgent

getResponses

public java.util.List<Response> getResponses(CommandId cmdId,
                                             int respCode)
Description copied from interface: SIPAgent
Returns the list of responses for the request indicated by cmdId and with response code respCode .

Specified by:
getResponses in interface SIPAgent

enableAutoAnswer

public void enableAutoAnswer()
Description copied from interface: SIPAgent
Sends a 200 OK response to an incoming INVITE without any explicit answer() command from the test case.

Specified by:
enableAutoAnswer in interface SIPAgent

getDTMFReceived

public java.lang.String getDTMFReceived()
Description copied from interface: SIPAgent
Gets the DTMF digits that were received earlier as part of the RTP stream and then stored in a buffer. This method also clears the buffer. This method is useful while testing IVR systems that send DTMF as part of the audio stream to the test system (from the SUT to the test case) and the test case needs to find out what DTMF sequence the SUT sent.

Specified by:
getDTMFReceived in interface SIPAgent

waitForRtpAbsence

public int waitForRtpAbsence(int silenceDuration,
                             int maxWait)
                      throws CATException
Description copied from interface: SIPAgent
EXPERIMENTAL. SUBJECT TO CHANGE. USE AT YOUR OWN RISK.

Wait for absence of incoming RTP packets for a minimum duration specified by silenceDuration. On reaching the maxWait duration, returns -1, else returns 0.

Specified by:
waitForRtpAbsence in interface SIPAgent
Throws:
CATException

waitForRtpPresence

public int waitForRtpPresence(int maxWait)
                       throws CATException
Description copied from interface: SIPAgent
EXPERIMENTAL. SUBJECT TO CHANGE. USE AT YOUR OWN RISK.

Wait for presence of incoming RTP packets. On reaching the maxWait duration, returns -1, else returns 0.

Specified by:
waitForRtpPresence in interface SIPAgent
Throws:
CATException