Which audio codec should I use to ge the best audio quality?
There isn’t a simple answer to that question. It depends on how much bandwidth you’ve got available - among other things.
Given enough bandwidth, g711 is best - as it’s uncompressed. But it’s likely to sound pretty bad if you try and use it over a network connection that hasn’t really got enough bandwidth overhead.
G729 is pretty much the standard for best quality with lower bandwidth requirements. However, it’s a proprietary codec and you have to pay for it.
GSM is arguably near enough as good as g729 - you’re not likely to be able to hear much difference, anyway - but it’s free.
ILBC is about the same quality as g729 and GSM - it’s also free.
These are the most commonly used and the rest probably aren’t worth bothering about.
However, you also need to take into account the load you’re going to place on your Asterisk server if you need to transcode between different codecs. The least load with transcoding would be between g711 and GSM. ILBC and g729 put considerably more load on the server. Whether this matters or not depends on how you’re using it.
In general, as a rule of thumb, and where possible, i’d be inclined to go for g711 over ethernet - say between your phone and Asterisk - and GSM over the internet - between Asterisk and an ITSP.
You mentedion iLBC and GSM as being comparable, why did you recommend GSM over iLBC if the Internet stands between the PBX and the phone?
iLBC puts more load CPU cycle-wise on the computer…