PDA

View Full Version : Different music libraries for different clients



Niek Jongerius
2005-08-13, 09:13
Hi all,

There has been some discussion in various threads about offering different
libraries (sets of music files) to different players. For instance, the
SB for Dad should not include the "music" the kids want to hear.

I have hacked together a few scripts that allow me to have a "master"
directory of my music, and run several instances of SlimServer which all
can point to different parts in the music directory.

Beware, this is _not_ a portable solution, it relies heavily on various
Linux-specific stuff.

The solution runs several instances of SlimServer. Each instance listens on
a different IP address. For this to work I had to tweak the server a bit.
The SlimProto listener doesn't have an option to let it run on one specific
IP address (which is available for the HTTP and the CLI ports), so I had to
add that bit (I added a command line option "--protoaddr <IPaddr>").

After this worked, I could use the following recipe to create a SlimServer
instance (these examples use <NR> to create instance number <NR>, and
assume the SlimServer software is installed in /usr/local/slimserver):

- Create an IP alias on loopback: "ifconfig lo:<NR> 10.0.0.<NR>"
- Create a dummy user: "useradd -d /home/slimserver/<NR> slimserver.<NR>"
- Create the homedir: "mkdir -p /home/slimserver/<NR>"
- Set permissions: "chown slimserver.<NR> /home/slimserver/<NR>"
- Start server: "/usr/local/slimserver/slimserver.pl --daemon
--prefsfile /home/slimserver/<NR>/slimserver.conf
--logfile /home/slimserver/<NR>/slimserver.log
--httpaddr 10.0.0.<NR> --cliaddr 10.0.0.<NR> --protoaddr 10.0.0.<NR>

This should get you a slimserver on IP address 10.0.0.<NR> (check with
"netstat -na"). To let a player (SB or SoftSqueeze) access this instance,
you need to do a bit of iptables trickery. To give player with IP address
<PlayerIP> access to SlimServer instance <NR>:

- iptables -t nat -A PREROUTING -s <PlayerIP> -m multiport -p tcp
--destination-ports 3483,9000,9090 -j DNAT --to-destination 10.0.0.<NR>
- iptables -t nat -A PREROUTING -s <PlayerIP> -p udp
--destination-port 3483 -j DNAT --to-destination 10.0.0.<NR>

This will forward incoming requests from that specific player to the new
SlimServer config. All players that use your server will talk to the same
server IP address, so this setup is transparent for the players.

Now set up the music for each SlimServer instance. You could do that for
instance like so (this example assumes the master music library in
/home/music):

- mkdir /home/slimserver/<NR>/music
- cd /home/slimserver/<NR>/music
- ln -s /home/music/Beatles 1.dir
- ln -s /home/music/"Rolling Stones" 2.dir
- ln -s /home/music/Queen/"We will rock you.mp3" 3.mp3
- etc.
- chown -R slimserver.<NR> /home/slimserver/<NR>/music

(Remember to use the correct file extension if you are linking to single
files, otherwise the SS scan will not recognize it as a valid music file.)

Set up a playlists directory as well under /home/slimserver/<NR>, chown
it to slimserver.<NR>. Now start a browser on the SlimServer machine and
point it to http://10.0.0.<NR>:9000, specify the music and playlists,
and away you go. If you want to use the browser on another machine to
configure a specific SlimServer instance, you have to add the iptables
rules for that client as well (and of course point it to the real IP addy
of the SlimServer machine). If necessary, lock down the settings page on
the webserver of SS so the kids cannot alter the music directory.

Now all that is left is to write a simple frontend to automate creating
these SlimServer instances, adding of clients to the SlimServer instances,
managing the symlinks for a SS instance etc. Switching a client to use a
different part of your library should then be a breeze (handy for parties
etc). I leave that part as an exercise to the reader. :-)

Niek.

Marc Sherman
2005-08-13, 09:57
Niek Jongerius wrote:
>
> The solution runs several instances of SlimServer. Each instance
> listens on a different IP address. For this to work I had to tweak
> the server a bit. The SlimProto listener doesn't have an option to
> let it run on one specific IP address (which is available for the
> HTTP and the CLI ports), so I had to add that bit (I added a command
> line option "--protoaddr <IPaddr>").

Patch! Patch!

- Marc

Niek Jongerius
2005-08-13, 10:15
> Patch! Patch!

Yeah, I know. I'm trying to get a version checked out with SVN, but am
having some problems with it (it seems to stall).

Niek.

Niek Jongerius
2005-08-14, 00:51
Hi all,

An update on this:

> The solution runs several instances of SlimServer. Each instance listens
> on a different IP address. For this to work I had to tweak the server a
> bit. The SlimProto listener doesn't have an option to let it run on one
> specific IP address (which is available for the HTTP and the CLI ports),
> so I had to add that bit.

Dean corrected me, this option is already available (--playeraddr). So no
hacks to the SlimServer code are necessary to run several SS copies on
one server.

There are several cool things possible with this (once I have put together
a simple interface to juggle around these instances):

- Offering customized libraries which are part of the master library
(the original intent of this hack).
- Making use of multi-proc machines to drive several players (but you
loose synching up players which use different SS instances).
- Setting up two identical instances so you can let one instance scan
your library while the other keeps driving your music. Once the scan
is done, switch your player(s) to the other instance and presto, new
music available with a minimum of annoyance (works especially well if
you have the multi-CPU machine so one SS instance doesn't hog all the
CPU power). A sort of poor man's threading of SS.

Niek.

mac02109
2005-08-15, 07:05
I think Niek may have posed a solution to a problem
that I've had. I've got slimserver (6.1) running on
an XP machine with about 4K tracks ripped in WMA
lossless format. I serve these to my SB1 and other
computers through a wired home network. I've then
converted these tracks to a variety of lossy formats
for several portable devices under separate
(essentially mirrored) directory structures outside of
my slimserver music folder. That's fine, as I prefer
listening to the lossless tracks while at home, but
now I'd like to be able to listen remotely using
SoftSqueeze, and I don't have the bandwith to stream
the lossless tracks. I take it that there is no
current way access a separate music folder hierarchy
within one instance of slimserver without creating
multiple entries in the database (the "Multiple
Profiles" thread seems to confirm this). But Niek
suggests that there is already a way to run multiple
instances of slimserver to accomplish my objective.
Exactly how do I do this on an XP machine? I'm a
newbie, so I'm not clear how to implement the
--playeraddr option, where to specify the needed
change in ports on the 2nd instance of slimserver,
etc. Thanks for any help you can provide. -Mark

Aaron Zinck
2005-08-15, 09:33
> now I'd like to be able to listen remotely using
> SoftSqueeze, and I don't have the bandwith to stream
> the lossless tracks.


No need to complicate matters with multiple libraries...Slimserver can do
downconversion on-the-fly on a per-client basis. In the web interface go
the player settings for your softsqueeze client, then choose audio, and then
limit the bitrate to whatever your connection can handle. You'll need lame
installed for this to work.