Live radio/fm channel connection

Hello,

We are using Asterisk 18.4, working for Disability education.
We are thinking to connect live radio/fm channel , so that users who connected with our system with simple phone , can also take benefit of live radio listening.
pls guide with your suggestions.
thanks

Do you have many stations or just a few? Do you want something basic where people call a number and listen or more complex.

If you want to do something simple I would suggest using MusicOnHold.

musiconhold.conf

[general]
cachertclasses=yes ; use 1 instance of moh class for all users who are using it,
preferchannelclass=no ; Needed so that we use what's set in MusicOnHold() and not the channel default

[default]
mode=files
directory=moh

[jewish_music_stream]
mode=custom
application=/etc/asterisk/moh/jewish_music_stream.sh

jewish_music_stream.sh

#!/bin/bash


/usr/bin/ffmpeg -i http://stream.jewishmusicstream.com:9000 -vn -ar 8000 -ac 1 -f s16le -

echo "[$(date +%F) $(date +%T)] $0" >> /tmp/streams_down #Log downed streams for now. In the future put out an alert
sleep $(( ( RANDOM % 60 )  )) #This is extremley important as if it's not here the repeat will lockup a core on the box

You can then have a dialplan that looks like this.

[from-external]
Exten => s,1,Answer
 same =>   n,MusicOnHold(jewish_music_stream) 

Of course you get a lot more complicated than that. For instance the way I have musichold set up (cachertclasses=yes), asterisk will start pulling the stream on start. If you have 100 stations then your box will be busy. If you set it to no then every time someone calls it will start a new stream (so if 100 people are listening that’s 100 instances of ffmpg running). We have a platform that has about 150+ streams on it. To get around this issue we use Asterisk realtime which only starts the moh thread if there is a call for it. When the call hangs up we have a bash script that waits 3 seconds and see’s if anyone else is listening to this class. If there is the script exits. If not it unregisters the moh class freeing up resources.

1 Like

You could save a couple of nano-seconds with:

printf '[%(%F %T)T] %s\n' -1 "$0"

A Bash ‘built-in’ vs 2 process creations.

Thanks a lot, We will definitely try to implement, Will revert with results.
thanks

I have tried to implement but errors from musiconhold.conf

We want to use 4-5 different channels for radio/fm , so that user can select by pressing 1…2…3

my musiconhold.conf as you suggested.
[general]
cachertclasses=yes ; use 1 instance of moh class for all users who are using it,
preferchannelclass=no ;

[default]
mode=files
directory=moh
;
[jewish_music_stream]
mode=custom
application=/var/lib/asterisk/moh/jewish_music_stream.sh


[root@localhost asterisk]# cat /var/lib/asterisk/moh/jewish_music_stream.sh
#!/bin/bash

#/usr/bin/ffmpeg -i http://stream.jewishmusicstream.com:9000 -vn -ar 8000 -ac 1 -f s16le -
/usr/local/bin/ffmpeg -i Listen to India FM online radio, free internet radio stations -vn -ar 8000 -ac 1 -f s16le -

echo “[$(date +%F) $(date +%T)] $0” >> /tmp/streams_down #Log downed streams for now. In the future put out an alert
sleep $(( ( RANDOM % 60 ) )) #This is extremley important as if it’s not here the repeat will lockup a core on the box

error is
Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:48] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call
[Jul 9 20:22:49] WARNING[42479]: res_musiconhold.c:809 monmp3thread

Please put triple back ticks before and after quotes from logs and configuration files, to stop their being interpreted as mark up.

Although it may indicate a problem, interrupted system call on poll should not normally be treated as an error, and the fact that you get multiple reports suggests it isn’t being treated as an error.

I am facing errors in script, i have shared details, pls see.

Is there any other easy way to listen radio/fm, where users can easily listen music.

tried also but not done
exten => 66661,1,System(/usr/bin/mpg123 -q -r 8000 -f 8192 --mono -s Radio Vividh Bharati (VBS) Online)

You might want to check item 4 in their Terms of Use!

Hello @david551

There are many sites/channel , some are available with news and other information/music. but at this moment we are unable to use same due to settings. We are not working commercially, We are Not for profit trust working for Disability education and others.

I suspect that that would still be considered commercial use, and, in any case it isn’t personal use. You should approach the site. You may need some sort of API key, or they may not have the rights to waive the restriction, and you may need to approach the individual stations.

You may be right , but listening live radio news Govt/private is seems not any offence, This is just for help for those who don’t have smart phones.
Do you find any issue/error in my setup as shared above. pls guide.

Doesn’t matter

The retransmission of FM radio broadcasts for any reason, public or private, is forbidden under both FCC and copyright rules.

To do this legally, you have to seek permission from the station as well as pay copyrights.

The fact you work with vets, the disabled, and are non-profit do not excuse you from this.

I understand legal issue, thanks for sharing more info about radio listening copyright rules.

I still willing to test radio listening. I see in different posts , many people doing same, I followed previous instruction above but not resolved yet.

Hi,
when we use link through shell script .sh file, it is showing warning/notice/error but when we try direct with musiconhold.conf , it seems workable but not playing
/usr/bin/ffmpeg -i http://stream.jewishmusicstream.com:9000 -vn -ar 8000 -ac 1 -f s16le -

music is playing after clicking on play on above web link.

Can we create own music channel in our asterisk server for our users.

Based on his name it seems like he is in India so FCC rules would not apply. I think it’s appropriate to tell people here that there may be legality issues here but it’s not our place to police others.

1 Like

The copyright issues aside, unless your users are listening on a phone, a better application for music playout and streaming is Rivendell http://www.rivendellaudio.org/

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.