Asterisk. This time, as a background music broadcasting system with the possibility of emergency notification
Good afternoon, dear residents of the Asterisk hub.
I don’t know about you, but lately I’m not interested in using Asterisk as a standard PBX. ')
In a previous post, Asterisk performed the duties of a security guard in a parking lot. This time, Asterisk, in my configuration, played the background music in the shopping pavilion and in the event of an emergency situation (or, if necessary, to make some kind of announcement) acted as a warning system.
Details under the cut. A couple of weeks ago, I had one interesting task, namely to deploy a system for playing background music, one of the functions of which should be able to “wedge in” to play a sound file, make an announcement, and then continue playing music from the same place.
Having quickly looked at the existing “box” solutions in Google, I realized that this is not exactly what I want. I was offered either professional warning systems (for example, for stadiums), or analog devices, which are certainly reliable, but absolutely not customizable.
Were also reviewed existing devices SIP-alert. Here it is already more interesting: they register on Asterisk as extensions, know how to broadcast multicast, know how to prioritize different sound streams. In Russia, you can find the IP-SIP dynamics of Cyberdata , which were discussed in great detail in this topic. The speakers have a new firmware, the interface is a little refreshed. Having the opportunity to "play around" with this device, it was a sin not to use it :)
So let's get started.
Of course, we will not describe the installation of Asterisk: the network is full of quality manuals. The only thing I’ll add is: docker-compose with asterisk, mysql, php-apache, cdr-viewer has already done for a long time, which makes asterisk almost instantaneous. I plan to describe it in the next topic).
Create a couple of extensions on Asterisk (by default /etc/asterisk/sip.conf):
We write the simplest Asterisk dialplan for tests (by default /etc/asterisk/extensions.conf):
Hidden text
exten => _XXX,1,NoOp(Testing calls to speakers. Dialing ${EXTEN} from ${CALLERID}) same => n,Page(SIP/${EXTEN},qA(hello-world)) same => n,Hangup()
Go to the speaker setup.
We find it in our local network (by default, the device is configured for dhcp):
Configure sip extension (to login to the speaker login / default password admin / admin):
The only inconvenience is that after each operation the speaker must be sent to a reboot, which takes as much as a full minute.
And set up a multicast:
Notice the caption: “SIP calls are considered priority 4.5. Priority 9 is the highest and 0 is the lowest. »In order for a multicast to be interrupted when a call is made to a speaker, multicast settings must take priority 4 and below.
Now we set up a multicast broadcast on the asterisk server. I used the ffmpeg utility.
Install:
sudo apt-get install ffmpeg
We start broadcasting (I took a playlist from vocaltrance.fm (not an ad), of course, you can choose any):
In addition to the obvious advantages, this implementation variant has one big disadvantage, namely the price, which for this dynamics is about $ 400 dollars per piece.
To lower the cost of the system, I decided to use regular speakers (I had
like these ones
and raspberry pi . (The cost of the dynamics and raspberry was ~ $ 50).
So let's get started.
Install on raspberry raspbx distribution, which is a ready-made freepbx image for ARM architecture. (You will need a 4Gb flash drive for installation.)
Installation is trivial: download, take a suitable flash drive, unmount the partition, write the image in dd:
On the "main" Asterisk we create the same trunk, just point it to ip raspberry.
Calls to raspberry will be sent to chan_alsa (module load chan_alsa.so, if not loaded by default).
To play music, use omxplayer (sudo apt-get -y install omxplayer).
To make calls interrupt music playback, let's write a simple dialplan:
Hidden text
[speakers] exten => s,1,System(killall /usr/bin/omxplayer.bin) same => n,Wait(2) same => n,Dial(console/sdp) same => n,Hangup() exten => h,1,System(omxplayer -o local rtp://@236.0.0.1:2000)
To call from the “head” Asterisk, add to the initial dialplan:
exten => 1000.1, Dial (SIP / rasp / s, 60, Tt) same => n, hangup ()
And enjoy the result :)
Conclusion
As a result, we have a completely working background music / broadcasting system, controlled by Asterisk, with several options for terminal devices. Options for the use of other devices are welcome in the comments. Thanks for attention.