Including external C++ Module

Hi All,

I want to include my own application in Asterisk Realtime. for the reasion of routing and calculating call rate.

I want to use Asterisk to work as Proxy Server, only for user registeration and routing calls to the carrier via IP Address. I will not use for any PSTN purpose.

I written my perl script to do my requirment via GAI Perl. But day by day my cuncurrent calls are increasing so some time our perl script taking more time to connect MySQL and calculatiing balance.

[main-ext]
exten => _x.,1,Set(UserN=${ACCOUNTCODE})
exten => _x.,2,Set(CalledNum=${EXTEN})
exten => _x.,3,Set(Stime=${DATETIME})
exten => _x.,4,Set(CID=${CALLERID})
exten => _x.,5,Set(HCA=${HANGUPCAUSE})
exten => _x.,6,Set(Cun=${UNIQUEID})
exten => _x.,7,AGI(dial_num.pl)
exten => h,1,DeadAGI(/var/lib/asterisk/agi-bin/update_balance.pl)

dial_num.pl Inside this file i am calculating the the called country rate according to user balance after that i am dialing from the same file with timelimit.

update_balance.pl Once the AGI will dead this script will update the balance and calculate the call rate etc…

So this file i compile successfully in C++, now i want to include it in RealTime. because i found C++ is faster than Perl and it will solve my poblem for crashing Database Server.

My question is: How i can my modules before dialing the numbe?

113574

There are some condiderations:

  1. dial_num.pl could not only dail, but also update your DB.
  2. If you have already some application, writen in C, then compile it, and use it same way as you are using perl scripts.
    I suppose you made translation from perl to C - it should work without problems.

Hello,

Could u tell me the following information

1- Which one will be faster Perl or C?
2- To run C application, i need to install some liberary for C AGI?

a badly coded C app might be slower than your Perl script !!

voip-info AGI page lists sourceforge.net/projects/cagi/ as a C AGI Toolkit, might be worth checking it out.

how about compiling your app as an asterisk native application instead ?

Hello,

Thats what i wanted to know to compile my app as an asterisk native. But i do not have any information, how i should start and which asterisk channels i have to add so i can capture asterisk even in my application and our app can do my requirment job before make and after disconnectinc call.

Coud you point me any documents so i can try to compile my app as an asterisk native?

Get any application like app_cdr.c - look at it.
Follow their way of programming.
Put as much as possiible debug strings - you will see how.
And that’s all.
It is simple :smile:
And there are nice looking documentation espesially if you used make doxygen (or something like this)
PS
You can save time and efforts if you will think about fast agi. Meaning every thing which is not specific for Asterisk could be done on some other computer.