Skip to content

Commit

Permalink
Added the rtp_echo scenario action
Browse files Browse the repository at this point in the history
  • Loading branch information
pbertera committed Oct 5, 2016
1 parent 7412b02 commit b540cec
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGES.md
Expand Up @@ -31,7 +31,10 @@ Features added in 3.6.0
and must be between 50 and 2000.
- Instead of digits a `[field...]` keyword is also accepted.
- Make sure you add enough `<pause/>` after `play_dtmf`.

* Added `rtp_echo` action (pull #259 by Snom Technology). Compile with
`--with-rtpstream` and use it by adding `<rtp_echo value="0">` to stop
the RTP echo enabled via `-rtp_echo`. RTP echo can be restarted via
`<rtp_echo value="1">` action. Usage example in `regress/github-#0259/uas.xml`

Bugs fixed in 3.5.x
===================
Expand Down
1 change: 1 addition & 0 deletions include/actions.hpp
Expand Up @@ -79,6 +79,7 @@ class CAction
E_AT_RTP_STREAM_PAUSE,
E_AT_RTP_STREAM_RESUME,
E_AT_RTP_STREAM_PLAY,
E_AT_RTP_ECHO,
#endif
E_AT_NB_ACTION
};
Expand Down
3 changes: 3 additions & 0 deletions include/sipp.hpp
Expand Up @@ -300,6 +300,9 @@ extern char * auth_uri _DEFVAL(0);
extern const char * call_id_string _DEFVAL("%u-%p@%s");
extern char **generic[100];

#ifdef RTP_STREAM
extern bool rtp_echo_state _DEFVAL(true);
#endif
extern bool callidSlash _DEFVAL(false);

/* TDM map */
Expand Down
Binary file added regress/github-#0259/beep_1sec_50x160b.alaw
Binary file not shown.
20 changes: 20 additions & 0 deletions regress/github-#0259/run
@@ -0,0 +1,20 @@
#!/bin/sh
# This regression test is a part of SIPp.
# Author: Pietro Bertera, Snom Technology AG, 2016
#
# Start the UAS scenario, UAS stops the rtp_echo
# for some seconds
#
. "`dirname "$0"`/../functions"; init

if ! sippversion | grep -q RTPSTREAM; then
skip "requires RTPSTREAM"
fi

sippbg -sf uas.xml -p 5070 -rtp_echo
sippfg -m 1 -sf uac.xml 127.0.0.1:5070 \
-timeout 10 -timeout_error >/dev/null 2>&1
status=$?

test $status -ne 0 && fail "SIPp UAC job failed"
ok
80 changes: 80 additions & 0 deletions regress/github-#0259/uac.xml
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="RTP Echo pause / start test UAC">

<send retrans="500" start_txn="invite">
<![CDATA[
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: sip:[service]@[local_ip]:[local_port];tag=[pid]SIPpTag00[call_number]
To: sip:[service]@[remote_ip]:[remote_port]
Call-ID: [call_id]
CSeq: [cseq] INVITE
Contact: sip:[service]@[local_ip]:[local_port]
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv response="100" optional="true" response_txn="invite"/>

<recv response="180" optional="true" response_txn="invite"/>

<recv response="183" optional="true" response_txn="invite"/>

<recv response="200" rrs="true" response_txn="invite"/>

<send ack_txn="invite">
<![CDATA[
ACK [next_url] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
[routes]
From: sip:[service]@[local_ip]:[local_port];tag=[pid]SIPpTag00[call_number]
To: sip:[service]@[remote_ip]:[remote_port][peer_tag_param]
Call-ID: [call_id]
CSeq: [cseq] ACK
Contact: sip:[service]@[local_ip]:[local_port]
Content-Length: 0
]]>
</send>

<!-- Send the audio for 8 seconds -->
<nop>
<action>
<exec rtp_stream="beep_1sec_50x160b.alaw,8,8"/>
</action>
</nop>

<recv request="BYE"/>

<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_Record-Route:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0
]]>
</send>

<timewait milliseconds="1000"/><!-- retransmit 200's for a while -->

</scenario>
93 changes: 93 additions & 0 deletions regress/github-#0259/uas.xml
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="RTP Echo pause / start test UAS">

<recv request="INVITE" rrs="true"/>

<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_Record-Route:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: sip:[service]@[local_ip]:[local_port]
Content-Length: 0
]]>
</send>

<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_Record-Route:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: sip:[service]@[local_ip]:[local_port]
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv request="ACK" rrs="true">
<action>
<ereg regexp=": *(.*)" search_in="hdr" header="To" assign_to="_,us"/><!-- with tag -->
<ereg regexp=": *(.*)" search_in="hdr" header="From" assign_to="_,them"/>
</action>
</recv>
<Reference variables="_"/>

<pause milliseconds="2000"/>

<nop>
<action>
<rtp_echo value="0"/> <!-- stop the RTP echo -->
</action>
</nop>

<pause milliseconds="2000"/>

<nop>
<action>
<rtp_echo value="1"/> <!-- start the RTP echo -->
</action>
</nop>

<pause milliseconds="2000"/>

<send start_txn="bye" retrans="500">
<![CDATA[
BYE [next_url] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
[routes]
From: [$us]
To: [$them]
[last_Call-ID:]
CSeq: [cseq] BYE
Contact: sip:[service]@[local_ip]:[local_port]
Content-Length: 0
]]>
</send>

<recv response="200" response_txn="bye"/>

</scenario><!-- vim: set ts=8 sw=2 sts=2 et ai: -->
2 changes: 2 additions & 0 deletions src/call.cpp
Expand Up @@ -3691,6 +3691,8 @@ call::T_ActionResult call::executeAction(char * msg, message *curmsg)
#endif

#ifdef RTP_STREAM
} else if (currentAction->getActionType() == CAction::E_AT_RTP_ECHO) {
rtp_echo_state = (currentAction->getDoubleValue() != 0);
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_PAUSE) {
rtpstream_pause(&rtpstream_callinfo);
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_RESUME) {
Expand Down
7 changes: 7 additions & 0 deletions src/scenario.cpp
Expand Up @@ -1647,6 +1647,13 @@ void scenario::parseAction(CActions *actions)
} else {
ERROR("illegal <exec> in the scenario\n");
}
} else if(!strcmp(actionElem, "rtp_echo")) {
#ifdef RTP_STREAM
tmpAction->setActionType(CAction::E_AT_RTP_ECHO);
handle_rhs(tmpAction, "rtp_echo");
#else
ERROR("Scenario specifies a rtp_echo action, but this version of SIPp does not have RTP stream support");
#endif
} else {
ERROR("Unknown action: %s", actionElem);
}
Expand Down
5 changes: 5 additions & 0 deletions src/sipp.cpp
Expand Up @@ -603,6 +603,11 @@ static void rtp_echo_thread(void* param)
errno);
return;
}
#ifdef RTP_STREAM
if (!rtp_echo_state) {
continue;
}
#endif
ns = sendto(*(int*)param, msg, nr, 0,
(sockaddr*)&remote_rtp_addr, len);

Expand Down

0 comments on commit b540cec

Please sign in to comment.