Codec negotiation

Our DID provider sends alaw and g729 codec (alaw preferred)
My preferred codec is g729 but fax detection does not work with g729

sip.conf
g729
alaw
gsm

If preferred_codec_only=no calls from the provider side end up connecting via alaw and (t.38) fax detection works
If preferred codec_only=yes calls from the provider side will connect on g729 but fax detection fails.

I need fax detection to work but would like to force g729 codec whenever possible. Is there a way?

How are you terminating your FAX calls? If they’re going to an ATA, ONLY support alaw on that device. You could T.38 if you’d like but it may not be necessary if the call is set up with an uncompressed codec.

Thanks but that’s not what I meant.

I am using fax2email so incoming calls from my provider are recognized in FreePBX as fax and sent to my email. My provider send alaw (t38) and g729 (without preference) so incoming calls are recognized as t38 and it works if I allow both codecs on my side. However since FreePBX (Asterisk?) does not force codec priority ALL other calls also resolve with alaw codec instead of g729 which would be preferable for voice calls.

Setting “preferred_codec_only=yes” makes fax calls fail because FreePBX forces the g729 codec and thus does not recognize t38 faxes. If I remove that setting faxes work but all calls are alaw. That is my issue.

Yes that is how asterisk works with being designed as a back to back user agent. If someone offers a codec to asterisk and that codec is in the list for asterisk to accept it takes it. Regardless of what order in the list it is. This is all by design of asterisk to take the media and if it needs to change when going back out it will transcode it.

No different than people setting there polycom or aastra phones to use G729. When an ext calls another ext it passes through the G729 but if it is a call going out a trunk or to a device that does not support G729 it trans codes it instead of going back to the originator of the call and asking for a better suited codec.

You need to learn to do some research before blasting the forums with questions that can be answered by a simple google search as most people will just ignore your post since this is asterisk 101 stuff.

Thanks for the reply and sorry for my ignorance. I guess I know more about setting up trunks, routes, etc… than the Asterisk basics but I never pretended to be a pro at this.

I do research each issue before I post a question but if I don’t find an answer I dig further and check the forum. Most of the time people are nice and answer anyways. Even if my questions are about the basics.