How do you change codec priority?

I enabled G722 (high definition audio) on my phone and on my FreePBX server. It's all working fine.
The problem is that FreePBX gives priority to ulaw and gsm. They show up first in the sip.conf file (which I cannot edit because FreePBX overwrites them).
The only way I can get G722 to work is by adding the allow=g722 to sip_general_custom.conf and then set my phone to ONLY use G722. If I just set my phone to prioritize G722 it negotiates G711 when it registers.
What I would prefer is to have Asterisk prioritize G722 by having this selectable in the FreePBX GUI (globally, not per extension) so that the phone can be set to fall back to ulaw if G722 is not negotiated by the server or I add a SIP phone that does not support G722. I don't see manual edits to freepbx php files as an option because they will be overwritten when I update Freepbx.
I know I can set this per extension by disallowing the codec I don't want or disallow all and allow G722. I would like to be able to globally re-arrange priority which is a much better way IMHO. Especially if you have to set up a lot of extensions.
I'm running the latest FreePBX on Asterisk 1.6.0.17.



Asterisk SIP Settings
Under Tools try Asterisk SIP Settings.
It looks like what you want.
okay it doesn't change priority
But you can enable / disable...
Thanks, I didn't have that
Thanks,
I didn't have that module installed. Some good stuff there but in my case all it is doing is adding g722 to sip.conf. It still adds it after ulaw so that doesn't help. With a just a tiny teeny bit of extra code I'm pretty sure that feature could be added to this module...hint hint. Unfortunately I can't code to save my life.
I'll create a feature ticket.
Don't hint to me
I have written lots of code, but not lately, not in Linux, and not PHP. Like you, I can see what is possible, but not do it myself. Usually easier said than done.
Writing a feature ticket is a good idea.
Bulk change extensions codec select order
Yes we have a procedure. HOWEVER....
The only practical way to do the change on a large scale Freepbx installation is to update the mysql database. This is ONLY for very advanced administrators only. A screw up here and you'll have to delete all your extensions and re-enter/load.
NOTE THAT ALL OUR INSTALLATIONS HAVE THE alaw CODEC ONLY ALREADY CONFIGURED. GENERIC INSTALLATIONS DO NOT.
Thus in a generic installation, this will not work. But quality administrators will get the picture. In the generic case, best that you write a script to obtain the sip extensions and loop around to insert into the sip table with keyword allow and the data set to 'g722&alaw'.
1. Backup your system first
2. All SIP extensions have been entered with codec allow set to just alaw.
3. Obtain the mysql password from /etc/amportal.conf
4. Run up mysql -u asteriskuser - p and enter your obtained password
5. Connect to database asterisk
6. Describe the sip table
7. Select * from sip to view all data.. be aware it might be big
8. Execute the update, in our case.
update sip set data='g722&alaw' where data='alaw';
9. In the Freepbx GUI, navigate and select a extension. Scroll down and check to see that the new codec is now available.
10. Submit the extension, even thou you have not changed anything.
11. Apply the configuration change.
ALL DONE.
Regards, Paul.
mustardman, ok, I saw your
mustardman,
ok, I saw your ticket the other day and understand what you are trying to do. After thinking about it some, I found a way to achieve what you want to do with minimal changes. There will not be an 'intuitive' gui that lets you re-order things by moving them around (it would be nice but ...). However, I am about to checkin a change to the 2.7 repository that will allow you to clear all the codecs, hit submit, then by adding them one at a time and hitting submit between each addition (not reload, just submit), it will put them in that order.
So keep your eyes open and have a look. I'm putting it into 2.7 for now though you could manually put that version on 2.6 if that is what you are running and it would work fine.
Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here
Works for prioritizing, but....
Thanks for all your work on this, Phil. I like using FreePBX.
I ran this suggestion and got station to station calls to complete in G.722, so it works exactly as you said.
But when I dial out on a trunk, I get fast busy.
I am under the impression that this is because the station establishes G.722 on its leg to the PBX, then the PBX can't negotiate G.722 with the trunk and gives up.
Are there any fixes that let the PBX renegotiate with the station? It looks to me as though would also help with announcements.
Thanks again.
Hi Phil, Doesn't need to be
Hi Phil,
Doesn't need to be fancy so your solution sounds great to me.
For me too. :):) Thank you
For me too. :):)
Thank you so much!!!
HDMichael, chances are your
HDMichael,
chances are your trunk does not support g722 and you may not have had other codecs available to negotiate a call.
You need to make sure your phones have other more standard codecs listed lower in their list (like ulaw/alaw depending on your location).
On the trunk side, it's always a good idea to have:
with the list of codecs those supported by your trunk provider based on your desired preference (e.g. it's fine to have just on, ulaw/alaw, as appropriate).
Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here