Gst-nvdsudpsink#

The Gst-nvdsudpsink plugin is a sink type component which can be used to transmit the RTP packets over IP network. Internally, the plugin uses Rivermax SDK APIs for network communications. NVIDIA Rivermax® offers a unique IP-based solution for any media and data streaming use case. For more details see the Rivermax Product Page.

nvdsudpsink can operate in three different modes based on the input type and properties set to the component.

Mode 1: RTP packets with Rivermax Generic API

This is default mode. In this mode nvdsudpsink will receive RTP packets and transmit it to network using Rivermax generic APIs. nvdsudpsink doesn’t require any information about the content of RTP packets.

Mode 2: RTP packets with Rivermax Media API

This mode is for specific use case of SMPTE 2110-20, 30 streams. In this mode, nvdsudpsink supports SMPTE 2110-20 and SMPTE 2110-30 streams with traffic shaping. nvdsudpsink expects RTP packets having either uncompressed audio or video as payload and It will transmit those packets to network using Rivermax media APIs.

Since Rivermax media APIs need to know the information about the data being transmitted for it to handle the traffic shaping, nvdsudpsink needs that information for Rivermax initialization in the form of SDP file.

  • This mode can be enabled by setting sdp-file property of the component. In this mode, for uncompressed video streams, packets-per-line and payload-size properties along with sdp-file must be set. Similarly, value of mtu property of payloader component must be same as payload-size of nvdsudpsink.

  • For uncompressed audio streams in this mode, max-ptime and ptime-multiple properties of payloader component must be set. Also it is mandatory to set a=ptime: attribute in the SDP file with an appropriate value which denotes packet time in milliseconds.

Mode 3: Uncompressed data with Rivermax media API

In this mode, nvdsudpsink expects uncompressed audio or video frames directly instead of RTP packets. The component will convert those frames to RTP packets and then transmit over network using Rivermax media API.

  • This mode will be enabled if in addition to the requirements of mode #2 the incoming data is uncompressed video or audio frames instead of RTP packets.

  • In this mode, if render-thread-core property is set, a separate thread will be created to packetize the frame and transmit the packets. That thread will also be bound to the CPU core(s) provided as the value of the property.

Note

In this mode as uncompressed video input, only YUV 4:2:2 and RGB with 8 or 10 bit depth is supported.

SMPTE 2022-7 feature support

The plugin supports SMPTE 2022-7 standard. Its main purpose is to ensure uninterrupted transport of media streams, by providing redundancy for RTP packets to safeguard against packet loss or network/interface failures. To enable SMPTE 2022-7 feature, corresponding sdp-file should be provided. It should have a DUP string as well as details of two streams.

Sample sdp-file provided below:

v=0
o=- 123456 2 IN IP4 192.168.1.10
s=SMPTE ST2022-7 DUP streams
i=Includes 1080p@30 fps video
t=0 0
a=recvonly
a=group:DUP one other
m=video 50020 RTP/AVP 96
c=IN IP4 225.1.1.2/64
a=source-filter: incl IN IP4 225.1.1.2 192.168.1.10
a=rtpmap:96 raw/90000
a=fmtp:96 sampling=YCbCr-4:2:2; width=1920; height=1080; exactframerate=30; depth=10; TCS=SDR; colorimetry=BT709; PM=2110GPM; TP=2110TPN; SSN=ST2110-20:2017
a=ts-refclk:localmac=04-3F-72-DB-77-D4
a=mediaclk:direct=0
a=mid:one
m=video 50120 RTP/AVP 96
c=IN IP4 225.1.1.3/64
a=source-filter: incl IN IP4 225.1.1.3 192.168.101.10
a=rtpmap:96 raw/90000
a=fmtp:96 sampling=YCbCr-4:2:2; width=1920; height=1080; exactframerate=30; depth=10; TCS=SDR; colorimetry=BT709; PM=2110GPM; TP=2110TPN; SSN=ST2110-20:2017
a=ts-refclk:localmac=04-3F-72-DB-77-D4
a=mediaclk:direct=0
a=mid:other

Note

