Play audio file on channel that is in ConfBridge

Hello - we have a situation where our users connect via computer or phone to an extension in our dialplan.

That extension simply does an Answer, then uses ConfBridge to place them into a conference.

We have the Asterisk Manager Interface hooked up in our code, and we send messages like ConfBridgeMute, etc. and that works great.

We have need of playing audio files to users that are connected and are in ConfBridge.

A great example of this is an audio file that says “You have been muted by the conference leader” (we added an admin level mute into our app). Or if the user on the phone hits *51 to unmute, but we detect that they are “admin muted” we want to play an audio file that says “Sorry, you can’t unmute because the conference leader has muted you”.

I’ve been trying various things but no luck so far. It appears that AGI will be the best bet, but I think I’m not understanding a key component of this.

I attempted to added Async AGI support to the channels like this (which is apparently all wrong haha)

exten => 1,1,AGI(agi:async)
same => n,Answer
same => n,ConfBridge( with all its params )
same => n,Hangup

I was hoping that would enable async agi on the channel that gets established and then I could issue commands via AGI to play the sound whenever my app decides it should.

However I notice than when AGI(agi:async) is called in the dial plan, execution of the remaining priorities in the extension doesn’t happen. It seems as if that dial plan cmd puts the extension into listen mode… so my user never gets into ConfBridge.

This makes it pretty obvious I don’t quite understand AGI.

In a nutshell… I want users coming in via my dialplan and getting to ConfBridge. Then whenever I want, using AMI from my own application… I like to be able to play an audio file on any of the existing channels that are on the call.

Any thoughts to get me back on the right track?

1 Like

Your best approach for implementing something like this will be to use ChanSpy. Using ChanSpy, you could use a Local channel to play the audio as a whisper directly to a channel while they are in the Conference. Something like this:

[default]

exten => play_to_participant,1,NoOp()
 same => n,ChanSpy(${CHANNEL_TO_PLAY_ON},w)
 same => n,Hangup()

You could then Originate a Local channel to the play_to_participant extension, with the other end of the Local channel having the Playback application invoked on it with the sound file that should be played. When Originating, you can specify the channel name in the channel variable CHANNEL_TO_PLAY_ON.

1 Like

Good morning. First - a HUGE thanks for setting me on the right track. The response was extremely detailed and very helpful. I’ve made progress and feel I’m much closer but still no luck getting the audio file to play.

Here’s what I’ve done:

In the CLI, issued module load app_chanspy.so and the module successfully loads.

In extensions.conf, I added this:

[stoneware]
exten => whisper,1,Answer()
same => n,Verbose(Whisper to: ${CHANNEL_TO_PLAY_ON})
same => n,ChanSpy(${CHANNEL_TO_PLAY_ON},w)
same => n,Verbose(This line never shows up and the sound file never plays)
same => n,Hangup()

I connect to the call like usual (and enter ConfBridge) and then have my application issue the following command via AMI:

{
“Action”:“Originate”,
“Channel”:“Local/whisper@stoneware”,
“Application”:“Playback”,
“Data”:“indiana”,
“Variable”:“CHANNEL_TO_PLAY_ON=SIP/52.11.111.111-000002ab”
}
(note: I did manually change my IP for this post to keep mine private)

When the Originate cmd runs, in the Asterisk CLI I see the following output:

Whisper to: SIP/52.11.111.111-000002ab

So this Verbose output shows the channel variable with the channel is being passed correctly and that I am getting to that new whisper extension.

It seems like the extension gets to the ChanSpy line and nothing happens. The sound file does not play. I never end up at the second Verbose line (maybe I’m not supposed to?).

Makes me think maybe my arguments for ChanSpy aren’t correct? Is there a way to pull up debug for ChanSpy to help track this down?

When my users first connect, I put them in a conference with ConfBridge. Would this audio file still be able to get through even while they are in ConfBridge?

Thanks in advance - the help here has been wonderful!!

matt

Interestingly enough… changing my ChanSpy line in the dialplan to this works:

same => n,ChanSpy(${CHANNEL_TO_PLAY_ON},qw)

If I do it with just the w option, then nothing happens… no CLI output from ChanSpy or anything.

However if I add the q … CLI shows:

[2016-08-10 17:29:52] NOTICE[17304][C-000000c0]: app_chanspy.c:501 start_spying: Attaching Local/whisper@stoneware-0000009e;2 to SIP/52.11.111.111-0000000d

and the sound file plays as expected.

So looks like I’m good to go… thanks again for the excellent help and advice yesterday. That really got me moving!

1 Like

Glad to hear it (and glad that you found that the q option - for some reason - made the whispering start!)

1 Like

I just tested the above solution and it works like a charm, the q option make the trick when removing this option it keep stuck after play the spied extension digits.

I made an small code in PHP in order to be able to pass the channel name and the audio file name to be play through POST or GET variables .

The same task can be completed using ARI but channel need to be bridged to the Stasis() application
any way this a pretty cool script

curl -v -u asterisk:asterisk -X POST “http://localhost:8088/ari/channels/1456957509.267/play?media=sound:/var/lib/asterisk/sounds/en/hello-world

2 Likes