Skip to main content

How To's


This pages contains tutorials for common use. All dialplan recipes gathered from emails or conversations could stay here.

Click here to expand Table of Contents

Lock negotiated codec

In the middle of a call if one side puts the other one on hold a re-invite will occur and a new codec negotiation will happen. There's cases where you need to keep the same codec previously negotiated when the call was answered.

To accomplish this you can make an extension in the same context "assuming default for this example":

<extension name="lock_codec">                                                                                                                                   
<condition field="destination_number" expression="^lock_codec$">
<action application="set" data="absolute_codec_string=${rtp_use_codec_name}"/>

In your normal call processing extension add this condition before calling bridge:

<action application="set" data="execute_on_answer=execute_extension lock_codec XML default"/>

Then when the channel is answered it will execute the extension and set the absolute_codec_string to whatever codec was first negotiated, that should limit what it will choose on the re-invite.

You can probably set it on both legs with "export" instead of set or by adding it also to the {} before bridge.

Dialplan: sofia/internal/1007@ Regex (PASS) [lock_codec] destination_number(lock_codec) =~ /^lock_codec$/ break=on-false
Dialplan: sofia/internal/1007@ Action set(absolute_codec_string=${rtp_use_codec_name})
2016-12-14 00:51:19.722495 [NOTICE] switch_core_session.c:2966 Execute set(absolute_codec_string=${rtp_use_codec_name})
EXECUTE sofia/internal/1007@ set(absolute_codec_string=PCMU)
2016-12-14 00:51:19.722495 [DEBUG] mod_dptools.c:1562 SET sofia/internal/1007@ [absolute_codec_string]=[PCMU]