SMPTE 2022-7 is only supported in Mode 2 and Mode 3.

  • Example pipeline that uses SMPTE 2022-7 feature to send two identical streams over separate network paths:

    gst-launch-1.0 videotestsrc horizontal-speed=1 ! 'video/x-raw,width=640,height=480,format=UYVP,framerate=30/1' ! nvvideoconvert ! 'video/x-raw(memory:NVMM), width=1920, height=1080, format=(string)UYVP, framerate=30/1' ! queue ! nvdsudpsink host=<ip address> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file>
    
GPU Direct for SMPTE 2110-20 stream

GPU Direct feature is only supported for SMPTE 2110-20 stream and only in Mode 3. To enable this feature, provide video/x-raw(memory:NVMM) as input for nvdsudpsink and also set gpu-id property for the plugin.

  • Example pipeline that uses GPU-direct feature while sending SMPTE ST2110-20 stream (requires ConnectX-6 or above cards)

    gst-launch-1.0 videotestsrc ! 'video/x-raw, width=640, height=480, format=(string)NV12, framerate=60/1' ! nvvideoconvert compute-hw=1 ! 'video/x-raw(memory:NVMM),width=1920,height=1080,format=UYVP,framerate=60/1' ! queue ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> gpu-id=<gpu id> sync=1 -v --gst-debug=3
    

If enabled, Rivermax media API’s will allocate GPU memory to receive the SMPTE 2110-20 stream and this memory is directly accessible by NICThis feature is only available for ConnectX-6 or above cards.

Timestamps in RTP packet headers
  • By default, nvdsudpsink ignores timestamps from upstream components (buffer pts/dts) and generates RTP header timestamp based on system clock.

    If ptp-src property is set, the plugin will use time from the Rivermax hardware clock provider instead of system clock.

    The timestamp generated is in TAI time (International Atomic Time) which is 37 seconds (called as leap seconds) ahead of UTC time.

    The above timestamp generation logic is applicable only in Mode 2 and 3.

  • If user want to generate RTP header timestamp based on upstream time (e.g. buffer pts or meta), set pass-rtp-timestamp property. It will ignore the timestamp generation logic discussed above. It has two ways to set RTP timestamp for outgoing buffers:

    • Use the buffer PTS it received from upstream component for calculating RTP timestamp for outgoing buffers:

      RTP time = base time of pipeline + buffer PTS
      
    • If metadata GstRTPTimestampMeta is attached along with the upstream buffer, the timestamp from that metadata will be used directly and take precedence over the RTP timestamp calculated using buffer PTS.

    pass-rtp-timestamp is only valid if no payloader is used before nvdsudpsink, that is, in Mode 3 only.

  • Receiver (nvdsudpsrc) has to do leap second adjustment if they receive timestamp in TAI time and wants to use UTC time. Whenever sender (nvdsudpsink) does packetization, by default it uses TAI time. So leap-second adjustment will be required in most scenarios except when pass-rtp-timestamp is set and the upstream component does not provide timestamps in TAI time. It is the user’s responsibility to identify if TAI time based timestamps are expected in such cases.

  • Example pipeline that uses “pass-rtp-timestamp” property to pass the timestamp it received from upstream nvdsudpsrc component.

    gst-launch-1.0 nvdsudpsrc address=<unicast / multicast address> port=<port number> local-iface-ip=<ip address of NIC> caps='video/x-raw(memory:NVMM), format=UYVP, width=1920, height=1080, framerate=60/1' header-size=20 payload-size=1200 gpu-id=0 use-rtp-timestamp=1 adjust-leap-seconds=1 ! nvvideoconvert ! 'video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, format=(string)UYVP' ! queue ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> pass-rtp-timestamp=1 sync=1 -v --gst-debug=3
    

Payload size and packets per line for some of common formats

To calculate the payload size and packets per line, use the following steps:

  1. Calculate line stride as follows:

    line stride = (width * pgroup size) / pgroup coverage
    
  2. Divide this stride into number of packets having equal bytes. This will be value of packet-per-line.

  3. Add 20 bytes to size of each packet calculated in step 2 for RTP + Payload header. This will be value for payload-size.

    Note

    It is assumed that there is only single Sample Row Data per RTP packet and line stride is equally divisible.

