Codec negotiation


I haven’t found yet something reliable about codec negotiation so I’d like to know if someone could tell or post a good link that gives me the right directions.

Here’s the idea a got at moment:

UA1 codec order: gsm, ilbc (softphone)
ulaw, gsm, alaw (sip.conf)

UA2 codec order: alaw, gsm (softphone)
alaw, ilbc, ulaw, gsm (sip.conf)

Offer schema:

UA1 —> gsm, ilbc —> ASTERISK —> ulaw, gsm, alaw —> UA2
UA1 <— alaw, ilbc, ulaw, gsm <—ASTERISK <— alaw, gsm <— UA2

Now, what’s the negotiation schema that Asterisk takes to set the rights codecs on every UA?

It’s kind of difficult to exlpain my doubts but, any way, if someone know any good text about codec negotiation on Asterisk, please be kind and post it here.