tags:

views:

842

answers:

3

Hello everyone, i am developing an application that shall allow users to access their mail boxes using their phones. I developped an IVR menu of which users will make use to retrieve their mails. More specifically I write an AGI in perl to retrieve the mails. The issue is that the AGI execution takes quite a long time.To this end, I need to make my users hear some music played back in the background while the agi being executed. That is, i need to make the "AGI" and "MusicOnHold" applications in my dialplan execute simultaneously. Any clue how I can achieve this?

+1  A: 

This may not be the answer you expected, but if you plan to create a proper application for doing stuff over the phone, have a look at other solutions apart from asterisk. Both yate and (as far as I know - never tried this one for anything serious) freeswitch implement a more asynchronous interface where you can connect an incoming call to whatever sound source you want without losing control over it. They may be a much better choice for advanced applications.

Asterisk is cool for simple logic, but if you need some processing in the background and leaving the call in some state for an undefined time, it becomes quite hard to manage.

viraptor
A: 

You can issue SET MUSIC ON from you AGI applications, process your calculations, then issue SET MUSIC OFF.

If you want the music to be interruptable, issue this:

CONTROL STREAM FILE <filename> "0123456789*#" "0" "" "" ""

The second parameter is the list of digits able to interrupt the music.

It's better not to mix AGI and dialplan commands.

AGI is capable of everything dialplan is capable of, but AGI is implemented in a full fledged programming language and therefore gives you more control over the execution logic.

Quassnoi
A: 

Is the complete execution taking a long time or just starting up the app? If the whole execution takes too long then you can do what Quassnoi says, start the music as soon as the AGI program starts.

If startup time is the problem, then you might need to implement something with FastAGI, so that your app is always running and listening for connections over a socket. The performance is much much better in an environment with a lot of AGI calls.

Chochos