Minimise Transcoding in Freeswitch

Status
Not open for further replies.

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Hello, This may be more a question for a FreeSwitch forum, but I know we have a lot of knowledgeable people on here...
In an attempt to minimise CPU usage by reducing the amount of transcoding that takes place, I have looked at enabling inbound-late-negotiation and adding the inherit_codec parameter in the internal SIP profile.

Even though I can see in the debug trace that Sofia is working out a match, it doesn't use it because before the 200OK comes in from the b-leg a 183 early media messages with an SDP is sent to the a-leg, at this point Sofia does not know what codecs b-leg will offer so it goes with a prference from the a-leg selection. But now when the 200OK comes in from b-leg FS sends 200OK to a-leg with same SDP as in the 183 message. I believe this is the correct behaviour looking at RFC.

The problem is FS is now transcoding when there were common codecs available on both legs, the early media seems to have scuppered the late negotiation. I found a section on the FS documentation that is entitled Early Media and Late Codec Negotiation but it is just a stub with no content.

Can anyone shed any light on this for me?

Many thanks
Adrian.
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
Can anyone shed any light on this for me?

I usually lock Fusion and the provider to a single codec, so any transcoding - if required - would happen on the provider's server.

Code:
<action application="bridge" data="{absolute_codec_string='PCMA'}sofia/gateway/gw1/dest_num"/>
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Thank you DD. I can see from the logs that changing negotiation from generous to greedy does align the codecs better and indeed does reduce transcoding. Still curious about the section in the FreeSwitch wiki (confluence) entitled Early Media and Late Codec Negotiation. I guess I'll keep checking to see if something get written in there.
 
Jul 15, 2021
102
9
18
34
Thank you DD. I can see from the logs that changing negotiation from generous to greedy does align the codecs better and indeed does reduce transcoding. Still curious about the section in the FreeSwitch wiki (confluence) entitled Early Media and Late Codec Negotiation. I guess I'll keep checking to see if something get written in there.
I know this is an old thread, I came across an interesting behaviour,if you have early media then your late codec negotiation goes for a toss. As the early media's codec is used as A leg's choice. If you want late negotiation to work as you intend to, disable ringback and transfer ringback in the variables - make sure you restart freeswitch for it to take effect - I learned it the hard way. However with no early media, if you are behind NAT, I find the audio port negotiation takes a while after the call is established and the otherside speaks to a black hole for a while and audio is lost. So the best approach might be for freeswitch to fix this "feature" as a work around you can try playing a ringback file with the codec of your choice (in the dialplan) - I am yet to try this.
 
Status
Not open for further replies.