Showing posts with label asterisk. Show all posts
Showing posts with label asterisk. Show all posts

Wednesday, October 3, 2012

Custom Destinations in Asterisk

Custom Destination feature in asterisk is a very useful functionality where we can have lot of options to make the asterisk to work in different environments. Upon using this functionality we can use a single inbound number to access all internal conference bridges, route the call to one asterisk box to another one through the trunks etc. We will describe these one by one,

  • Accessing internal conference bridges using single inbound number.

In our example, we already have a working asterisk pbx with lot of conference bridges working inside the office through VoIP phones.

We are going to make accessing all these conference bridges from the local mobile/land phones through a single inbound number. So will start as mentioned below,

1) Install "Custom Destination module" through FreePBX admin interface.
2) Create a new custom destination "conferences,s,1" with whatever description you like (ie "ConferenceIVR")
3) Add to /etc/asterisk/extensions_custom.conf the following script


[conferences]
include => ext-meetme; in [ext-meetme] contest are stored all the conferences created in FreePBX
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(enter-conf-call-number); Insert you welcome message
exten => s,n,Goto(w,1)
exten => w,1,Wait(1)
exten => w,n,Playback(beep)
exten => w,n(begin),Set(TIMEOUT(digit)=3)
exten => w,n,Set(TIMEOUT(response)=10)
exten => w,n,WaitExten(,)
exten => w,n,Playback(invalid)
exten => w,n,Goto(w,1)

This script asks for the conference number to join to and enters the context managing the conferences.
If the conference doesn't exists, it loops and ask again for a valid conference number.


4) Reload the Asterisk
5) Create a new Inbound Route and route it to the Custom Destination    "ConferencesIVR"
6)  Now try from local/mobile phones using the inbound number, you will be asked the conference call number to be joined and the PIN for the same.
7) Enjoy !!!


  • Pass one DID from one asterisk to another.
I have two asterisk boxes (box A & box B) in two different countries and both are inter connected through SIP trunk and able to communicate between the extensions registered on both the boxes. In one of my requirement, I have to route my company's support calls coming to one location to be routed to the support team located in the other country after the end of Office hours on first country.

What I did to achieve this are,
  • Set up a DID on box A and it's destination set to the registered extension on box A. For example, +918xxxxx1010 which rings to the local extension 1010, which finally I need to route to extension 2020 on the box B through my SIP trunk.
  • Create a custom destination on Box A as, 
custom-did-to-BoxB,${EXTEN},1
  • Then I have to go and add the following line in the /etc/asterisk/extensions_custom.conf file,  
[custom-did-to-BoxB]
exten => _X.,1,Dial(SIP/2020@IP-Of- the- BoxB,30,r)

If you are using IAX trunk the above line should look like,
[custom-did-to-BoxB]exten => _X.,1,Dial(IAX2/IP-of-the-BoxB/$2020,30,r)
  • Go to the extension 1010 on Box A and select custom destination and set the value as  custom-did-to-BoxB which we created above.
  • Reload asterisk to get it effect.
Now if you call to the local number +918xxxxx1010 and let the phone ring completely, it will route the call to the exension 2020 which is actually registered on BoxB which is in another country.

Wednesday, June 29, 2011

Install (Free) g729 codec on Trixbox CE (asterisk)

g729 is a low bandwidth codec, which can operates at a lower bandwidth of 8Kb/s. This tutorial describes how to install the g729 free codec on trixbox CE.

Download the Codec

Free version of the g729 codecs are available on http://asterisk.hosting.lv/#bin .

Depending on the architecture and the version of asterisk on your machine, download the correct package from the above site.
For finding the asterisk version and system processor architecture we can use the following commands.

astersik -V
uname -a
I have downloaded the following package which worked fine for my Xeon dual core processor and asterisk version 1.4.
[trixbox ~]# wget http://asterisk.hosting.lv/bin/codec_g729-ast14-gcc4-glibc-core2-sse4.so

Rename the codec file

Rename the downloaded file and copy it to /usr/lib/asterisk/modules directory as follows,
[trixbox ~]# cp codec_g729-ast14-gcc4-glibc-core2-sse4.so /usr/lib/asterisk/modules/codec_g729.so

Reload Asterisk

Load the above copied module, by issuing the following command on asterisk console,
[trixbox ~]# asterisk -r
trixbox*CLI> codec load codec_g729

Check the work

Verify the codec has been loaded correctly by the following command on console,
trixbox*CLI> show translation
you will see a line as below for g729,

g729 - 2 2 2 2 2 1 3 - 9 10 2 -

If everything went well as mentioned above, we can test the codec functionality by enabling it in an extension as below,

Test the codec working

Login to the web interface and go to PBX-> PBX Settings-> Extensions, choose one extension you wish to enable the codec for, ensure disallow is set to “all” and allow is set to “g729”.

Once the extension is set up to allow g729, you can test whether it’s working properly by having a test call connected and running the command sip show channels:

trixbox*CLI> sip show channels
It will list the output as below,

192.168.113.35 3245 eefbd3ee-b5 00101/00001 0x100 (g729) No Rx: ACK
We are done.

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