Skip to content

Commit 997845c

Browse files
pjsip: Add tests for Advanced Codec Negotiation (ACN)
1 parent e930bd9 commit 997845c

File tree

256 files changed

+13533
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+13533
-0
lines changed

Diff for: tests/channels/pjsip/all_codecs_on_empty_reinvite/early-offer/configs/ast1/pjsip.conf

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ timer_b=6400
55

66
[global]
77
all_codecs_on_empty_reinvite=yes
8+
debug=yes
89

910
[local-transport-udp]
1011
type=transport
@@ -16,3 +17,4 @@ type=endpoint
1617
context=default
1718
media_address=127.0.0.1
1819
allow=!all,g722,alaw,ulaw,ilbc,opus
20+
codec_prefs_incoming_offer = prefer: configured, operation: intersect, keep: all, transcode: allow

Diff for: tests/channels/pjsip/all_codecs_on_empty_reinvite/late-offer/configs/ast1/pjsip.conf

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ timer_b=6400
55

66
[global]
77
all_codecs_on_empty_reinvite=yes
8+
debug=yes
89

910
[local-transport-udp]
1011
type=transport
@@ -16,3 +17,4 @@ type=endpoint
1617
context=default
1718
media_address=127.0.0.1
1819
allow=!all,g722,alaw,ulaw,ilbc,opus
20+
codec_prefs_incoming_offer = prefer: configured, operation: intersect, keep: all, transcode: allow
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[general]
2+
3+
[globals]
4+
5+
[calling]
6+
exten => bob,1,NoOp()
7+
same => n,Dial(PJSIP/bob)
8+
same => n,Hangup()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[system]
2+
type=system
3+
timer_t1=100
4+
timer_b=6400
5+
6+
[global]
7+
type=global
8+
debug=yes
9+
10+
[local-transport]
11+
type=transport
12+
bind=127.0.0.1
13+
protocol=udp
14+
15+
16+
17+
[endpoint-template](!)
18+
19+
[alice](endpoint-template)
20+
type=endpoint
21+
allow=opus,g722,ulaw,alaw,h264
22+
context=calling
23+
direct_media=no
24+
media_address=127.0.0.1
25+
aors=alice
26+
27+
[bob](endpoint-template)
28+
type=endpoint
29+
allow=opus,g722,ulaw,alaw,h264
30+
context=calling
31+
direct_media=no
32+
media_address=127.0.0.1
33+
aors=bob
34+
35+
[bob]
36+
type=aor
37+
max_contacts=1
38+
contact=sip:[email protected]:5060\;transport=udp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
3+
<scenario name="Send Call">
4+
5+
<send retrans="500">
6+
<![CDATA[
7+
8+
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
9+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
10+
From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
11+
To: <sip:[service]@[remote_ip]:[remote_port]>
12+
Call-ID: [call_id]
13+
CSeq: [cseq] INVITE
14+
Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
15+
Max-Forwards: 70
16+
Content-Type: application/sdp
17+
Content-Length: [len]
18+
19+
v=0
20+
o=- 53655765 2353687637 IN IP[local_ip_type] [local_ip]
21+
s=-
22+
c=IN IP[media_ip_type] [media_ip]
23+
t=0 0
24+
m=audio [custom_media_port] RTP/AVP 107 9 8 0
25+
a=rtpmap:107 opus/48000/2
26+
a=fmtp:107 maxaveragebitrate=64000;sprop-stereo=1
27+
a=rtpmap:9 G722/8000
28+
a=rtpmap:8 PCMA/8000
29+
a=rtpmap:0 PCMU/8000
30+
a=ptime:20
31+
a=maxptime:20
32+
a=sendrecv
33+
a=rtcp-mux
34+
]]>
35+
</send>
36+
37+
<recv response="100" optional="true" />
38+
<recv response="180" />
39+
40+
<recv response="200" rtd="true">
41+
<!-- Save the To tag. -->
42+
<action>
43+
<ereg regexp="(;tag=.*)"
44+
header="To:"
45+
search_in="hdr"
46+
check_it="true"
47+
assign_to="remote_tag"/>
48+
<ereg regexp="m=audio [0-9]{1,5} RTP/AVP 9 8 0"
49+
search_in="body" check_it="true" assign_to="1"/>
50+
<test assign_to="1" variable="1" compare="equal" value=""/>
51+
<ereg regexp="G722"
52+
search_in="body" check_it_inverse="false" assign_to="2"/>
53+
<test assign_to="2" variable="2" compare="equal" value=""/>
54+
<ereg regexp="PCMA"
55+
search_in="body" check_it_inverse="false" assign_to="3"/>
56+
<test assign_to="3" variable="3" compare="equal" value=""/>
57+
<ereg regexp="OPUS"
58+
search_in="body" check_it_inverse="true" assign_to="4"/>
59+
<test assign_to="4" variable="4" compare="equal" value=""/>
60+
</action>
61+
</recv>
62+
63+
<send>
64+
<![CDATA[
65+
66+
ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
67+
[last_Via:]
68+
[last_From:]
69+
[last_To:]
70+
Call-ID: [call_id]
71+
CSeq: [cseq] ACK
72+
Contact: <sip:alice@[local_ip]:[local_port];transport=[transport]>
73+
Max-Forwards: 70
74+
Content-Length: 0
75+
76+
]]>
77+
</send>
78+
79+
<pause milliseconds="1000" />
80+
81+
<send retrans="500">
82+
<![CDATA[
83+
84+
BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
85+
[last_Via:]4
86+
From: <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag[call_number]
87+
To: <sip:[service]@[remote_ip]:[remote_port]>[$remote_tag]
88+
Call-ID: [call_id]
89+
CSeq: [cseq] BYE
90+
Contact: sip:alice@[local_ip]:[local_port]
91+
Max-Forwards: 70
92+
Subject: Codec Negotiation Test
93+
Content-Length: 0
94+
95+
]]>
96+
</send>
97+
98+
<recv response="200" crlf="true">
99+
</recv>
100+
101+
</scenario>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!DOCTYPE scenario SYSTEM "sipp.dtd">
3+
4+
<scenario name="Basic UAS responder">
5+
6+
<recv request="INVITE" crlf="true" />
7+
8+
<send>
9+
<![CDATA[
10+
11+
SIP/2.0 180 Ringing
12+
[last_Via:]
13+
[last_From:]
14+
[last_To:];tag=[pid]SIPpTag[call_number]
15+
[last_Call-ID:]
16+
[last_CSeq:]
17+
Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
18+
Content-Length: 0
19+
20+
]]>
21+
</send>
22+
23+
<pause milliseconds="100" />
24+
25+
<send retrans="500">
26+
<![CDATA[
27+
28+
SIP/2.0 200 OK
29+
[last_Via:]
30+
[last_From:]
31+
[last_To:];tag=[pid]SIPpTag[call_number]
32+
[last_Call-ID:]
33+
[last_CSeq:]
34+
Contact: <sip:bob@[local_ip]:[local_port];transport=[transport]>
35+
Content-Type: application/sdp
36+
Content-Length: [len]
37+
38+
v=0
39+
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
40+
s=-
41+
c=IN IP[media_ip_type] [media_ip]
42+
t=0 0
43+
m=audio [custom_media_port] RTP/AVP 9 8 0
44+
a=rtpmap:9 G722/8000
45+
a=rtpmap:8 PCMA/8000
46+
a=rtpmap:0 PCMU/8000
47+
a=ptime:20
48+
a=maxptime:20
49+
a=sendrecv
50+
]]>
51+
</send>
52+
53+
<recv request="ACK"
54+
rtd="true"
55+
crlf="true">
56+
</recv>
57+
58+
<recv request="BYE" />
59+
60+
<send>
61+
<![CDATA[
62+
63+
SIP/2.0 200 OK
64+
[last_Via:]
65+
[last_From:]
66+
[last_To:]
67+
[last_Call-ID:]
68+
[last_CSeq:]
69+
Content-Length: 0
70+
71+
]]>
72+
</send>
73+
74+
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
75+
76+
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
77+
78+
</scenario>
79+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
testinfo:
3+
summary:
4+
'Test advanced codec negotiation in a call between two parties
5+
with 3 common codecs '
6+
description: |
7+
'Two PJSIP endpoints are configured to support many codecs.
8+
Alice client is configured with Opus as additional codec.
9+
All endpoints share the same codec settings in pjsip.conf
10+
Alice calls Bob and in Bob\'s SDP answer he provides 3 codecs that Alice except Opus.
11+
The common codecs are g722,pcma,pcmu.
12+
Asterisk should not transcode in this case as the parties share at least one common codec.'
13+
14+
properties:
15+
dependencies:
16+
- python: 'twisted'
17+
- python: 'starpy'
18+
- asterisk: 'app_dial'
19+
- asterisk: 'res_pjsip'
20+
- sipp:
21+
version: 'v3.6.0'
22+
tags:
23+
- pjsip
24+
25+
test-modules:
26+
add-test-to-search-path: 'True'
27+
test-object:
28+
config-section: test-case-config
29+
typename: 'sipp.SIPpTestCase'
30+
31+
test-case-config:
32+
memcheck-delay-stop: 7
33+
# connect-ami: 'False'
34+
fail-on-any: false
35+
test-iterations:
36+
# First iteration
37+
-
38+
scenarios:
39+
# Bob receives call from Alice
40+
- {'key-args':
41+
{'scenario': 'bob.xml', '-p': '5060', '-i': '127.0.0.3',
42+
'-s': 'alice', '-timeout': '20s', '-mi': '127.0.0.3'
43+
},
44+
'ordered-args':
45+
['-timeout_error', '-key', 'custom_media_port', '6004']}
46+
# Alice calls Bob
47+
- {'key-args':
48+
{'scenario': 'alice.xml', '-p': '5060',
49+
'-i': '127.0.0.2', '-s': 'bob', '-timeout': '20s',
50+
'-mi': '127.0.0.2'},
51+
'ordered-args':
52+
['-timeout_error', '-key', 'custom_media_port', '6004']}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[general]
2+
3+
[globals]
4+
5+
[calling]
6+
exten => bob,1,NoOp()
7+
same => n,Dial(PJSIP/bob)
8+
same => n,Hangup()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[system]
2+
type=system
3+
timer_t1=100
4+
timer_b=6400
5+
6+
[global]
7+
type=global
8+
debug=yes
9+
10+
[local-transport]
11+
type=transport
12+
bind=127.0.0.1
13+
protocol=udp
14+
15+
16+
17+
[endpoint-template](!)
18+
codec_prefs_outgoing_answer = prefer: pending, operation: union, keep: all, transcode: allow
19+
20+
[alice](endpoint-template)
21+
type=endpoint
22+
allow=opus,g722,ulaw,alaw,h264
23+
context=calling
24+
direct_media=no
25+
media_address=127.0.0.1
26+
aors=alice
27+
28+
[bob](endpoint-template)
29+
type=endpoint
30+
allow=opus,g722,ulaw,alaw,h264
31+
context=calling
32+
direct_media=no
33+
media_address=127.0.0.1
34+
aors=bob
35+
36+
[bob]
37+
type=aor
38+
max_contacts=1
39+
contact=sip:[email protected]:5060\;transport=udp

0 commit comments

Comments
 (0)