Skip to content

pjsip: Add tests for Advanced Codec Negotiation (ACN) #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ timer_b=6400

[global]
all_codecs_on_empty_reinvite=yes
debug=yes

[local-transport-udp]
type=transport
Expand All @@ -16,3 +17,4 @@ type=endpoint
context=default
media_address=127.0.0.1
allow=!all,g722,alaw,ulaw,ilbc,opus
codec_prefs_incoming_offer = prefer: configured, operation: intersect, keep: all, transcode: allow
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ timer_b=6400

[global]
all_codecs_on_empty_reinvite=yes
debug=yes

[local-transport-udp]
type=transport
Expand All @@ -16,3 +17,4 @@ type=endpoint
context=default
media_address=127.0.0.1
allow=!all,g722,alaw,ulaw,ilbc,opus
codec_prefs_incoming_offer = prefer: configured, operation: intersect, keep: all, transcode: allow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[general]

[globals]

[calling]
exten => bob,1,NoOp()
same => n,Dial(PJSIP/bob)
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[system]
type=system
timer_t1=100
timer_b=6400

[global]
type=global
debug=yes

[local-transport]
type=transport
bind=127.0.0.1
protocol=udp



[endpoint-template](!)

[alice](endpoint-template)
type=endpoint
allow=opus,g722,ulaw,alaw,h264
context=calling
direct_media=no
media_address=127.0.0.1
aors=alice

[bob](endpoint-template)
type=endpoint
allow=opus,g722,ulaw,alaw,h264
context=calling
direct_media=no
media_address=127.0.0.1
aors=bob

[bob]
type=aor
max_contacts=1
contact=sip:[email protected]:5060\;transport=udp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>

<scenario name="Send Call">

<send retrans="500">
<![CDATA[

INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
To: <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: [cseq] INVITE
Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: [len]

v=0
o=- 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [custom_media_port] RTP/AVP 107 9 8 0
a=rtpmap:107 opus/48000/2
a=fmtp:107 maxaveragebitrate=64000;sprop-stereo=1
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=ptime:20
a=maxptime:20
a=sendrecv
a=rtcp-mux
]]>
</send>

<recv response="100" optional="true" />
<recv response="180" />

<recv response="200" rtd="true">
<!-- Save the To tag. -->
<action>
<ereg regexp="(;tag=.*)"
header="To:"
search_in="hdr"
check_it="true"
assign_to="remote_tag"/>
<ereg regexp="m=audio [0-9]{1,5} RTP/AVP 9 8 0"
search_in="body" check_it="true" assign_to="1"/>
<test assign_to="1" variable="1" compare="equal" value=""/>
<ereg regexp="G722"
search_in="body" check_it_inverse="false" assign_to="2"/>
<test assign_to="2" variable="2" compare="equal" value=""/>
<ereg regexp="PCMA"
search_in="body" check_it_inverse="false" assign_to="3"/>
<test assign_to="3" variable="3" compare="equal" value=""/>
<ereg regexp="OPUS"
search_in="body" check_it_inverse="true" assign_to="4"/>
<test assign_to="4" variable="4" compare="equal" value=""/>
</action>
</recv>

<send>
<![CDATA[

ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
[last_Via:]
[last_From:]
[last_To:]
Call-ID: [call_id]
CSeq: [cseq] ACK
Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
Max-Forwards: 70
Content-Length: 0

]]>
</send>

<pause milliseconds="1000" />

<send retrans="500">
<![CDATA[

BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
[last_Via:]4
From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
To: <sip:[service]@[remote_ip]:[remote_port]>[$remote_tag]
Call-ID: [call_id]
CSeq: [cseq] BYE
Contact: sip:alice@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Codec Negotiation Test
Content-Length: 0

]]>
</send>

<recv response="200" crlf="true">
</recv>

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="Basic UAS responder">

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

<send>
<![CDATA[

SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
Content-Length: 0

]]>
</send>

<pause milliseconds="100" />

<send retrans="500">
<![CDATA[

SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
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 [custom_media_port] RTP/AVP 9 8 0
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=ptime:20
a=maxptime:20
a=sendrecv
]]>
</send>

<recv request="ACK"
rtd="true"
crlf="true">
</recv>

<recv request="BYE" />

<send>
<![CDATA[

SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0

]]>
</send>

<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>

<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>

</scenario>

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
testinfo:
summary:
'Test advanced codec negotiation in a call between two parties
with 3 common codecs '
description: |
'Two PJSIP endpoints are configured to support many codecs.
Alice client is configured with Opus as additional codec.
All endpoints share the same codec settings in pjsip.conf
Alice calls Bob and in Bob\'s SDP answer he provides 3 codecs that Alice except Opus.
The common codecs are g722,pcma,pcmu.
Asterisk should not transcode in this case as the parties share at least one common codec.'
properties:
dependencies:
- python: 'twisted'
- python: 'starpy'
- asterisk: 'app_dial'
- asterisk: 'res_pjsip'
- sipp:
version: 'v3.6.0'
tags:
- pjsip

test-modules:
add-test-to-search-path: 'True'
test-object:
config-section: test-case-config
typename: 'sipp.SIPpTestCase'

test-case-config:
memcheck-delay-stop: 7
# connect-ami: 'False'
fail-on-any: false
test-iterations:
# First iteration
-
scenarios:
# Bob receives call from Alice
- {'key-args':
{'scenario': 'bob.xml', '-p': '5060', '-i': '127.0.0.3',
'-s': 'alice', '-timeout': '20s', '-mi': '127.0.0.3'
},
'ordered-args':
['-timeout_error', '-key', 'custom_media_port', '6004']}
# Alice calls Bob
- {'key-args':
{'scenario': 'alice.xml', '-p': '5060',
'-i': '127.0.0.2', '-s': 'bob', '-timeout': '20s',
'-mi': '127.0.0.2'},
'ordered-args':
['-timeout_error', '-key', 'custom_media_port', '6004']}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[general]

[globals]

[calling]
exten => bob,1,NoOp()
same => n,Dial(PJSIP/bob)
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[system]
type=system
timer_t1=100
timer_b=6400

[global]
type=global
debug=yes

[local-transport]
type=transport
bind=127.0.0.1
protocol=udp



[endpoint-template](!)
codec_prefs_outgoing_answer = prefer: pending, operation: union, keep: all, transcode: allow

[alice](endpoint-template)
type=endpoint
allow=opus,g722,ulaw,alaw,h264
context=calling
direct_media=no
media_address=127.0.0.1
aors=alice

[bob](endpoint-template)
type=endpoint
allow=opus,g722,ulaw,alaw,h264
context=calling
direct_media=no
media_address=127.0.0.1
aors=bob

[bob]
type=aor
max_contacts=1
contact=sip:[email protected]:5060\;transport=udp
Loading