How to retrieve SDP codecs in dialplan?

Hello,

Here, many ITSP provides SIP trunks allowing only two audio codecs: G711A or G729. While most calls use G711A, some use G729 forcing Asterisk to either natively support G729, or pass G729 to IP phones and drop many Asterisk features accordingly (no voicemail, playback, …).

In my dialplan, before dialing my SIP phones how can I retrieve SDP codecs so that, if a G729 call comes in, I can drop some dialplan features.

I was thinking CHANNEL(audionativeformat) would exactly reflect what is listed in incoming SDP but from short trials, CHANNEL(audionativeformat) intersects SDP codec list with allowed codec list.

In 2019, this [1] thread said this was not yet possible.

Best regards

[1] Retrieve incoming sdp context / codecs - #3 by kharwell

I don’t understand why the restriction mentioned in the posting you reference is relevant, given that the configured list of codecs, for the endpoint, will already have limited which the other side can send.

Based on documentation, I’d probably have looked into audionativeformat in CHANNEL - Asterisk Documentation