I have installed Asterisk and FreePBX on a server. I have set up some extensions for testing and I have configured voicemail for these. I have discovered that voice mail files gets stored in /var/spool/asterisk/voicemail/default/(EXTENSION)/tmp/(TMPFILE).wav
and that they are later moved to /var/spool/asterisk/voicemail/default/(EXTENSION)/INBOX/msg####.wav
I want to stream the voice data to another server in real time so that the server can start processing of the data. That is I want to start streaming the data as soon as a call is received by Asterisk and I do not want to wait for the hang up before sending the sound.
I am looking for how to hook into Asterisk to get hold of the voice data. I have a few ideas so far:
1) Regularly check the /tmp directories for new files and start reading them as soon as they are available. But the file names are random and I also want to find out who is calling for example. Seem like a dead end. Files might also get stuck if I read them while Asterisk tries to move them?
2) Maybe I could write a plugin for Asterisk that can pick up the files in the right step of the process. If so, what do I need to write such a plugin and how can I configure it to get access to the voice data as soon as the voice mail module picks up the phone?
You can use EAGI program which able get sound from channel #3.
http://www.voip-info.org/wiki/view/Asterisk+EAGI
You also can do c/c++ app for asterisk which will do streamming(see source code in apps/ folder for examples)