Skip to content

Instantly share code, notes, and snippets.

@pulsar256
Last active January 29, 2024 01:19

Revisions

  1. pulsar256 revised this gist Jun 8, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ gst-launch-1.0 \

    ### Gstreamer Based

    ### Default / auto audio sink
    #### Default / auto audio sink

    ``` bash
    RECEIVER_PORT=5100
    @@ -38,7 +38,7 @@ gst-launch-1.0 \
    ! autoaudiosink
    ```

    ### Jack Audio Sink
    #### Jack Audio Sink

    ``` bash
    RECEIVER_PORT=5100
  2. pulsar256 revised this gist Jun 8, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,8 @@ gst-launch-1.0 \

    ### Gstreamer Based

    ### Default / auto audio sink

    ``` bash
    RECEIVER_PORT=5100

    @@ -36,7 +38,7 @@ gst-launch-1.0 \
    ! autoaudiosink
    ```

    ### Gstreamer Based Jack Target
    ### Jack Audio Sink

    ``` bash
    RECEIVER_PORT=5100
    @@ -52,8 +54,6 @@ gst-launch-1.0 \
    ! jackaudiosink
    ```



    ### VLC Based

    VLC requires a SDP File specifying the RTP payload.
  3. pulsar256 revised this gist Jun 8, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,7 @@ 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 \
    @@ -43,6 +44,7 @@ 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 \
    @@ -77,3 +79,5 @@ See https://tools.ietf.org/html/rfc7587 for more details.
    ## Notes

    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).
  4. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,22 @@ gst-launch-1.0 \
    ! autoaudiosink
    ```

    ### Gstreamer Based Jack Target

    ``` bash
    RECEIVER_PORT=5100

    gst-launch-1.0 \
    udpsrc port=$RECEIVER_PORT \
    ! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
    ! rtpopusdepay \
    ! opusdec \
    ! audioconvert \
    ! audioresample \
    ! jackaudiosink
    ```



    ### VLC Based

  5. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ gst-launch-1.0 \
    RECEIVER_PORT=5100

    gst-launch-1.0 \
    udpsrc port=$RECEIVER_PORT\
    udpsrc port=$RECEIVER_PORT \
    ! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
    ! rtpopusdepay \
    ! opusdec \
  6. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ gst-launch-1.0 \
    ! audioconvert \
    ! opusenc bitrate-type=vbr bitrate=128000 \
    ! rtpopuspay pt=101 \
    ! udpsink host=$TARGET_IP port=$TARGET_PORT blocksize=4096
    ! udpsink host=$TARGET_IP port=$TARGET_PORT
    ```

    ## Consumer
    @@ -27,7 +27,7 @@ gst-launch-1.0 \
    RECEIVER_PORT=5100

    gst-launch-1.0 \
    udpsrc port=$RECEIVER_PORT blocksize=128 \
    udpsrc port=$RECEIVER_PORT\
    ! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
    ! rtpopusdepay \
    ! opusdec \
  7. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,4 @@ See https://tools.ietf.org/html/rfc7587 for more details.

    ## Notes

    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-odp` and `test-launch` in the `1.16` branch did not yeld any working servers during my tests.
    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.
  8. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Abstract
    # Opus p2p streaming

    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.

    @@ -58,4 +58,6 @@ Please notice the hardcoded UDP port in the SDP file set to 5100, depending on y

    See https://tools.ietf.org/html/rfc7587 for more details.

    ## Notes

    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-odp` and `test-launch` in the `1.16` branch did not yeld any working servers during my tests.
  9. pulsar256 revised this gist Jun 7, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    # Abstract

    Low latency streaming of ogg compressed audio data between two peers using RTP and gstreamer-1.0
    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.

    ## Producer

    The producer will provide a Jack sink which needs to be connected to a audio producer.

    ```bash
    TARGET_PORT=5100
    TARGET_IP=PEER_IP
  10. pulsar256 created this gist Jun 7, 2020.
    59 changes: 59 additions & 0 deletions opus-p2p-streaming.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    # Abstract

    Low latency streaming of ogg compressed audio data between two peers using RTP and gstreamer-1.0

    ## Producer

    ```bash
    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 blocksize=4096
    ```

    ## Consumer

    ### Gstreamer Based

    ``` bash
    RECEIVER_PORT=5100

    gst-launch-1.0 \
    udpsrc port=$RECEIVER_PORT blocksize=128 \
    ! application/x-rtp,media=audio,payload=101,encoding-name=OPUS \
    ! rtpopusdepay \
    ! opusdec \
    ! audioconvert \
    ! autoaudiosink
    ```


    ### VLC Based

    VLC requires a SDP File specifying the RTP payload.

    `stream.sdp`:

    ```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.