Leo Burd
2010-Feb-08 02:54 UTC
[asterisk-users] How to run a remote PHP script and still have access to audio stream?
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? Thanks in advance, Leo
Ben Dinnerville
2010-Feb-08 03:13 UTC
[asterisk-users] How to run a remote PHP script and still have access to audio stream?
Leo Burd 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? > > Thanks in advance, > > Leo > >There is the EAGI protocol that will allow this but the easiest way I find to do this sort of thing is to have a shared file system between the app / web server and the asterisk server(s). We run a clustered setup with 12 asterisk systems and a clustered jboss environment with a NFS mount shared between all the systems. For applications such as call recording asterisk does the monitor into the NSF mounted share / directory which is also visible on the jboss servers (mainly for permission checks / security etc) and the web server (for download etc). As long as you have a scheme that ensures you do not have duplicate file names (which can be controlled by a central database and via your php script) then you will not have any issues. There are a number of other file system alternatives out there that will achieve the same thing but NFS seems to be proven and stable and we have not any issues with it to date. Your php script can then be a simple AGI / FastAGI that simply executes a Playback(path/to/nfs/directory/file) - you can also incorporate things like checking if the file exists in your PHP script and implementing access restrictions etc. We also share our sounds directory between systems this way so that all our sounds only have to reside in one place but are visible across all the systems. Cheers, Ben
David Backeberg
2010-Feb-08 03:18 UTC
[asterisk-users] How to run a remote PHP script and still have access to audio stream?
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.