📜 ⬆️ ⬇️

Deploying a radio station to GNU / Linux. Part I

First of all, I want to say that I read a lot of topics on Habré about the deployment of the radio, but none gave me comprehensive information.
I decided to do everything myself. This is not some kind of project or startup, but just just4fun. It may seem useful to you.
So, I used only free software in the deployment of a radio stream, so that users of window $ and ma o $ can no longer read;). Although no, still read, maybe this will open up GNU / Linux for you from the new side.



What I need from the broadcast stream:

')
Starting positions

Studio microphone, 1 pc
64 MB USB Drive


First of all, the stock firmware of the router was demolished, and in its place OpenWRT rose from the trunk. I will not talk about how to roll OpenWRT, it can be read, for example, here .
Let me just say that you need to transfer the FS root of the router to an external USB flash drive using a block-extroot, because the built-in memory is only 4 megabytes, and also include the useradd program in the buildbox build parameters.

So, the firmware is installed, the Internet works, SSH too, we go over SSH to our router and begin to understand.

I. Icecast
The question is, “what to use as a stream server?” I did not have. In addition, it is quite stable and lightweight.

Install icecast on the router:
opkg update opkg install icecast 

Why on the router? Of course, the computer is turned off at night, and 24/7 mode is planned.

I will use Icecast in the sandbox, so I’ll create an icecast user.
The icecast configuration file is in XML format.
 #   useradd   busybox,  : opkg install shadow-useradd useradd icecast -g nogroup cp /etc/icecast.xml /usr/share/icecast # vi /usr/share/icecast/icecast.xml #  nano 


In truth, I generally used kate (kio-sftp) to edit this config, however, it does not matter.

The config is well-documented. For security, we need to set the chroot to one, but also the changeowner in our user. Also note that paths in this case should be relative to basedir, but with a slash at the beginning. And icecast does not like to create the paths itself.
As an example, here is my config.

In my case, you need to create log files for the icecast user:
 cd /usr/share/icecast mkdir log cd log touch {error,access}.log cd - chown -R icecast log #  icecast -b -c icecast.xml 


The web interface is available at 192.168.1.1 : 8000

By the way, add the line
icecast -b -c /usr/share/icecast/icecast.xml
in /etc/rc.local, in order to start the icecast when loading the router.

II: Fallback stream

I will not be able to work 24 hours a day, so I need a fallback stream that will replace the main one at the same URL, in the case of the first offline.
You will find the final version of the fallback stream setup in the second part, but for now I will use MPD for this.

There is nothing difficult in setting up MPD for icecast, now it is being broadcast by me in parallel to ALSA and IceCast. Just install mpd and open ~ / .mpdconf, both ALSA and Icecast will be configured there, you just need to uncomment and tweak the settings for you.

Suppose our main stream is / live , and the fallback is /mpd.ogg
Then add to icecast.xml:
  <mount> <mount-name>/live</mount-name> <fallback-mount>/mpd.ogg</fallback-mount> <fallback-override>1</fallback-override> <fallback-when-full>1</fallback-when-full> </mount> 


Restart icecast (killall is our all), and try to open the address
192.168.1.1 : 8000 / live in the player. Works? Let's go further.

III: We climb to the Internet

It's time to set up a firewall to accept connections from the outside. If you do not have a “white” IP, use dyndns.org and refer to the openwrt documentation.

In / etc / config / firewall, add the following lines:
 #ICECAST config rule option src wan option dest_port 8000 option target ACCEPT option proto tcp 

and restart the firewall:
/etc/init.d/firewall restart
By the way, for me, the best way to check is not isup.me, but a mobile phone :). In general, go further

IV: Client Setup
Client machine, i.e. The desktop is also Linux, as I said at the beginning of the post.
To control the radio, we will use the idjc free, open, and most importantly, non-portable (Linux only) program. Let me quote a review from SourceForge:

In the past, I have streamed on Windows XP with both SAM and ShoutCast. It’s a live streaming experience in my life. Over six hours connected preformed flawlessly. Kudos to those who put this together.


It was not in Gentoo portage, but, for example, it is in Ubuntu. I compiled a program from source. I also needed to add the “jack” USE flag in /etc/make.conf to install it and integrate with alsa.

To work, the program requires the JACK sound server (when people ask me what are the outstanding programs in Linux, but not in m $, I answer: Rosegarden, Cinelerra, JACK, Ardour, MythTV ! Well, idjc).
Other dependencies: GTK +, pygtk and the presence of a sound card with headphones and a microphone.

