Non-fiction‎ > ‎

Minimal UPNP renderer package for the Raspberry Pi

UPDATE: Volumio 1.4 includes built in UPNP renderer support using mpd and upmpdcli.  You will need to enable it from the volumio settings, but there is now a turnkey solution to making your RasPi into a UPNP media player.  As such I'm no longer using the method detailed here, but it may still be useful if you can't install volumio on your Pi for some reason.  I would strongly recommend using a volumio image (available from the first link below) as the easiest way to do UPNP on RasPi. 

The Raspberry Pi is really quite a good platform for using as a networked music player.  The problem is that the software to do so doesn't seem to have been packaged up by anyone yet.  So I have done so.  I'm unlikely to have the time to maintain or support this, but here it is for anyone who wants to try and see if the easy method will work before rolling their own.  This method will work with the default audio out socket on the Raspberry Pi.  If you have external or USB audio, it may require some tweaking.  (See the post-install notes below for a bit more detail.)

Prior to installing

  1. Install and configure a Linux distribution on the Raspberry PI.  I would suggest one of the following three options:

    • Volumio is probably a good place to start as it's a distribution designed to support audio applications.   It is a bit rough around the edges though.
    • SqueezePlug is a bit more mature and is also audio and video streaming focused, so it's quite a good bet.   It is harder to set up than Volumio though. 
    • Raspbian is the standard general purpose Raspberry Pi Linux distribution, and that should work too.

    Other distributions may work, but you may need to manually install the ALSA drivers on those.   I've tested on Volumio and SqueezePlug. 

    You can access the command line by using an ssh client such as PuTTY.  In volumio, the account name is "volumio" with password "volumio". The root password is also "volumio".  In Squeezeplug, the account name is "root" with password "nosoup4u".  It would be wise to change these passwords.

  2. (Optional, but recommended) Update the kernal using rpi-update.  Execute the following commands from a root prompt:

    apt-get install git binutils rpi-update
    rpi-update

    If you get an error running rpi-update then you may need to manually update rpi-update to a newer version which uses curl rather than wget.  You can do this by running the following command:
    sudo curl -L --output /usr/bin/rpi-update \
    https://raw.github.com/Hexxeh/rpi-update/master/rpi-update \
    && sudo chmod +x /usr/bin/rpi-update

    Updating the kernel may be necessary in order to get good quality sound from the line out on the Raspberry Pi, since the kernel drivers were originally quite ropey.  This is sometimes described as updating the Raspberry Pi firmware, but as far as I can tell what it does is downloads and compiles a new kernel.

    I recommend this step because it seems to improve gapless playback for some tracks and reduces the frequency of incidents where the renderer will not play any new tracks and a reboot is required.  Your mileage may vary.

Method 1 (recommended unless you use video) - using mediarenderer for gstreamer 1.2.2

Pros

  • The earlier version of gstreamer shipped with raspbian is unsupported and buggy.  This method should provide the most stable renderer.

