Asterisk Sound Injection ApplicationLast edited on Feb 25, 2012

Sound injection Application

This application, while not very usefull, is quite funny. I use it to inject sounds on an arbitrary channel, part of an active call, and will not be heard by the other peer. This will act a bit like ChanSpy, except that when pressing on a digit on your keypad, a sound file will be played on the specified channel. For example, let's say that ipphone1 is currently talking talking to ipphone2. With ipphone3, you call an extention that executes Inject(SIP/ipphone2). This will allow you to hear the conversation between ipphone1 and ipphone2. Now you would like to inject a sample that says "What is your name?" (a sound file recorded with the voice of the user using ipphone1). This can now be done by pressing a digit on your keypad. Not only they will not hear you on the other end, but the sound file that you have just injected will be heard by ipphone2 only. This could create a lot of confusion for both users.

Compiling and Installing

First, get a copy of the source code. Untar in any folder you like. With this one, the source code doesn't need to reside in the asterisk source tree, but you will need the asterisk sources on your computer. You might need to change the Makefile since the folders in there are good for my installation, but might not be good for yours. It's a one-line change anyway. Next, just type "make" to build the app, or "make load" to automatically build,install and load the module into asterisk. so basically:

wget http://www.dumaisnet.ca/files/app_inject.tar
tar -xf app_inject.tar
# you might need to modify the ASTMODULES and INCLUDES paths in Makefile
make load


No configuration files are needed. The only thing you need to setup is the dialplan. You only need to call Inject(CHANNEL). No need to answer first, the application will take care of it.

exten => *7,1,Inject(SIP/ipphone)
exten => *7,2,Hangup()

You will need to provide sound files for when you will press digits to play the different sounds that you need. You need to copy 10 sound files in your sound folder (usualy /var/lib/asterisk/sounds). They MUST follow the name scheme "injection0.gsm", "injection1.gsm", ... "injection9.gsm". Of course, you could use .wav or .gsm. As you guessed it, pressing on "5" will play injection5.gsm. It is not necessary to provide all sound files.



Asterisk Filter ApplicationLast edited on Feb 25, 2012

Filter application

I use this application to manage a blacklist of telemarketers. Althought this could be easily done with a perl script, I'd rather have a real application for it. This application will allow you to define several groups. In each group, you add a list of callerID, an optional greeting message and a context/extension pair to jump to. If the callerID of an incomming call matches a callerID defined in a group, the group's greeting message will be played and the dialplan will jump to the context/extension defined for that group. If no greeting is defined, none will be played. If no context/extension pair is defined, dialplan execution will continue normaly.

Compiling and Installing

After downloading app_filter.c, copy the file in your asterisk source three and compile it. In my example, I am assuming that your asterisk source code is in /usr/src/asterisk- and that your modules are located in /usr/lib/asterisk/modules/.

cp app_filter.c /usr/src/asterisk-
cd /usr/src/asterisk-
make apps
cp apps/app_filter.so /usr/lib/asterisk/modules/

next, go into the asterisk CLI and load the module using "module load app_filter.so". Of course it is also possible to have the module loaded automatically using /etc/asterisk/modules.conf. Now you are ready to use the module


You must first create /etc/asterisk/filter.conf. Add the following:

dbtype => 0

"dbtype" must be set to 0 if the same configuration file is going to be used for defining filter groups. Set dbtype to 1 if you prefer mysql. If you are going to be using mysql, you can skip to the next section. Otherwise, here's how to do it. Note that the configuration file is read each time that Filter() is called

You can several sections, in the file. In each section, add as many callerIDs as you want using the "cid:" directive. Define an optional greeting with "greeting", context with "context" and extension to "exten" Complete example:

dbtype => 0

cid => 1001234567
cid => 1001234566
greeting => greeting1 ; do not add the extension. This file must be present in /var/lib/asterisk/sounds

cid => 1001234565
cid => 1001234564
greeting => not-welcome
context => telemarketer-torture
exten => s

In this example, caller with callerID 100-123-4565 will hear the "not-welcome.wav" greeting message and will be redirected to extension "s" in the "telemarketer-torture" context

Configuration with mysql

mysql support is not implemented yet


Here is how you should use it in the dialplan:

exten => s,1,Answer()
exten => s,2,Filter()


The source code can be found here: app_filter.c

Aastra weather xml applicationLast edited on Feb 25, 2012


This application will only work for cities in Canada. The ministry of the Environment provides RSS feeds on a website for every (almost every) cities in canada. I made an application that downloads the RSS feed, parses it and then presents it in a format that is suitable for the Aastra phone. The current package has the city of Ottawa hardcoded in it but this is easily changed.



Aastra prime rate xml applicationLast edited on Feb 25, 2012

Prime rate

I wanted to have a way of seeing the current prime rate of the National Bank Of Canada every day. Instead of having a bookmark or a RSS reader, I figured it might be useful to have that information displayed on the idle screen of my a57i phone. This application is a good example to figure out how to write an Idle screen application. I haved added the url of my application in the "Poll" field under the "Action URI" page. That way, the application is downloaded every 3600 seconds and the idle screen is then refreshed. This application also includes the current outside temperature taken from the ministry of environment webpage.



Aastra contact list xml applicationLast edited on Feb 25, 2012

Contact directory

The Aastra 571 does not provide a phonebook button. This is not a problem since this can be done with the assignment of an XML application on a soft button. My contacts are all stored in a MYSQL database. This contact list is maintained on a page on my intranet website. You can see how usefull it would be to have that list accessible on all IP phones in the house. This application will do the trick.