AGI STREAM FILE not working?

Home » Asterisk Users » AGI STREAM FILE not working?
Asterisk Users 3 Comments

Hello,
using 1.8.4. using a very simple local AGI script in bash which has only one
line in it:

echo -e ‘STREAM FILE welcome 123 n’

dialplan:
exten => 5150,1,Answer()
same => n,Set(CHANNEL(language)=en_AU)
same => n,AGI(testagi.sh)
same => n,Hangup

console output:

3 thoughts on - AGI STREAM FILE not working?

  • be written in C# running on a remote system. I was just doing a quick PoC to
    figure out how would I use the stream file function to actually read audio
    files over the network and even though I used to teach Perl 10+ yrs ago, I
    don’t do much scripting/coding for a long time, so the brain doesn’t think
    like a coder anymore. Just needed to try various tricks w.r.t to how can I
    dynamically bring over audio files from another server, convert them to the
    codec of my channel and then play/store them locally (cache if you will) but
    wanted to learn the right way to do it with a local file first before I
    tried something fancier. Guess I’ll continue playing with the php script
    that worked and once I figure the process out, will give it to the C# dev to
    implement. Can’t believe I wasted more than 2-3 hrs on this 🙁

    BTW, I’d raised that a while ago, and got no conclusive response. How / what
    is the best way to stream audio files (not MOH/Internet Radio/TV and what
    not) inside a dialplan using AGI without comprising performance/adding
    latency too much. no examples of shout/ICE I could find that show how to do
    that simply by allowing me to run a web server remotely and use a shoutcast
    module to play the audio right into the channel

    ideas?

  • In article ,
    A E [Gmail] wrote:

    Firstly, you need to check that you can successfully play files
    outside of the AGI environment. Replace the AGI command with:

    same => n,Playback(welcome)

    If that doesn’t work, the problem is nothing to do with AGI.

    However, I think what else is happening is that your AGI script is
    sending the STREAM FILE command and then immediately exiting. This goes
    back to the dialplan and executes a hangup when only a tiny fraction of
    the welcome file has been played. You could test this theory in two
    different ways, as I’m not sure whether it’s the exiting of the AGI or
    the subsequent hangup that is aborting the playback.

    a) Put a “sleep 5” in your agitest.sh after the echo. As others have
    said, you should really use a proper library that reads responses to
    AGI commands, but for testing, a sleep will keep the AGI script alive
    while the message plays.

    b) Put a “same => n,Wait(5)” after the AGI command. If the AGI leaves
    the message playing, this would give it some time to play before you
    hang up the line.

    Hope this helps!

    Tony