Archive

Posts Tagged ‘Asterisk’

Installing the free G729 Codec for Asterisk

May 28th, 2010 Ahmed El Gamil No comments

This tutorial will let you install the G729 Codec on an Asterisk installation in under 5 minutes.

cd /usr/lib/asterisk/modules

Download the codec

[root@Machine modules]# wget http://asterisk.hosting.lv/bin/codec_g729-ast14-gcc4-glibc-pentium.so

Notice that we are in the modules directory

Rename the codec file

mv codec_g729-ast14-gcc4-glibc-pentium4.so codec_g729.so

Restart Asterisk

/etc/init.d/asterisk restart

Check your work

Connect to Asterisk

asterisk -r

Then show all of the codec translations available using the command below, and check g729 at the left, you should see that it can be translated to many other codecs on the top of the table

Machine*CLI> show translations

         Translation times between formats (in milliseconds) for one second of data

          Source Format (Rows) Destination Format (Columns)

          g723 gsm ulaw alaw g726aal2 adpcm slin lpc10 g729 speex ilbc g726 g722

     g723    -   -    -    -        -     -    -     -    -     -    -    -    -

      gsm    -   -    2    2        2     2    1     2    3     -    -    2    -

     ulaw    -   3    -    1        2     2    1     2    3     -    -    2    -

     alaw    -   3    1    -        2     2    1     2    3     -    -    2    -

 g726aal2    -   3    2    2        -     2    1     2    3     -    -    2    -

    adpcm    -   3    2    2        2     -    1     2    3     -    -    2    -

     slin    -   2    1    1        1     1    -     1    2     -    -    1    -

    lpc10    -   3    2    2        2     2    1     -    3     -    -    2    -

     g729    -   3    2    2        2     2    1     2    -     -    -    2    -

    speex    -   -    -    -        -     -    -     -    -     -    -    -    -

     ilbc    -   -    -    -        -     -    -     -    -     -    -    -    -

     g726    -   3    2    2        2     2    1     2    3     -    -    -    -

     g722    -   -    -    -        -     -    -     -    -     -    -    -    -

Machine*CLI> quit

Troubleshooting

If you didn’t see the codec translation as mentioned above then probably you downloaded the wrong codec, please check again the points mentioned during downloading the codec, you can use the following commands to help you:

asterisk -V

uname -a

Routing calls from Zap Trunks to SIP trunks in Asterisk

March 9th, 2010 Ahmed El Gamil 1 comment

So i had this situation where i have 2 Asterisk boxes, the 1st one of them had a PRI card and the 2nd one is just attached to the network through an ethernet card

Goal: redirect all of the incoming calls on the PRI to the 2nd Asterisk box through a SIP Trunk (The 2nd box holds the IVR and all of those stuff, all of the IP phones are connecting to this one), There was no decent documentation about this out there so i am documenting this and may be someone will find it useful.

Here is what you should do (I am assuming you are using an Asterisk installation that uses FreePBX):

  • Create the Zap Trunk as you normally do from the FreePBX interface: Trunks -> Add Zap Trunk
  • Create a SIP trunk that points to the 2nd Asterisk box, we will use this Trunk later in the configuration: Trunks -> Add SIP Trunk, scroll down to outgoing settings and add the following
    • Trunk name: to-2ndAsterisk
    • Peer details:

type=peer

host=<IP Address of 2nd Asterisk Box>

  • Connect to the 1st Asterisk box using SSH and edit the file /etc/asterisk/dahdi-channels.conf, you will find some configuration like
group=0,11
context=from-pstn
switchtype = euroisdn
signalling = pri_cpe
channel => 1-15,17-31
context = default
group = 63
  • So as you can see all of the incoming calls are directed to the from-pstn context, we will now edit this line to direct the calls to the from-pstn-custom context and do the rest of the magic in this context so the file should be as follows
group=0,11
context=from-pstn-custom
switchtype = euroisdn
signalling = pri_cpe
channel => 1-15,17-31
context = default
group = 63
  • Now edit the file /etc/asterisk/extensions_custom.conf and add the following at the end of the file

[from-pstn-custom]
exten => _.,1,Dial(SIP/to-2ndAsterisk/${EXTEN:2},20,rt)

So what this does is that it matches all of the calls (_.) then redirect them through the SIP trunk to the 2nd Asterisk box

  • And the last step is to allow calls coming from the 1st Box to the 2nd Box, you should do IP-based authentication on the 2nd box by editing /etc/asterisk/sip_custom.conf and add the following

[1stAsterisk]
type=peer
canreinvite=no
host=<IP Address of 1st Asterisk Box>
context=from-pstn
nat=no
dtmfmode=rfc2833
disallow=all
allow=ulaw
insecure=port
qualify=yes

Of course you can now create any inbound routes on the 2nd Asterisk Box to match your needs.

I hope this works for you, and if you need any assistance please don’t hesitate to ask me in the comments

Thanks for listening :)