codec selection negotiation and tweaking

mikemee
Posts: 124
Member Since:
2006-06-07

I think I'm pushing on rope, but I'm trying to configure a system that will do this:

* use ulaw for all communications on the local network (e.g. between phones, voicemail)
* use g729 for all communications on the WAN (e.g. iax2 to/from remote office, SIP with voipstreet/vitelity)

I have phones that will do several codecs. However, my research suggests that the following happens during codec negotiation:

Make an outside call from an office phone:

1) phone calls asterisk
2) asterisk starts with the allow= list in order and picks the first codec on the list that the phone says it can do
3) asterisk then negotiates the next hop as a separate connection except that if the codec chosen for connection (1) is anywhere on the allow list for connection (2), it will ask for that first
4) if the resulting codecs match, asterisk simply passes packets back and forth, or, if canreinvite is set yes and NAT is set no and the phones are on the same lan, asterisk will issue a reinvite to both phones and if everything aligns the phones will talk amongst themselves.
5) if the resuling codecs don't match, asterisk does transcoding as needed

Thus, if I setup my outside trunks to only support g729 (allow=g729), I have two choices for my phone extension settings, i.e. allow=ulaw&g729 or allow=g729&ulaw. These have the following results:

allow=ulaw&g729
Phone (ulaw) -> Phone (ulaw) - great quality, good result
Phone (ulaw) -> Outside (g729) - asterisk transcodes, cpu and license used
Phone (ulaw) -> voicemail (ulaw) - great quality, good result
Outside (g729) -> Phone (g729) - asterisk passes packets, no license used, no cpu used
Phone (ulaw) -> Remote office IAX2 (g729) -> Phone (g729) - 1 license used, 1 cpu used

allow=g729&ulaw
Phone (g729) -> Phone (g729) - no license used, no cpu used, reduced quality
Phone (g729) -> Outside (g729) - asterisk passes packets, no license used, no cpu used
Phone (g729) -> voicemail (g729) - 1 license used, reduced quality
Outside (g729) -> Phone (g729) - asterisk passes packets, no license used, no cpu used
Phone (g729) -> Remote office IAX2 (g729) -> Phone (g729) - no license used, no cpu used

Tradeoffs both ways as you can see. The 2nd uses less licenses and less CPU, but there is never an opportunity to use ulaw and take advantage of being on a 100 Mbit LAN.

Am I completely messed up on this (e.g. how codec negotiation works)? Do others have a similar experience or needs? Any suggestions or hacks?

thx, michael