How to play a notification (voice) on an on-going call

Hi,

I’m working on a simple application for my office that puts a limit on the amount of time someone in the office can be on the phone (when making outbound call).

The only thing missing in the app (but really nice to have) is a notification that is played when the time limit is about to be reached (e.g.: “you have 2 minutes left…”). Both parties involved in the call should be able to hear the notification, and the call should not be interrupted. The voice from both parties should be ‘mixed’ with the notification message. The notification will be short, soft, and played with low volume. It is as if someone whispers behind the caller, softly, but can still be heard at the other end of the call.

I’ve tried the following:
[1] In the dialplan, I routed the call to an AGI script (written in Java, using Asterisk-Java).
[2] Within the service() method of the AGI script I did 2 things:
- I sent a RedirectAction (to the destination wanted by the caller).
- I scheduled a TimerTask that when fires will send StreamFileCommand through the AGI channel. (note: the parameter of the streamfilecommand is the name of a sound file located unded /var/asterisk/sounds).
[3] Because from inside the run() method of the TimerTask I need a reference to the AGIChannel, I make the execution of service() method of the AGIScript to wait (i.e.: doesn’t return) until the timertask has fired or the call has been hang up. I used a simple thread synchronization techniques in Java using wait() and notify() method.

The trick didn’t work. I got an exception that says: “channel has been hang up”, that was thrown when the timertask sent the StreamFileCommand. I debugged through my code (including Asterisk-Java source code) and found out that the exception was thrown because the asterisk java didn’t receive any reply for the stream file command that it sent.

I don’t think it’s Asterisk-Java bug. I guess that Asterisk simply ignores AGI command sent “through” ‘dead’ channel. I’m not quite sure what I meant by dead channel, though :smile: I was just guessing that once the RedirectAction has succeeded (that resulted in the 2 channels being bridged), the original channel (from the caller to the AGI script) will become invalid, and anything that Asterisk receives through that channel will be ignored.

Please shed some light here. I was wondering if there’s a trick that works for my scenario… and cleaner (I feel that the technique I mentioned above somewhat hacky). Well, I guess using MeetMe is one of the alternatives. But I’m not very sure about it… I need something more lightweight.

Best regards and thanks in advance,
Steve

LIMIT_WARNING_FILE

see http://www.voip-info.org/wiki-Asterisk+cmd+Dial

Thank you. I think that will work.

I don’t see a similar option for meetme conferences.
How could I add time limits and “minutes left” reminders in a meetme conference?