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
Late negotiation doesn't work when calls are bridged to a different profile #1340
Comments
How about if you just add Opus on the external profile too ? I am not very clear on what you're trying to do. Is it just a breakout to a SIP/PSTN trunk ? You also have a lot of channel variables to tune your setup, from dialplan, eg:
|
Thank you for trying to help. The external profile is for PSTN which accepts only PCMA. The external profile has only PCMA as the codec choice for both inbound and outbound. The issue arises with the internal profile which has multiple codecs of choice as per my earlier message. Currently for sip clients connected to internal profile who have Opus and PCMA as choice of codec in that order, when they make a PSTN call via the external profile (bridge), free switch transcodes if I set inbound-codec-negotiation to generous. If I set the inbound-codec-negotiation to scrooge or greedy then it is PCMA all the way for internal calls as well. The inherit_codec /late negotiation fails if there is an early media ring tone provided by freeswitch - as the early media chooses the codec for A leg and it doesn't change it after B leg sends a ring SDP with its accepted codec details.
I have tried these two settings before but it didn't help. When I tried as an experiment to set bridge_early_media=true ( by default it is false as per documentation)- free switch and the whole CPU hogs and the hardware becomes unresponsive. I have 3 profiles, 1 is internal, 2 is external for PSTN, 3rd one is for remote clients to register. Looks like when I disabled ringback and transfer-ringback, I didn't restart freeswitch. I just restarted the profiles - which probably wasn't taking effect. I just restarted freeswitch and the early media has stopped appearing and all has fallen in place. So in short restart freeswitch if you disable instant ringback and transfer ringback. |
Is there a way to choose between Codec Activated L16@48000hz and Codec Activated L16@8000hz using the dialplan. I have achieved late negotiation as I intended with ringback disabled. However this results in a delay in audio port getting established after the call setup is complete - there is a long delay of even 6 -10 seconds if the clients are behind NAT for the audio to work. So ringback is a necessary evil, however it will no longer be an evil if I can set the codec type in the dialplan. |
"Is there a way to choose between Codec Activated L16@48000hz and Codec Activated L16@8000hz using the dialplan" - you cannot "choose" these directly, only by using codecs at specified sampling rates. eg: you could use for codec string "OPUS@8000h" instead of just "OPUS" so everything will be at 8khz. |
@dragos-oancea Thank you for you reply. I tried setting Opus@8000h as you suggested. However by doing so everything gets trans-coded, i.e the clients which can handle Opus, send an SDP with Opus@48000 which gets passed to the B leg by freeswitch. So there is transcoding between Opus@8000 and Opus@48000. When calling a PCMA client, there is transcoding between Opus@8000 and PCMA. All this transcoding occurs only if the ringback is provided. If I disable it - late negotiation works as intended and there is no transcoding. Just to recap, I am posting my settings
If a call is bridged between profile internal and external, I want PCMA at A leg - this currently works with ringback enabled. if a call is bridged between profile internal and external_for_internet at A leg, I want PCMA or Opus depending on the client answering at leg B. However with ringback enabled - A leg is always set to Opus@48000 (when I use Opus@8000h instead of Opus, A leg is stuck at Opus@8000h) For the above call setup If I change inbound-codec-negotiation [scrooge or greedy] at the internal profile, then A leg is always PCMA irrespective of B leg. The following log is to show what happens when I use opus@8000h. This is a call originating from internal profile to external_for_internet
|
Late negotiation works if the call originates and terminates between clients in the same profile. It doesn't work when the call is bridged across profiles. When a call is bridged between profiles, A leg is assigned a codec based on its first preference or that of the profile's first choice based on the inbound-codec-negotiation setting on the profile. B leg gets the codec based on outbound-codec-pref setting. This results in calls being transcoded, even though both the profiles support a common codec. Late negotiation across profiles work if ring back is disabled, however this is leading to large delays in audio ports being set up when UA are behind NAT and hence not optimal. As this setup is similar to proxy or direct media. The issue appears to be that the ringback is sent without waiting for the response for the invite. If freeswitch waits for the response for the invite which has the B leg's preferred codec, then A leg can be fed the ringback with a sampling frequency as specified in the codec of B leg. Right now it blindly sets the sampling frequency of the ringback tone based on the profile's first choice codec. This is not an optimal solution. |
I have a work around for this problem by providing rtp_codec_negotiation=greedy/generous before calls are bridged to other profiles. I would still prefer this late negotiation works as intended when calls are bridged across profiles. It seems to be a classic issue prevailing since ages https://freeswitch-users.freeswitch.narkive.com/ScjSjtgS/inherit-codec-failing-with-pre-media |
I have in my external profile
I also have instant ringback disabled.
When a client on internal profile whose first choice of codec is Opus (whose second choice is PCMA) makes a call which gets bridged to external profile, there is NO late negotiation - the client is offered Opus and this results in transcoding.
I am aware, I can set the inbound-codec-negotiation to greedy in the internal profile to overcome this, but this results in PCMA being offered as the codec for clients wishing to use Opus as the first choice for calls to another profile which supports both Opus and PCMA.
Is this how this late negotiation is designed to work?
I have noticed that late negotiation works across profiles, if the profile responds with a 183 proceeding with a SDP as below
Is this how it is designed to work? It appears that the early media is forcing the codec on A leg even before B leg responds.
I tried setting
<action application="set" data="ignore_early_media=ring_ready"/>
before bridging to the profile, this doesn't prevent early media but just messes the early media ringtone (audibly)
The text was updated successfully, but these errors were encountered: