[Asterisk-Dev] Perl AGI + MySql Audio

Darren Sessions dsessions at ionosphere.net
Tue Nov 23 12:49:00 MST 2004


I know there is a patch you can get for MPG123 that lets it query a MySQL
database for audio files to play.

Is there a way to have Asterisks internal WAV49 player grab the binary data
(of an audio file) from a blog field and play it without writing the audio
file to disk?

Right now the way I do it, is once an audio file is created (lets say by
using record), an AGI script reads the contents of the wav49 file into a
variable and then dumps the contents of that variable into an blob field via
an sql insert.

While this makes the AGI audio dynamic, it hammers the local hard drive.

Any ideas? I think the concept is very sound (no pun intended), but my
experience with C is very limited and Perl AGI only lets you do so much.

I realize you can't "stream" wav files, so it'd need to load the audio bin
contents into memory, then spit it out to whatever caller.

Ideally, I think it would be nice to have something like this:

/etc/asterisk/dbsound.conf:
[database]
Type=mysql
Server=dbserver.local.domain
Username=whatever
Password=whatever
Database=asterisk


Perl AGI command (or could be regular AGI command and just done in Perl with
print)

$AGI->db_stream_file("<table>","<whattoselect>","<option1>","<option1
value>","<option2>","<option2 equals");

$AGI->db_stream_file("sounds","audioprompt","custnum","=15551112222","custst
atus","=1");

SELECT audioprompt from sounds where custnum="15551112222 AND custstatus="1"

Like wise, you'd want that same capability with the get_data AGI.

$rc = $AGI->db_getdata("maxwait
duration","dtmfdigits","<table>","<whattoselect>","<option1>","<option1
value>","<option2>","<option2 equals>");

Anyways - just a thought... :)

Thanks,

 - Darren





More information about the asterisk-dev mailing list