icecast

Introduction

shout - encoder/streamer
MP3 ストリームを送出する. 曲目(playlist)などの制御はこのプログラムで行う. icecast は shout などのエンコーダからうけとったストリームを MP3 プレーヤ に渡しているにすぎない.
icecast - server
MP3 プレーヤからのリクエストに応えて, encoder からうけとった MP3 ストリームを流す.
MP3 player - client
icecast からうけとった MP3 ストリームを再生するエンティティ.

Making DNS resource record

必須ではないが, icecast サーバに覚えやすい名前をつけておく. ここでは icecast という名前の CNAME レコードを作成した.

Launching icecast server

icecast サーバの設定ファイル icecast.conf を必要に応じて変更する. コマンド・ラインでも変えられるが, 動的に変更する必要のない設定は ここですればいいだろう.
% diff icecast.conf.dist icecast.conf
4,5c4,5
< location Monkeyland Virginia
< rp_email monkey@apan.com
---
> location Tokyo, Japan
> rp_email dxy@optix.org
8,10c8,10
< max_clients 1000
< max_sources 10
< max_admins 5
---
> max_clients 100
> max_sources 5
> max_admins 3
14,16c14,16
< encoder_password letmein
< admin_password breakin
< oper_password lalala
---
> encoder_password something
> admin_password something
> oper_password something
39c39
< server_name laika.linux.tm
---
> server_name icecast.optix.org
46c46
< console_mode 0
---
> console_mode 3
65c65
< alias radiofri http://195.7.65.207:6903
---
> #alias radiofri http://195.7.65.207:6903

# mkdir /usr/local/icecast
# chown dxy:user 
# mkdir /usr/local/icecast/shout
# chown dxy:user

shout などのエンコーダが icecast サーバに MP3 を流し込むには encoder_password に設定されたパスワードを指定しなければならない. つまり, encoder_password を使って, 正規のエンコーダであることを認証する. (認証というにはあまりにプリミティブだが.)

configure の際, --with-libwrapオプションを指定している場合, tcp_wrappers を使ったアクセス・コントロールが可能. (cf. doc/FAQ Q.14)
/etc/hosts.deny
icecast: ALL
/etc/hosts.allow
129.158.34.
% cd /usr/local/icecast
% /usr/local/icecast/icecast 
[03/Jul/1999:12:25:08] DEBUG: Checking current directory writabilty...
Icecast Version 1.3.0 Starting...
Icecast comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of Icecast under the terms of the
GNU General Public License.
For more information about these matters, see the file named COPYING.

[03/Jul/1999:12:25:09] Icecast Version 1.3.0 Starting..
[03/Jul/1999:12:25:09] Trying to fork
[03/Jul/1999:12:25:09] Detached (pid: 8018)
icecast.conf で指定したファイルにログが書き込まれる. この例では /usr/local/icecast/icecast.log および /usr/local/icecast/stats.log になる.

Pushing MP3 stream to icecast server

次に, エンコーダ から icecast サーバに MP3 ストリームを送り込まなければ ならない. ~/.shoutrc ~/.shout/ playlist shout の設定は -S オプションで確認できる.
% shout -S
option  requires an argument
Compile time options:
        Won't die on small errors
Defaults:
        Password: itsme
        Name: Optix Net Radio
        Genre: Original
        URL: http://icecast.optix.org/
        Shout directory: /usr/local/icecast/shout
        DJ Program: /usr/local/bin/im_the_dj -with -lots -of -cool -options
        Config file: .shoutrc
        Port: 8000
        Bitrate: 128000
Current settings:
        Bitrate autodetection: on
        Port to connect to: 8000
        Shuffle playlist: off
        Loop forever: on
        Verbose mode: off
        Autocorrection of transfer bitrate: on
        Truncate playlist: on
        Use cue file: yes
        Update cue file: yes
        Use DJ program: no
        Public x-audio flag: off
        Default bitrate: 128000
        Configfile: /home/dxy/.shoutrc
        Internal playlist: /usr/local/icecast/shout/shout.playlist
        Cue file: 
        Logfile: 
        Password: something
        DJ Program: /usr/local/bin/im_the_dj -with -lots -of -cool -options
        URL: http://icecast.optix.org/
        Genre: Original
        Name: Optix Net Radio
% shout icecast.optix.org

Listening to MP3 stream

いよいよ, MP3 を聞いてみる.
% mpg123 http://icecast.optix.org:8000
High Performance MPEG 1.0/2.0 Audio Player for Layer 1, 2 and 3.
Version 0.59k (1997/07/13). Written and copyrights by Michael Hipp.
Uses code from various people. See 'README' for more!
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!

Directory: http://
Playing MPEG stream from icecast.optix.org:8000 ...
MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo
mpg123: Can't rewind stream by 1363 bits!
mpg123: Can't rewind stream by 652 bits!
Illegal Audio-MPEG-Header 0x00000000 at offset 0xfffffffb.
Skipped 8204 bytes in input.