Music Collection Sharing With Rhythmbox

Actually, this title is not very descriptive, as sharing music across the LAN with Rhythmbox takes only one click of the mouse. However, this article intends to provide an overview of what happens behind the scenes after this mouse button has been pressed and how Rhythmbox and Avahi work together in order to make the sharing of music such an easy task.

Some General Info

The traditional way of sharing a collection of audio files across a local home network is by sharing the directory that contains them, so that everybody can access these files. This works well, but I guess it’s time to move on to the next level of music sharing through the Digital Audio Access Protocol (DAAP).

A very interesting article (note: page is down), published on Linux.com, was the motive in order to start reading about DAAP. In brief, this protocol was originally developed by Apple and is implemented in the company’s popular audio player, iTunes. What makes DAAP so important is the fact that it uses ZeroConf, also developed by Apple and originally called Rendezvous, to announce and discover the music shares across the LAN. All this is done automatically, usually requiring zero configuration by the user.

Τhe requirements for using DAAP in order to share your music are:

  1. an implementation of the protocol itself, either in the form of a daemon or have it built-in within a music management application.
  2. an implementation of ZeroConf.

Hopefully, as you might have already read in the linked pages above, there is just enough native linux software that satisfies both of the above requirements. This small article will deal with the Avahi daemon, a promising implementation of ZeroConf, and Rhythmbox, built with DAAP support. These are available OOTB in FC5 and will most probably be included in the upcoming releases of the major Linux distributions, if not already included (this is beyond my knowledge).

How To Share Across The LAN

Rhythmbox, if built with DAAP support, includes a new tab in the preferences panel, called “Sharing“. This is where the user can enable music collection sharing, set a name for the share and even set a password in order to control access.

Having enabled this, when Rhythmbox is started, it uses D-Bus to send a message to the Avahi daemon informing it that the player implements a service based on the DAAP protocol, which gives access to the user’s music collection and can also recognize other users’ music shares. Avahi, after collecting all the needed information about that service, it publishes it as a mDNS/DNS-SD service and makes it available in the local subnet, so that all other workstations are notified about the new available service. All this is accomplished without any user intervention, which makes it very convenient even for unexperienced users.

Even if Rhythmbox does not share its music collection, it, if built with DAAP support, still informs Avahi through D-Bus, that it can recognize other users’ music shares and, eventually, all these available shares are displayed in Rhythmbox’ music sources list. Each of these shares includes the whole music database, which by the way can be searched as if it was the local music collection, plus any playlists. The outcome of all these operations is that all the available music on the local network is viewable and searchable from within Rhythmbox’ user interface!

More Than A Mouse Click

Although enabling the sharing of the music collection in Rhythmbox should be enough, it requires one more step so that other workstations on the LAN can actually read the published music. Actually, this is only required in the case that the workstation which shares the music is protected by a firewall. The fact that this aspect is not even mentioned in the Rhythmbox documentation is, at least, surprising.

So, which port should be open? Hopefully, Rhythmbox’ DAAP service uses the DAAP protocol’s default port:

3689 TCP

Opening this port on the workstation that shares the music is mandatory. A workstation, which is supposed to only read music shares, is not required to have port 3689 open.

But, what about if the service did not use the standard port? How to find information about the available services on the local machine or accross the local network? Read on…

Avahi

As it was previously mentioned, Avahi’s responsibilities, by default, are to publish and announce any local services to the whole subnet (Multicast Server) and also to collect information about other services that are available on the subnet and make it available to the workstation it runs on (Service Discovery). Furthermore, Avahi can publish services that run on workstations on which Avahi is not installed.

The Avahi distribution, among others, includes some utilities in order to assist users in finding information about the available ZeroConf services on the network. A command-line tool (avahi-browse) and a graphical one (avahi-discover) are provided.

You can use avahi-browse like in the example below:

# avahi-browse -a -r -t

Some info about the parameters:
-a : Show all services, regardless of the type.
-r : Resolve the services and provide detailed information about their parameters.
-t : Terminate when an apparently complete list has been printed to stdout.

The information, that the above command provides, includes the port number on which a service is run.

If you like it graphically, you can use the avahi-discover-standalone utility. Run it from a terminal:

# avahi-discover-standalone

Select any of the services that are shown and the service’s information will be displayed.

Final Words

The implementation of the DAAP protocol that is built in Rhythmbox makes it possible to share music with Apple’s music management application, iTunes, which cannot run natively in Linux. Apart from that, a UNIX server implementation of the DAAP protocol, mt-daapd, can be used to share your audio files from a central location. The importance of DAAP is that it makes the synchronization of music across a local network extremely easy.

This small article is also a small introduction to Avahi and to what a user can achieve with it. It seems that I just discovered multicast DNS and automatic service discovery. Well, this is not absolutely true. I just discovered some useful things a user can do with it, so I intend to spend some more time with Avahi and hopefully post some more info about its usage in future articles.

Music Collection Sharing With Rhythmbox by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

5 responses on “Music Collection Sharing With Rhythmbox

  1. Peter Enseleit Permalink →

    Nice article.

    I am looking into ZeroConf as well.

    Apparently, GAIM and GnomeMesseger are also Zeroconf compliant. GAIM previously used only the Howl libraries, but I believe it is now also using Avahi.

    If you have ZeroConf (Avahi) configured on two Linux boxes and connect a cable between them they will automatically be able to communicate with each other. Hence Zero Configuration Networking.

    I have not played with this yet, but will be looking at it soon.

  2. George Notaras Post authorPermalink →

    I started playing with Avahi lately too. It seems that, apart from Rhythmbox, GAIM and Ekiga (gnomemeeting), there are some more GNOME applications that support ZeroConf: Vino and the Epiphany browser. Vino auto discovers the remote desktops and Epiphany shows all services of type _http._tcp in the bookmarks, under the Local Sites category. Unfortunately, I didn’t have the time to try and test all this functionality, but will do soon.

    Thanks for your comment.

  3. Anders Jackson Permalink →

    I can confirm that Epiphany, Rhythmbox works with Avahi. I am using Debian/testing and it is no problems to install at all. I am just installing mt-daapd, so you have to wait for any reports about that.

    You don’t need to have Zeroconf installed to make Avahi (and you computer) to discover things.
    The Linux named “kaka” with Avahi installed will announce itself as “kaka.local”, and with

    hosts: files dns mdns

    in /etc/nsswitch.conf, you can connect with ssh kaka.local, which is realy nice.

    In /etc/avahi/hosts on “kaka” you can add machines that doesn’t have mDNS (which Avahi implements) to make “kaka” announce that address under domain “local”.

    Put this code in /etc/avahi/services/webserver.service in “kaka” to make it announce it’s web server to your local net:

    Kaka's webserver
      
        _http._tcp
        80
        path=/
      
    
    

    This in /etc/avahi/services/ssh.service makes your ssh annonced:

    
      Remote Terminal on %h
      
        _ssh._tcp
        22
      
    
    
  4. Anders Jackson Permalink →

    Hmmm, how doy you put XML-code into a posting?

  5. George Notaras Post authorPermalink →

    Thanks for this info. I had also tried to announce services on a machine without Avahi, but didn’t manage to do so.

    WordPress is rather unconvenient when writing code in a post or comment. ;-)