Asterisk 14 opus config not working

Good day

I am using Asterisk 14.6.2.

The codec_opus.so and format_ogg_opus.so modules are loaded and running, however non of the options i setup in codecs.conf are being used by asterisk,

Codecs.conf
[opus8]
type=opus
packet_loss=5
complexity=10
max_bandwidth=narrow
signal=auto
application=voip
max_playback_rate=12000
bitrate=auto
cbr=1
fec=1
dtx=0

My testing is done on a yealink T40p using the opus codec. I am trying to make narrowband opus calls. The extension has dissallow all , allow opus8 configured.

when i make a call i see that the call is not narrowband and usses about 31kb tx, and 45kb rx on the line, monitoring is done by mirkotik.

can someone assist me in getting the codec to truely use narrowband?

What is the output of the SIP signaling? (the INVITE and etc that contains the SDP, it will show what is being negotiated)

My phone IP is 192.2.2.162
My pbx is 192.15.1.9

NVITE sip:#######@192.15.1.9:5060 SIP/2.0
Via: SIP/2.0/UDP 192.2.2.162:1024;branch=z9hG4bK825109692
From: “opus” sip:2000@192.15.1.9:5060;tag=2830686737
To: sip:##########@192.15.1.9:5060
Call-ID: 1_1430801944@192.168.55.250
CSeq: 2 INVITE
Contact: sip:2000@192.2.2.162:1024
Authorization: Digest username=“2000”, realm=“asterisk”, nonce=“1508932598/5ef4f3c7d187596c404cb0ed188e5696”, uri=“sip#########@192.15.1.9:5060”, response=“f1ad1baa13b5e6dccd2ae4b4cf4888a6”, algorithm=MD5, cnonce=“0a4f113b”, opaque=“0ce1980a036def29”, qop=auth, nc=00000001
Content-Type: application/sdp
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE
Max-Forwards: 70
User-Agent: Yealink SIP-T40P 54.82.0.20
Allow-Events: talk,hold,conference,refer,check-sync
Supported: replaces
Content-Length: 216

v=0
o=- 20006 20006 IN IP4 192.2.2.162
s=SDP data
c=IN IP4 192.2.2.162
t=0 0
m=audio 11944 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=ptime:20
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

And the SDP in our 200 OK?

Apologies

Here it is
2017-10-25 13:56:46 +0200 : 192.15.1.9:5060 -> 192.2.2.162:1024
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.2.2.162:1024;rport=1024;received=192.2.2.162;branch=z9hG4bK825109692
Call-ID: 1_1430801944@192.168.55.250
From: “opus” sip:2000@192.15.1.9;tag=2830686737
To: sip:###########@192.15.1.9;tag=2014e89f-869f-4164-880a-24be06cfe920
CSeq: 2 INVITE
Server: FPBX-14.0.1.1(14.6.2)
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: sip:192.15.1.9:5060
Supported: 100rel, timer, replaces, norefersub
P-Asserted-Identity: “CID:2000” sip:##########@192.15.1.9
Content-Type: application/sdp
Content-Length: 229

v=0
o=- 20006 20008 IN IP4 192.15.1.9
s=Asterisk
c=IN IP4 192.15.1.9
t=0 0
m=audio 12152 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

Do you also have the res_format_attr_opus module loaded?

Yes i confirmed just now it is loaded and running

freepbx*CLI> module show like opus
Module Description Use Count Status Support Level
codec_opus.so OPUS Coder/Decoder 0 Running extended
format_ogg_opus.so OGG/Opus audio 0 Running core
res_format_attr_opus.so Opus Format Attribute Module 1 Running core
3 modules loaded

What happens if you use “allow=opus” instead of opus8 (for testing purposes). I find it odd because there’s no fmtp in our response.

Yes it appears that in the current version of Digium’s codec_opus some of the configuration settings are not correctly applied and/or passed along in the SDP. However, I believe this has since been fixed and a new version of the codec should be released within the next few weeks.

should i change my codecs.conf to opus and then allow opus on the extension to test or just change extension to allow opus?

Don’t modify codecs.conf at all, just use “opus” in the allow line without any further changes.

Here is the call with just allow opus. Left the codecs.conf on opus8.

2017-10-30 12:11:13 +0200 : 192.2.2.162:5060 -> 192.15.1.9:5060
INVITE sip:xxxxxxxxxx@192.15.1.9:5060 SIP/2.0
Via: SIP/2.0/UDP 192.2.2.162:5060;branch=z9hG4bK2578166126
From: “opus” sip:2000@192.15.1.9:5060;tag=282785951
To: sip:xxxxxxxxxx@192.15.1.9:5060
Call-ID: 1_2096461407@192.168.55.250
CSeq: 1 INVITE
Contact: sip:2000@192.2.2.162:5060
Content-Type: application/sdp
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE
Max-Forwards: 70
User-Agent: Yealink SIP-T40P 54.82.0.20
Allow-Events: talk,hold,conference,refer,check-sync
Supported: replaces
Content-Length: 216

