PJSIP and OPUS codec settings

Hello,

I’m trying to limit the bandwidth and sampling rate of the OPUS codec.
I’ve defined a new codec in codecs.conf and added:

[myopus]
type=opus
packet_loss=15
signal=auto
application=voip
bitrate=24000
max_playback_rate=16000
dtx=1

In pjsip.conf I added this codec as the only allowed one:

[incoming-noauth]
type=endpoint
dtls_auto_generate_cert=yes
webrtc=yes
context=xxxxxxxx
direct_media=no
force_rport=yes
allow=!all,myopus

This endpoint is used for incoming, unauthenticated calls, coming from a WebRTC application.
In SDP, the only codec available is OPUS (as expected), but all the extra attributes for bandwidth etc. are missing, even the max_playback_rate setting is ignored:

<--- Transmitting SIP response (1713 bytes) to WSS:[2a02xxxxxx]:54664 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS lcjep48et2ok.invalid;rport=54664;received=2a02:xxxxxxx;branch=z9hG4bK4838678
Call-ID: gvmk361k8tqfm2d30u4a
From: <sip:xxxxxx>;tag=v9q6p9ktmc
To: <sip:xxxxxx>;tag=ae38c11f-4417-4ee2-8571-c54488279b0c
CSeq: 5738 INVITE
Server: Asterisk PBX 16.16.0
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Contact: <sip:[2003:cxxxxxxxxx]:8089;transport=ws>
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 90;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length:   962

v=0
o=- 2742622243 4 IN IP4 xxxxxx
s=Asterisk
c=IN IP4 xxxxx
t=0 0
a=msid-semantic:WMS *
a=group:BUNDLE 0
m=audio 50784 UDP/TLS/RTP/SAVPF 111 126
a=connection:new
a=setup:active
a=fingerprint:SHA-256 B2:67:E2:5E:.....
a=ice-ufrag:[.....]
a=rtpmap:111 opus/48000/2
a=rtpmap:126 telephone-event/8000
a=fmtp:126 0-16
a=ptime:20
a=maxptime:20
a=sendrecv
a=rtcp-mux
a=ssrc:1785835550 cname:222bfaa6-..........
a=msid:7fdd30d4-......
a=rtcp-fb:* transport-cc
a=mid:0

What am I missing?
Or is this expected behaviour on a WebRTC connection?

Thanks!

This is not expected behavior. I’m not sure what might be wrong though. I copied your codecs.conf configuration exactly, but the format parameters were in the 200 OK response for me.

After updating your configuration did you restart Asterisk?

If this is still a problem I’d suggest checking the Asterisk log for errors.

Also as a work around try changing “myopus” to just “opus” in codecs.conf

Is the res_format_attr_opus module loaded?

That was the point!
Added “res_format_attr_opus.so” to load to modules.conf. Even with “autoload = yes”, that module did not get loaded. Now it’s working fine - Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.