Following are values for some of the common formats:

YCbCr-4:2:2 1920x1080 8 bit:  payload-size:1300, packets-per-line:3
YCbCr-4:2:2 1920x1080 10 bit: payload-size:1220, packets-per-line:4
YCbCr-4:2:0 1920x1080 8 bit:  payload-size:1460, packets-per-line:2
YCbCr-4:2:0 1920x1080 10 bit: payload-size:1220, packets-per-line:3
RGB 1920x1080 8 bit:  payload-size:1460, packets-per-line:4
RGB 1920x1080 10 bit: payload-size:1220, packets-per-line:6

Refer to the SMPTE ST 2110-20:2017 for more information.

System can also have Gstreamer provided OSS implementation of udp sink (udpsink) component. In that case system would have two implementations for udp sink - udpsink and nvdsudpsink. nvdsudpsink component can only be used with NVIDIA ConnectX-5 and above cards after having installed Rivermax SDK and its license.

  • Download and setup the Rivermax 1.70.x SDK here: https://developer.nvidia.com/networking/rivermax-getting-started.

  • Follow the instruction on the SDK page to obtain development license for Rivermax.

  • To select nvdsudpsink out of two installations, use either LOCAL_IFACE_IP environment variable or local-iface-ip property. Use the command below to export the environment variable:

    export LOCAL_IFACE_IP=<IP of NIC>
    
  • nvdsudpsink component also requires CAP_NET_RAW capability. Either run the application that uses nvdsudpsink component with superuser privilege or set the CAP_NET_RAW capabilities using the following command.

    sudo setcap CAP_NET_RAW=ep <absolute path of application>
    

For example:

sudo setcap CAP_NET_RAW=ep /opt/nvidia/deepstream/deepstream/bin/deepstream-app

sudo setcap CAP_NET_RAW=ep /usr/bin/gst-launch-1.0
Gst-nvdsudpsrc

Inputs and Outputs#

  • Inputs

    • GstBufferList having RTP packets as buffer content.

    • GstBuffer having uncompressed audio or video frame.

  • Control parameters

    • LOCAL_IFACE_IP ENV flag or local-iface-ip property

  • Output

    • None

Features#

The following table summarizes the features of the plugin.

Gst-nvdsudpsink plugin features#

Feature

Description

Release

Supports Rivermax Generic and Media APIs

By default, it supports generic APIs, but media API can be enabled by setting sdp-file property.

DS 6.1

Supports any type of RTP packet (Compressed, Uncompressed, audio etc.) with Generic APIs

No restriction on content of RTP payload in case of Generic APIs.

DS 6.1

Supports RTCP packets,In addition to RTP

RTCP packets can also be transmitted.

DS 6.1

Traffic shaping in case of Uncompressed streams (video and audio)

By using Rivermax media APIs,packet pacing can be enabled for uncompressed video and audio streams.

DS 6.1

Supports SMPTE 2110-20

Uncompressed SMPTE 2110-20 streams with packet pacing is supported through Rivermax media APIs.

DS 6.1

Supports SMPTE 2110-30

Uncompressed SMPTE 2110-30 stream with packet pacing is supported through Rivermax media APIs.

DS 6.1

Supports RTP packetization of uncompressed video

Uncompressed video as input can be converted to RTP packets as per SMPTE 2110-20 before sending to network

DS 6.2

Supports RTP packetization of uncompressed audio

Uncompressed audio as input can be converted to RTP packets as per SMPTE 2110-30 before sending to network

DS 6.2

Supports PTP clock

“In addition to system clock hardware clock from the PTP source (Network card) can be used to generate RTP packet timestamp”

DS 6.2

Supports render thread affinity

Separate thread to packetize and transmit the data. This thread can be bound to specific CPU core(s)

DS 6.2

Supports GPU-Direct for SMPTE 2110-20 stream

Rivermax media API’s will allocate GPU memory to receive the SMPTE 2110-20 stream and this memory is directly accessible by NIC (ConnectX 6 or above required)

