Recently, I spent some time wondering how to send the audio output of my laptop to a DLNA DMR (Digital Media Renderer) compliant HiFi device.
The first step was to setup a classic DLNA streaming source with Rygel using a Pulseaudio
module available in the
pulseaudio-module-rygel-media-server package. This is done by adding the following options to /etc/pulse/default.pa :
#dlna load-module module-http-protocol-tcp load-module module-rygel-media-server load-module module-null-sink sink_name=dlna format=s16be channels=2 rate=44100 sink_properties="device.description='DLNA' device.bus='network' device.icon_name='network-server'"
At this point, Pulseaudio create a new virtual output device named dlna.
Then, Rygel is used to serve this output with the DLNA protocol. In ~/.config/rygel.conf :
[GstLaunch] enabled=true launch-items=pulseaudio_out pulseaudio_out-title=Audio output on @HOSTNAME@ pulseaudio_out-mime=audio/mpeg pulseaudio_out-launch=pulsesrc device=dlna.monitor
Here, no shameful on-the-fly encoding with
lamemp3, first because Rygel already provides built-in transcoding in MP3, and also because a WiFi network is strong enough to handle a PCM stream. This format has the advantage to avoid an additional encoding in an other lossly codec, which is a bad idea for audio quality.
The LPCM transcoding is set this way in the Rygel configuration :
All other features of Rygel (Tracker, MediaExport and Playbin) are disabled in my case.
At this point, an URL providing the stream is available on the local machine, but there is no way for me to call it directly from the DMR.
This is why the
gupnp-dlna-tools package is required. It provides a few tools to manage DLNA devices, and more especially the
gupnp-av-cp command. This command manages all the URL calls (for example, it sends the CurrentURI parameter) in order to control the DMR and fetch the laptop output from it.
So after starting
rygel and set the default audio output to the DLNA device, just launch
gupnp-av-cp to define the source and the destination of the stream : the output must be redirected.
By default, wine don’t use Pulseaudio, so Spotify started with wine can’t be streamed via DLNA with this method. The working solutions are the web-based player (but it uses MP3 instead of OGG, and Flash. : two good reasons to avoid it), or the native client for Linux.
This client can be downloaded from the Spotify official repo, but it requires openssl in a version not provided in Jessie.
In order to keep standard versions of the system libraries, I manually downloaded openssl (for x86_64), then I installed Spotify in /opt :
# mkdir /opt/spotify # dkpg -x <spotify_package.deb> /opt/spotify # cd /opt/spotify && mv opt/spotify/spotify-client . # dpkg -x <ssl_package.deb> /opt/spotify # cd /opt/spotify && mv usr/lib . # rm -rf /opt/spotify/usr && rm -rf /opt/spotify/opt
It can now be started after setting the LD_LIBRARY_PATH variable manually :
#!/bin/bash LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/spotify/lib /opt/spotify/spotify-client/spotify