Introduction
Are you interested in playing audio throughout your home but do not want to rewire it with expensive audio cabling? you might want to try RTP over your existing wired LAN. I tested this with my own wired LAN involving Linux PCs and a Smart TV.
Prerequisites
- Sony Bravia Smart TV
- Linux Pulse Audio
- VLC
- NTP (Network Time Protocol)
Timing is Hard
Setup the RTP Sender
load-module module-null-sink sink_name=broadcast sink_properties=device.description=Broadcast
load-module module-rtp-send source=broadcast.monitor loop=true source_ip=192.168.1.2 port=2000 ttl=1
load-module module-rtp-recv sink=speakers latency_msec=1800
.fail
The key elements here:
- Broadcast - virtual audio sink, use this like a speaker for broadcast audio, on its own it's just a dummy sink that doesn't do anything, but the associated monitor source we care about for the RTP broadcast.
- broadcast.monitor - the associated source of the same sink, read from by the RTP send module to do the actual broadcasting
- loop - playback the audio on the local machine too, otherwise it just broadcasts the audio to the network and ignores your speakers
- speakers - a virtual sink I created that maps to my speakers
- latency_msec - compensation for network lag, makes audio synchronized, set to a higher value to compensate for more network latency on your LAN.
- .fail / .nofail - atomic transaction, if any of the commands between these two tags fails, then undo everything that was ran successfully inside these two tags.
- ttl - Time-to-Live, this is a security measure, it makes sure that packets broadcast over your network will not reach beyond your immediate local area network.
- port - The UDP port to broadcast packets over, this is important and must be fixed.
This gets the RTP setup going on one machine for both sending audio to the Local Area Network as well as playing it back on the same machine's speakers.
I set a latency milliseconds value of just under two seconds, which makes audio playback on the local machine delayed by about two seconds because it takes about that long for the audio to playback in the other room over the network. Set this to a higher value if you have very bad network latency.
The other point worth mention is the UDP port value, I set this to 2000, which is the Cisco SCCP protocol, which I don't care about on my LAN. I first set it to 556 and this didn't work, probably because this is a privileged port, which are typically prohibited by many devices. If you don't set a fixed port then the RTP transmitter randomly picks a port each time and some RTP receivers don't like that.
RTP Receivers
Now it's time to setup the receiving end of playback
Linux Receiver
You can specify a sink if you want but otherwise this will playback audio on the default speakers configured for the system.
Sony Bravia Smart TV
Playing back RTP on a Smart TV was also pretty easy, just install VLC for Android from the Google Play Store.
Once setup add a network stream:
- Go to Browsing → Streams
- Now enter the following URL:
rtp://224.0.0.56:2000/
The URL here indicates a few things:
- RTP - The Realtime Transport Protocol
- 224.0.0.56 - This is the built-in UDP broadcast IP address, if a switch receives packets from this IP address it broadcasts them to everything on the network, if a host receives a packet from this IP address it has the option of reading it.
- 2000 - This is the UDP port we configured our RTP sender to transmit packets on
That's it! now you're ready to start playback. Use your TV remote to activate the link. If you hold your remote activation button VLC will let you rename it, I named mine LAN (wow, creative).