Low latency streaming of ogg compressed audio data between two peers using RTP and gstreamer-1.0. Expected latency over the network is below 1 second.
The producer will provide a Jack sink which needs to be connected to a audio producer.
TARGET_PORT=5100
TARGET_IP=PEER_IP
gst-launch-1.0 \
jackaudiosrc connect=1 \
! audio/x-raw, channels=2 \
! audioconvert \
! opusenc bitrate-type=vbr bitrate=128000 \
! rtpopuspay pt=101 \
! udpsink host=$TARGET_IP port=$TARGET_PORT
RECEIVER_PORT=5100
gst-launch-1.0 \
udpsrc port=$RECEIVER_PORT \
! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
! rtpjitterbuffer \
! rtpopusdepay \
! opusdec \
! audioconvert \
! autoaudiosink
RECEIVER_PORT=5100
gst-launch-1.0 \
udpsrc port=$RECEIVER_PORT \
! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
! rtpjitterbuffer \
! rtpopusdepay \
! opusdec \
! audioconvert \
! audioresample \
! jackaudiosink
VLC requires a SDP File specifying the RTP payload.
stream.sdp
:
m=audio 5100 RTP/AVP 101
c=IN IP4 127.0.0.1
a=rtpmap:101 opus/48000/2
run with
vlc ./stream.sdp
Please notice the hardcoded UDP port in the SDP file set to 5100, depending on your network configuration / forwarding rules this might need to change.
See https://tools.ietf.org/html/rfc7587 for more details.
this solution provides a peer to peer path only. If multiple clients shall connect to the same audio source, a RTSP server would be the next logical building block. See https://github.com/GStreamer/gst-rtsp-server for examples how to implement one. test-sdp
and test-launch
in the 1.16
branch did not yeld any working servers during my tests.
rtpjitterbuffer for the client might be optional if your network is stable and transport is udp (which it is in the examples above).