IV.1 Jack Setup
Jack works in realtime mode, so it needs to be given where it goes.
Add yourself to the audio group, then add to /etc/security.conf:
 @audio - rtprio 99 @audio - memlock unlimited @audio - nice -10 

and check it out.
You also need to create a configuration file, for example:
echo "/usr/bin/jackd -d -r 44100 -p 256" > ~/.jackdrc
JACK, back-end' ( ):
jackd -d
.. alsa pulse

IV.2 idjc
idjc , . ( ):
image

2 , ( ), ( ), , (), :
4 6 Icecast/Shoutcast MP3 OGG () FLAC
. Preferences Jingles , Output:

image

, , .
, .

, Format ., .. , .
, IRC.

V. Skype
skype ☻ alsa-plugins. Gentoo:
emerge alsa-plugins # USE="jack"

~/.asoundrc :
# VoIP plugin for the IDJC default profile. pcm.idjcvoip { type plug slave.pcm { type jack playback_ports { 0 idjc-mx_default:voip_in_l 1 idjc-mx_default:voip_in_r } capture_ports { 0 idjc-mx_default:voip_out_l 1 idjc-mx_default:voip_out_r } } }
.
, idjrc JACK jackd -d alsa ( pulse, ). , qjackctl.

idjcvoip ( , Ekiga ):

image

, , - .

, .
echo "/usr/bin/jackd -d -r 44100 -p 256" > ~/.jackdrc
JACK, back-end' ( ):
jackd -d
.. alsa pulse

IV.2 idjc
idjc , . ( ):
image

2 , ( ), ( ), , (), :
4 6 Icecast/Shoutcast MP3 OGG () FLAC
. Preferences Jingles , Output:

image

, , .
, .

, Format ., .. , .
, IRC.

V. Skype
skype ☻ alsa-plugins. Gentoo:
emerge alsa-plugins # USE="jack"

~/.asoundrc :
# VoIP plugin for the IDJC default profile. pcm.idjcvoip { type plug slave.pcm { type jack playback_ports { 0 idjc-mx_default:voip_in_l 1 idjc-mx_default:voip_in_r } capture_ports { 0 idjc-mx_default:voip_out_l 1 idjc-mx_default:voip_out_r } } }
.
, idjrc JACK jackd -d alsa ( pulse, ). , qjackctl.

idjcvoip ( , Ekiga ):

image

, , - .

, .
   echo "/usr/bin/jackd -d -r 44100 -p 256" > ~/.jackdrc 
JACK, back-end' ( ):
jackd -d
.. alsa pulse

IV.2 idjc
idjc , . ( ):
image

2 , ( ), ( ), , (), :
4 6 Icecast/Shoutcast MP3 OGG () FLAC
. Preferences Jingles , Output:

image

, , .
, .

, Format ., .. , .
, IRC.

V. Skype
skype ☻ alsa-plugins. Gentoo:
emerge alsa-plugins # USE="jack"

~/.asoundrc :
# VoIP plugin for the IDJC default profile. pcm.idjcvoip { type plug slave.pcm { type jack playback_ports { 0 idjc-mx_default:voip_in_l 1 idjc-mx_default:voip_in_r } capture_ports { 0 idjc-mx_default:voip_out_l 1 idjc-mx_default:voip_out_r } } }
.
, idjrc JACK jackd -d alsa ( pulse, ). , qjackctl.

idjcvoip ( , Ekiga ):

image

, , - .

, .
echo "/usr/bin/jackd -d -r 44100 -p 256" > ~/.jackdrc
JACK, back-end' ( ):
jackd -d
.. alsa pulse

IV.2 idjc
idjc , . ( ):
image

2 , ( ), ( ), , (), :
4 6 Icecast/Shoutcast MP3 OGG () FLAC
. Preferences Jingles , Output:

image

, , .
, .

, Format ., .. , .
, IRC.

V. Skype
skype ☻ alsa-plugins. Gentoo:
emerge alsa-plugins # USE="jack"

~/.asoundrc :
# VoIP plugin for the IDJC default profile. pcm.idjcvoip { type plug slave.pcm { type jack playback_ports { 0 idjc-mx_default:voip_in_l 1 idjc-mx_default:voip_in_r } capture_ports { 0 idjc-mx_default:voip_out_l 1 idjc-mx_default:voip_out_r } } }
.
, idjrc JACK jackd -d alsa ( pulse, ). , qjackctl.

idjcvoip ( , Ekiga ):

image

, , - .

, .

Source: https://habr.com/ru/post/146286/


All Articles