Interrupt playback on external event with custom file

Hello

I’d like to play an external file, (generated by a 3rd party app, and whose filename & content are variable), and be able to continue the dialplan, to monitor external events.

  • I’ve thought of using playback/background, which accept a variable file name as parameter, but the audio can’t be interrupted by something else than DTMF

  • I’ve though of using MOH, but I dont see how to play a custom file name (like myaudio.pid.1234.sln16, then myaudio.pid.2345.sln16, etc…)

Any suggestion on these ideas, or how to accomplish my goal ?
tks
J.

Background always listens for DTMF when it’s playing a file.

Thanks - unfortunately, I am using an AGI and waiting for a network event, so DTMF waiting is not an option

I can’t offer any advice with AGI sorry, I’m a dialplan guy.

Code your external network event detector as another thread in your AGI. When the event is detected, set a channel variable and exit. In the dialplan, if the channel variable has the expected value, you know the event ended the AGI.

Or…

If your detector is a separate process, set a signal handler in your AGI. When the event is detected, the detector can signal (kill) the AGI with the configured signal. In your AGI’s signal handler, set the channel variable and exit.

Thinking a little bit longer, setting a channel variable while playing an audio file may violate the AGI protocol. Maybe you could set the expected value before playing the audio and then clear it after the playback completes normally.

thanks for these interesting suggestions.

If I get you right, you’re suggesting to fork the STREAM FILE into a subprocess, that I can kill when I want ? Im’ curious to see how stdin/stdout follow the sub-process

I’ll give that a try,

Thank you

I was suggesting ‘pthreads,’ but ‘fork’ may work as well.

The important thing is understanding that the AGI protocol is a request / response kind of thing. If you issue a request without retrieving the previous response, all hell can break loose. This can also be induced if your debugging technique consists of peppering your source with ‘echo or printf’ statements.

many thanks, I’ll try pthreads - and yes, I’ve seen hell breaking loose on my head many times already !!! :slight_smile: