Both Oz and I are big fans of Club 977, in fact I’ll often have it on in the study when she has it on downstairs on the Xbox when she’s doing stuff. Needless to say, it was bugging the bejesus out of me knowing that I could be using up to two or three times the bandwidth needed to listen to the same station. I started to work my way around this by setting up an Icecast2 relay, but found that the relay ran regardless of whether anyone was using it. Not an ideal solution, as giving up 128k of bandwidth on a permanent basis per stream isn’t really an option. I then stumbled across the excellent Shoutcast Proxy which aside from a few minor flaws seems to do the trick.
Download shoutcast proxy from http://www.vanheusde...shoutcastproxy/ and save it somewhere. Untar it then cd into the directory you un-tarred it to. Then as root type the following:
mercury:~/scproxy/scproxy-0.6# make install
g++ -O2 -Wall -c -o scp.o scp.cpp
scp.cpp: In function `int connect_to_shoutcast_server(char *, int *, int *, char **)':
scp.cpp:346: warning: comparison between signed and unsigned
scp.cpp: In function `int client_handshake(int, int)':
scp.cpp:450: warning: comparison between signed and unsigned
g++ -O2 -Wall -c -o access.o access.cpp
g++ -O2 -Wall -c -o utils.o utils.c
g++ -O2 -Wall -c -o error.o error.c
g++ -g -Wall -W scp.o access.o utils.o error.o -o scproxy
cp scproxy /usr/local/bin
If you don’t have a /usr/local/etc directory, then mkdir /usr/local/etc
Open up /usr/local/etc/scproxy.conf in your favourite text editor and enter the following:
max_n_clients_per_proxy=5
proxy=http://64.236.34.97:80/stream/1040 192.168.0.2 8000
The max_n_clients_per_proxy setting is simply a way of limiting the number of concurrent connections. As this is for a home network, you’re unlikely to have more than 5 on the go at any one time although you might want to adjust this to suit.
The proxy setting is the interesting one. You specify a url from the .pls file that winamp/itunes etc. uses. To go back to our Club 977 80s channel example, if you open up the .pls file exported on shoutcast.com you should see the following:
[playlist]
numberofentries=5
File1=http://64.236.34.97:80/stream/1040
Title1=(#1 - 807/18970) CLUB 977 The 80s Channel
Length1=-1
File2=http://64.236.34.196:80/stream/1040
Title2=(#2 - 811/18614) CLUB 977 The 80s Channel
Length2=-1
File3=http://64.236.34.4:80/stream/1040
Title3=(#3 - 769/17590) CLUB 977 The 80s Channel
Length3=-1
File4=http://64.236.34.67:80/stream/1040
Title4=(#4 - 1497/18716) CLUB 977 The 80s Channel
Length4=-1
File5=http://205.188.234.66:8010
Title5=(#5 - 20/20) CLUB 977 The 80s Channel
Length5=-1
Version=2
All we’ve done here is take the File1 entry and pasted it into our config file. The IP address is the IP address of the server running scproxy, in my case 192.168.0.2 and the last figure is the port to listen on – in this case port 8000. You can have multiple proxy lines in the config. My scproxy.conf is shown below:
max_n_clients_per_proxy=5
#CLUB 977 The 80s Channel
proxy=http://64.236.34.97:80/stream/1040 192.168.0.2 8000
#CLUB 977 The Hitz Channel
proxy=http://64.236.34.4:80/stream/1074 192.168.0.2 8001
#Groove Salad: a nicely chilled plate of ambient beats and grooves. [SomaFM]
proxy=http://64.236.34.97:80/stream/1018 192.168.0.2 8002
#Dreamscape Movement [from glowdot.com]
proxy=http://216.144.224.194:8800 192.168.0.2 8003
When you enter these in, scproxy will have a hissy fit. Why? Because it can’t parse comments, that’s why. To be fair, I can’t parse comments either so I’ve put in a quick and dirty hack to let us comment where we are. Open up scp.cpp in the source and find the following lines:
for(;

{
char *i_is, *cmd, *par = NULL, *upar = NULL;
char *line = read_line(fh);
if (!line)
break;
After these lines, enter the following:
if (strchr(line, '#'))
continue;
Now save the changes, make clean and make install. You should now find configuration comments work fine as long as they’re on a separate line. Now it’s time to test the thing. Change to a non-root user and type the following:
steve@mercury:~$ scproxy
scproxy v0.6, © 2003 by folkert@vanheusden.com
Starting proxy for http://64.236.34.97:80/stream/1040, listening on 192.168.0.2:8000
Starting proxy for http://64.236.34.4:80/stream/1074, listening on 192.168.0.2:8001
Starting proxy for http://64.236.34.97:80/stream/1018, listening on 192.168.0.2:8002
Starting proxy for http://216.144.224.194:8800, listening on 192.168.0.2:8003
Now in iTunes, press ctrl-u to bring up the stream dialog and enter http://192.168.0.2:8000 – replacing my address with yours. Do the same for your other links.
If the audio starts getting choppy, or desyncs then try the following (in linux, other OSes are on your own, sorry):
mercury:~/scproxy/scproxy-0.6# echo 131072 131072 131072 > /proc/sys/net/ipv4/tcp_wmem
One thing I have noticed is that scproxy works better on some streams than others. In particular Club 977 works fine but I find that gloworm.com doesn’t seem to work so I’m having to fall back to an Icecast2 relay which I have to manually start and stop. Fine for me, but not fine for the S.O. (or for launching from the xbox for that matter).
I have tried relaying video from Winamp’s Shoutcast TV library through this but so far have only been able to get the audio output in Winamp. Ideally I’d like to be able to stream Internet TV streams (which go to the Xbox) from a centralised resource internally. Still, at least now I know that we won’t end up losing 256 k/bits on Saturday afternoons, and I’m saving slots on Club 977 that can now go to someone else.
Despues lo tradusco, pero para el que le gusta el tema del streaming sabrá entender... lo otro, el nuevo shoutcast trae esta opcion pero está aun en fase beta..