v=0
o=- 20001 20001 IN IP4 192.2.2.162
s=SDP data
c=IN IP4 192.2.2.162
t=0 0
m=audio 11906 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=ptime:20
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

2017-10-30 12:11:23 +0200 : 192.15.1.9:5060 -> 192.2.2.162:5060
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.2.2.162:5060;rport=5060;received=192.2.2.162;branch=z9hG4bK3399823305
Call-ID: 1_2096461407@192.168.55.250
From: “opus” sip:2000@192.15.1.9;tag=282785951
To: sip:xxxxxxxxx@192.15.1.9;tag=ebb9e9ae-918b-4648-a137-7953e5e3a3a7
CSeq: 2 INVITE
Server: FPBX-14.0.1.1(14.6.2)
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: sip:192.15.1.9:5060
Supported: 100rel, timer, replaces, norefersub
P-Asserted-Identity: “CID:2000” sip:xxxxxxxxxx@192.15.1.9
Content-Type: application/sdp
Content-Length: 229

v=0
o=- 20001 20003 IN IP4 192.15.1.9
s=Asterisk
c=IN IP4 192.15.1.9
t=0 0
m=audio 17152 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

The new version being released in a few weeks as @kharwell stated may resolve this as he said. Once that is out we can see what happens. It’s also interesting that the Yealink doesn’t request this themselves.

1 Like

Oky great thank you for the assistance.

Any release date for the new codec?

I do not have a specific release date. A few weeks or less.

I see a newer v1.2.o codec is downloadable from digium site, does this contain the fix for the problem described above?

It contains a few different fixes, including one that may resolve this, yes.

HI there

i tested using Opus Codec 1.2 with asterisk 14 and the result is still the same.

Find sip packets below

INVITE sip:0839######@192.15.1.9:5060 SIP/2.0
Via: SIP/2.0/UDP 192.2.2.162:1024;branch=z9hG4bK1733454999
From: "opus" <sip:2000@192.15.1.9:5060>;tag=1688182945
To: <sip:0839######@192.15.1.9:5060>
Call-ID: 1_2534513119@192.168.55.250
CSeq: 2 INVITE
Contact: <sip:2000@192.2.2.162:1024>
Authorization: Digest username="2000", realm="asterisk", nonce="1511258395/5b75d25cb8fd546670039c63ca099421", uri="sip:083#######8@192.15.1.9:5060", response="100280cc83481a99d6a1abb0d39c6436", algorithm=MD5, cnonce="0a4f113b", opaque="54bce1582a0573f7", qop=auth, nc=00000001
Content-Type: application/sdp
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE
Max-Forwards: 70
User-Agent: Yealink SIP-T40P 54.82.0.20
Allow-Events: talk,hold,conference,refer,check-sync
Supported: replaces
Content-Length: 216

v=0
o=- 20003 20003 IN IP4 192.2.2.162
s=SDP data
c=IN IP4 192.2.2.162
t=0 0
m=audio 12680 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=ptime:20
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15


2017-11-21 12:00:02 +0200 : 192.15.1.9:5060 -> 192.2.2.162:1024
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.2.2.162:1024;rport=1024;received=192.2.2.162;branch=z9hG4bK1733454999
Call-ID: 1_2534513119@192.168.55.250
From: "opus" <sip:2000@192.15.1.9>;tag=1688182945
To: <sip:###########@192.15.1.9>;tag=f4348e52-8a22-4ae6-a7e7-9855710a085f
CSeq: 2 INVITE
Server: FPBX-14.0.1.20(14.6.2)
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: <sip:192.15.1.9:5060>
Supported: 100rel, timer, replaces, norefersub
P-Asserted-Identity: "CID:2000" <sip:##########@192.15.1.9>
Content-Type: application/sdp
Content-Length:   247

v=0
o=- 20003 20005 IN IP4 192.15.1.9
s=Asterisk
c=IN IP4 192.15.1.9
t=0 0
m=audio 15242 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=fmtp:107 cbr=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

My codecs.conf is as follows
[opus8]
type=opus
packet_loss=5
complexity=10
max_bandwidth=narrow
signal=auto
application=voip
max_playback_rate=12000
bitrate=auto
cbr=1
fec=1
dtx=0

For the most part the SDP in the 200’s reply looks correct. Format parameters will only show up if they 1) are not set to the default value, 2) are jointly agreed upon.

So for instance, “dtx” falls under the first condition since “0” is the default. The reason “useinbandfec” is not in the reply is because both sides have to specify it, so this falls under the second condition. “cbr” is shown because it’s allowed if either side specifies it.

That all being said it does appear the “maxplaybackrate” parameter is still missing. Please file an issue on the Asterisk Issue Tracker. Please attach the information you provided (configuration, SIP trace) here on the issue as well.

Actually it looks like there is already an issue for the “maxplaybackrate” not being set: ASTERISK-26901