Cons

  • No support for transcoding using ffmpeg, since there is no unstable gstreamer1.0-ffmpeg package.  This has no effect on normal renderer operation.
  • No gstreamer1.0-libav package.  The package required the recompilation of several other Debian packages, and wasn't required for gmedia-render so I didn't produce one since it took about 2 days to build these packages on a pi as is.  This has no effect on normal renderer operation.  This may be a problem if you want to use it for video streaming though.
  • No guarantees of a smooth upgrade once gstreamer 1.0 packages make it into Raspbian (although I've done my best to make sure everything should work OK). 
  • Need to trust more non-maintainer debian packages.

Instructions

  1. Add the repository signing key to your local apt keyring.  As root:
    wget -O - \
    http://www.chiark.greenend.org.uk/~christi/debian/christi@coraline.org.gpg.key \
    | sudo apt-key add -
  2. Add the repository to your sources file (/etc/apt/sources.list or /etc/apt/sources.list.d/upnprender.list)

  3. Update your sources and install the renderer

    apt-get update
    apt-get install gmrender-resurrect

  4. (Optional)  Install any optional packages you require

    apt-get install gstreamer1.0-plugins-ugly

Method 2 - using Raspbian standard packages

Pros

  • Requires the user to trust only one non Debian package, for the renderer itself.
  • Supports video streaming

Cons

  • gstreamer0.1 is pretty buggy and is unsupported by the developers.  It is likely that the pi will need to be rebooted (or that someone will need to log in and restart the server manually) often if you use this method.
  • This should become unnecessary once gstreamer 1.2 is part of Raspbian.

Instructions

  1. Log in to the server using ssh, make sure you have root permissions, and update the list of available packages using the following command:

    apt-get update

  2. Install pre-requisite packages as follows:

    apt-get install libgstreamer0.10-dev gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg gstreamer0.10-pulseaudio gstreamer0.10-alsa libupnp6


    These install the infrastructure which is necessary in order for the UPNP renderer to work.  It may also install a large number of other packages such as ALSA.  This is normal and nothing to worry about.

  3. Copy the gmrender-resurrect package from this page onto your Raspberry PI (the wget command is probably the easiest way to do this) and install it:

    dpkg -i gmrender-resurrect_0.0.7.git-1-1_armhf.deb

After installation

  1. You now have a running UPNP media renderer with the same name as the hostname of the Pi that by default will output music to your Raspberry Pi's audio out socket.  If you're using volumio, it is possible to use the controls on Volumio's web interface to change the volume of the server.  You will also need a DNLA server (Volumio installs MiniDNLA by default, and you can use this) and software which will act as a UPNP control point.  I use an Android phone with BubbleUPNP, but you should be able to find something that works for you.

  2. (Optional) Install BubbleUPNP Server as an OpenHome wrapper for the renderer.  I had some trouble getting gmrender to advance to the next track reliably on its own, and this seems to have helped.  OpenHome also supports nifty stuff like gapless playback and remote access from anywhere on the net, which is nice.  There is a Debian wheezy package at http://www.bubblesoftapps.com/bubbleupnpserver/0.7/bubbleupnpserver_0.7-2deb7_all.deb which will do the job, but it won't play nice with the minimal headless Java package it is probably more sensible to use on the Raspberry Pi.  The java-runtime-dummy Debian package below will fix this.  Commands to install are therefore:

    apt-get install openjdk-7-jre-headless
    dpkg -i java-runtime-dummy_1.0_all.deb bubbleupnpserver_0.7-2deb7_all.deb


    Configuring BubbleUPNP server to allow access to the Internet is done via the webserver on port 58050 (i.e. http://volumio:58050).

  3. (Optional) Using a higher quality sound card, DAC or Digital Out.  The RasPi audio out socket is not very high quality, so it makes sense to use an alternative sound card.  I have successfully used this configuration with a HiFiBerry Digi daughter-board.   Even my execrable soldering skills were up to the task.  It may also be possible to use a USB sound card.  In addition to following the HiFiBerry setup instructions to enable the card, I did need to make the following changes to /etc/asound.conf to make sure it sent audio output to the daughter-board rather than the on-board sound.

    pcm.!default {
    type hw
    card 1
    device 0
    }
    ctl.!default {
    type hw
    card 1
    device 0
    }

    Note that you can check which sound devices are installed in the system using "aplay -l".  The correct numbers to use in the config file may vary on your system, but this command should enable you to see which ones should be used.

Notes

  1. This is a bit of a hack.  I wouldn't be surprised if something doesn't work.

  2. If you want to hack about with this, the package has a public git repository at https://github.com/christiscarborough/gmrender-resurrect-debian.

  3. If upgrading from a pre 1.1 release, it's probably necessary to remove the old .deb manually, as I had to change the version name to fit with Debian standards, and configuration is significantly improved in 1.1 so you probably don't want to keep your old configuration files.

    dpkg --purge gmrender-resurrect

  4. If you aren't bothered about being able to control the Pi remotely, but just want it to be able to access files on a UPNP server, it may be worth investigating mpd and its UPNP plugin.   See http://www.lesbonscomptes.com/pages/mpd-upnp.html for details.

  5. I used the equivs (apt-get install equivs) package to create the dummy Java package.  It requires the headless JRE to be installed and does nothing except reassure apt that we do in fact have a Java interpreter installed.

Changelog

 Version   
 Notes
 1.2 Rebuild using gstreamer 1.2
 1.1 Initial release using debconf to generate the package.                          
 1.0.1 Minor bugfix - missing dependency on libupnp
 1.0    Initial release

References

The following information was all useful in getting everything up and working.

Historical notes

These notes relate to pre 1.1 releases of the Debian packages, and almost certainly aren't of interest or relevance any more.  They are preserved entirely for historical reasons.

  1. Versions prior to 1.1 were built using checkinstall with the following commands.  Note that before running autogen.sh I had to add scripts/init.d to SUBDIRS in Makefile.ac and make a minimal Makefile in scripts/init.d to copy scripts/init.d/gmediarenderer to /etc/init.d.  Before checkinstall I needed to add checkinstall postinstall and preremove and postremovescripts to start/stop the server and run update-rc.d.

    apt-get install git autoconf automake libtool libupnp6-dev checkinstall
    git clone https://github.com/hzeller/gmrender-resurrect.git
    cd gmrender-resurrect
    ./autogen.sh
    ./configure --prefix=/usr
    checkinstall --install=no --pkgname=gmrender-resurrect --pkgversion=0.0.7-git --requires="libgstreamer0.10-dev,gstreamer0.10-plugins-base,gstreamer0.10-plugins-good,gstreamer0.10-plugins-bad,gstreamer0.10-plugins-ugly,gstreamer0.10-ffmpeg,gstreamer0.10-pulseaudio,gstreamer0.10-alsa,libupnp6" --pkgsource="https://github.com/hzeller/gmrender-resurrect.git"

  2. The modified files I used are contained in the gmrender-resurrect-modified.tar.bz2 file below.  As derivative works based on gmrender-resurrect, they are licensed under the GNU public license v2.

  3. The init script I used starts the daemon with uid 1000, which is usually "pi" on Raspberry Pi systems.  This may or may not be what you wanted.
ċ
gmrender-resurrect-modified.tar.bz2
(2k)
Christi Scarborough,
1 Feb 2014, 13:42
ċ
gmrender-resurrect_0.0.7-git-1.0.1_armhf.deb
(81k)
Christi Scarborough,
1 Feb 2014, 20:38
ċ
gmrender-resurrect_0.0.7.git-1.1.debian.tar.gz
(6k)
Christi Scarborough,
5 Feb 2014, 12:58
ċ
gmrender-resurrect_0.0.7.git-1.1.dsc
(1k)
Christi Scarborough,
5 Feb 2014, 12:58
ċ
gmrender-resurrect_0.0.7.git-1.1_armhf.deb
(76k)
Christi Scarborough,
5 Feb 2014, 12:58
ċ
gmrender-resurrect_0.0.7.git-1.2.dsc
(1k)
Christi Scarborough,
9 Feb 2014, 09:01
ċ
gmrender-resurrect_0.0.7.git-1.2_armhf.deb
(77k)
Christi Scarborough,
9 Feb 2014, 09:01
ċ
gmrender-resurrect_0.0.7.git.orig.tar.gz
(93k)
Christi Scarborough,
9 Feb 2014, 09:01
ċ
java-runtime-dummy_1.0_all.deb
(2k)
Christi Scarborough,
1 Feb 2014, 12:01