The problem[edit]
I have an amplifier and speaker system installed in my apartment to which I want to transcode audio ouput from any application on my laptop over my home WLAN. My roommate has an apple airport express, but I can't/refuse to connect through it. Turns out there's no need. I found two useful solutions. One involves transcoding directly from my pc (currently a Lenovo X1 1st generation running Ubuntu 16.04) via UPnP and a few other things. The other involves running a UPnP server on the laptop and connecting remotely from the phone. It took me a somewhat lazy Saturday morning to sort this out, so I'm recording the information here for future reference and sharing.
Prerequisites[edit]
- WLAN with both (a) any device you want to transcode/serve content from and (b) any device you want to receive/access content with are connected.
- Primary device (Lenovo X1 in my case) with Ubuntu 16.04, which seems to come with a UPnP/DLNA media server baked in unlike earlier versions.
- If you don't use Ubuntu 16.04, you might do well to try setting up Rygel or something similar. Check out this askubuntu post and this old blog post for some ideas about that.
- Software to sink media output to any UPnP/DLNA connected device. In my case, this turned out to be Pulseaudio-DLNA, which (surprise!) uses the pulseaudio server to direct media output to any DLNA-connected output. The first record I found of pulseaudio-dlna was posted as this AskUbuntu answer by the creator, Massimo. Note that I installed the
pavucontrol
package as well in order to manage the audio output as Massimo suggests in the post. - Audio receiver device with a UPnP renderer installed. In my case, this was an oldish Nexus 5 phone running a current version (13-point-something) of CyanogenMod or some other reasonably contemporary Android OS.
- I am using BubbleUPnP. That's a link to the free version. If you want to run the stream for more than 30 minutes or so, you may need to buy the full version for about $5. I have not tested this with other UPnP/DLNA rendering tools out there.
Method 1: Transcoding[edit]
From what I understand, transcoding requires that you have (a) a working UPnP/DLNA server setup on the machine you want to transcode from as well as (b) a UPnP/DLNA renderer. The keys here were really finding the right software. I tried a bunch of things before finding the baked-in Ubuntu UPnP/DLNA server, Pulseaudio-DLNA, and BubbleUPnP. Once I had those up and running it was almost seamless.
- Launch BubbleUPnP on the receiver (phone). From the menu select "renderer" and choose "Local renderer."
- Launch pulseaudio-dlna. Launch pavucontrol on the pc. Use optional flags as described by Massimo in the pulseaudio-dlna documentation to do things like set the streaming codec, default devices, etc. If everything is working as planned, the UPnP rendering device (receiver) will appear in the pavucontrol "Playback" tab drop-down menu next to the application currently generating audio output and the "Output Devices" tab. Select it as the output in the "Playback" tab drop-down.
- You may need to press "play" or something similar through the BubbleUPnP renderer interface on the receiver device.
- Check your volume levels :)
Method 2: PC as server[edit]
- Open the "Settings" in Ubuntu and select "Sharing" from the available options.
- Toggle the "Active" option for "Media Sharing." Note that I have not tried this for sharing the screen or any other options.
- Open the BubbleUPnP application on the renderer/receiver device. From the menu, select "renderer" and choose the server device (laptop in my case).
- The Ubuntu UPnP/DLNA server seems to have reasonable defaults and so I was able to navigate directly around relevant subdirectories of my home directory on my laptop's filesystem at this point.
- Select the file or directory and, assuming everything is connected as it should be, check your volume levels :)