[asterisk-users] How to run a remote PHP script and still have access to audio stream?

David Backeberg dbackeberg at gmail.com
Sun Feb 7 21:18:33 CST 2010


On Sun, Feb 7, 2010 at 9:54 PM, Leo Burd <leob at media.mit.edu> wrote:
> Hello there,
>
> I'm trying to figure out how to run a PHP script on a remote machine and
> still have access to the audio stream associated with the call.
>
> Ideally, I'd love to play/record audio files directly from/to the remote
> server without having to copy them back and forth to the Asterisk
> server.  What is the best way to do this?
>
> Is it possible to combine EAGI with FastAGI in PHP?

You don't specify how often / what proportion of the recordings need
to be on a remote machine versus on the asterisk server. So you have
two main things going on:

1) recordings, with a side order of distributing those to another machine
2) remote shell scripting

First, the recordings can be done directly on a channel where the call
is taking place. If this is one call, that's not so bad, but there get
to be I/O contention issues when you try to record 'a lot' of calls
simultaneously. Some people endorse working around that by writing
recordings to a ramdisk, and then occasionally flushing those off to a
real hard disk.

You may prefer an alternate approach, which is that taken by
commercial recording solutions. Oreka (which can be grabbed from
sourceforge), and pretty much every commercial voip recording solution
I've investigated, works by having you use libpcap (used in
Ethereal/Wireshark) to watch ethernet device(s) where voip calls are
taking place, grab the SIP headers that set up the RTP stream, and
then write those recordings to disk on a dedicated recordings server.
This requires explicit ethernet support by doing things like port
mirroring, or using an old-school hub, etc. This has an advantage for
you of providing a way to do recording directly on a machine that is
NOT the asterisk server. No copying required as the recording is
already where you want it.

Second, the remote shell isn't so hard. ssh with keys, problem solved.
You can do that directly from the asterisk dialplan using the System()
command. This let's you tie the remote shell directly to a given call,
where you can tune arguments accordingly.

Of course, you can also do #1 with scripting and remote shell, or
rsync with keys. If you don't need 'a lot' of simultaneous channels
recorded, this may be more straightforward. You only have to learn
asterisk, rather than asterisk and Oreka.



More information about the asterisk-users mailing list