SIP codec negotiation matrix by subnet

Hi guys

In a mixed environment, with LAN and WAN handsets, but not necessarily IAX interlinks, it would be nice if Asterisk could do SIP codec negotiation by using a matrix of “lowest common denominator” type selections. Currently Asterisk puts itself in the RTP path if a calling host has one preferred codec, when a recipient has another. Even if the recipient has only one codec allow line in sip.conf, Asterisk ends up creating two channels with different codecs in each direction.

Could dial be modified so a switch can be set to force a single codec to be negotiated in BOTH directions?

An example would be where there is a local PSTN gateway. Asterisk SIP conf would have disallow all, then allow lines for g711a, g711u, g729,gsm in that order.

All handsets would negotiate with g711a between each other and to the PSTN gateway.

Now we have a remote office with 2 handsets. In sip.conf I have these handsets with disallow=all and allow=g729.

When these handsets call the main office or each other, they will call at g729 and as sip.conf has that in the allow list and assuming all handsets and gateway have g729, they will talk g729.

Now if the main office handsets, or the PSTN gateway call the remote handsets, we end up with g.729 in one direction and g711 in the other.

If Asterisk had some form of matrix for subnets, or another form of identifiying sites, all calls between phones in the branch office would be negotiated with g711, all calls within the main office would be g711 and all calls between the offices would be g729.

Currently Asterisk has problems with this construct.

Cheers

Mark