DS-8.0

Supports SMPTE 2022-7

By using Rivermax media API’s, can transmit redundant packet streams over independent network paths. SDP file will decide whether it is 2022-7 stream

DS-8.0

Gst Properties#

The following table describes the Gst-nvdsudpsink plugin’s Gst properties.

Gst-nvdsudpsink plugin gst properties#

Property

Meaning

Type and Range

Example / Notes

Platforms

port

The port number to send the RTP packets to

Integer, 0 to 65535

Port=5004

dGPU Jetson

host

Unicast / Multicast address to send the packets

String

address=192.168.4.60

dGPU Jetson

chunk-size

Number of chunks to allocate in case of generic APIs

Integer, 1 to 65535

chunk-size=100

dGPU Jetson

packets-per-chunk

Number of packets per chunk

Integer, 1 to 65535

packets-per-chunk=10

dGPU Jetson

payload-size

Size of payload in RTP packet

Integer, 0 to 65535

payload-size=1400

dGPU Jetson

packets-per-line

Number of packets per line in case of media APIs

Integer, 1 to 65535

packets-per-line=4

dGPU Jetson

sdp-file

Path to SDP file, to enable the use of Rivermax media APIs

String

sdp-file=”sdp_video.txt”

dGPU Jetson

local-iface-ip

IP Address associated with network interface through which to transmit the data

String

local-iface-ip=”192.168.2.20”

dGPU Jetson

internal-thread-core

CPU core to run Rivermax internal thread

Integer, -1 to 1023

internal-thread-core=2

dGPU Jetson

ptp-src

IP Address of PTP source

String

ptp-src=”192.168.2.20”

dGPU Jetson

render-thread-core

Comma seperated list of CPU core(s) for rendering thread

String

render-thread-core=”2,3”

dGPU Jetson

gpu-id

GPU ID to use for GPUDirect

Integer, -1 to 2147483647

gpu-id=0

dGPU Jetson

pass-rtp-timestamp

When enabled use RTP timestamp from upstream metadata or calculate RTP timestamp from upstream buffer PTS

Boolean

pass-rtp-timestamp=true

dGPU Jetson

Example pipelines#

  • Pipeline to transmit 24 bit 2 channel 48k audio stream using Rivermax media API:

    gst-launch-1.0 audiotestsrc wave=8 ! 'audio/x-raw, format=(string)S24BE, rate=48000, channels=2, payload=(int)97' ! rtpL24pay ptime-multiple=1000000 max-ptime=1000000 seqnum-offset=0 pt=97 ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> sdp-file=<sdp file> internal-thread-core=4 -v --gst-debug=3
    
  • Pipeline with separate payload component to transmit 10bit YUV 4:2:2 1080p30 video stream using Rivermax media API:

    gst-launch-1.0 videotestsrc ! 'video/x-raw, width=1920, height=1080, format=(string)UYVP, framerate=30/1' ! queue ! rtpvrawpay mtu=1220 ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> -v --gst-debug=3
    
  • Pipeline without additional payload component to transmit 10bit YUV 4:2:2 1080p60 video stream using Rivermax media API:

    gst-launch-1.0 videotestsrc ! 'video/x-raw, width=1920, height=1080, format=(string)UYVP, framerate=60/1' ! queue ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> -v --gst-debug=3
    
  • Pipeline that uses PTP hardware clock from NIC:

    gst-launch-1.0 videotestsrc ! 'video/x-raw, width=1920, height=1080, format=(string)UYVP, framerate=60/1' ! queue ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> ptp-src=<ip addr of PTP source> -v --gst-debug=3
    
  • Pipeline that uses separate render thread and bind it to CPU core(s):

    gst-launch-1.0 videotestsrc ! 'video/x-raw, width=1920, height=1080, format=(string)UYVP, framerate=60/1' ! queue ! nvdsudpsink host=<ip address> port=<port number> local-iface-ip=<ip addr of NIC> payload-size=1220 packets-per-line=4 sdp-file=<sdp file> ptp-src=<ip addr of PTP source> render-thread-core="list of core(s)" sync=0 -v --gst-debug=3