Gst-nvdsudpsrc
The Gst-nvdsudpsrc plugin is a source type component which is used to receive the UDP-RTP packets from the 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..
Rivermax utilizes the kernel bypass technology and RDMA capabilities to achieve better CPU performance, low latency, and higher bandwidth. On top of Rivermax based enhancements, some of memory and buffer management optimization have been implemented to further reduce the CPU utilization in case of high packet rate use cases.
This component also supports RTP header and payload separation. RTP header and payloads can be received in separate memories. Header will always be in system memory while payload can directly be copied to GPU (Pinned) memory. This can avoid memory copies in cases when GPU processing is performed on the RTP payloads. Header and payload separation will happen only if header-size property is set to non-zero value and for fixed header size.
High resolution uncompressed video streams have a very high number of RTP packets per second. In such case, OSS de-packetization component (rtpvrawdepay) becomes bottleneck to process stream real-time. To handle such cases, nvdsudpsrc has added support for de-packetization of uncompressed video and audio streams as per SMPTE 2110-20/30 specifications. In this mode, nvdsudpsrc will provide GstBuffer having complete video / audio frame as an output instead of RTP packets.
To use de-packetization for uncompressed video and audio payloads within nvdsudpsrc, there are certain assumptions regarding input stream.
- Each RTP packet must be of fixed size with fixed header and payload size.
- There should not be more than one sample row data (SRD) per RTP packet.
With the support for de-packetization, nvdsudpsrc can now have five different operating modes based on the value of caps property of the component.
Default mode nvdsudpsrc will receive RTP packets having any type of payload from the network and push those packets to the downstream depayloader component for de-packetization. In this mode, nvdsudpsrc component is agnostic to content of the RTP packet. This is default mode and the source pad should have “application/x-rtp, ……” as caps.
Uncompressed video frame as output nvdsudpsrc will receive RTP packets having uncompressed video as payload and will do de-packetization as per SMPTE 2110-20 specification to form a video frame before sending to downstream components. This mode will be activated when caps property is set with “video/x-raw(memory:NVMM), …..” caps. From DS 8.0, caps can be set to “video/x-raw, …..” as well if required, to get output in software memory.
Uncompressed audio frame as output nvdsudpsrc will receive RTP packets having uncompressed audio as payload and will do de-packetization as per SMPTE 2110-30 specification to form an audio frame before sending to downstream components. This mode will be activated when the caps property is set with “audio/x-raw, …..” caps.
Generic data as output
nvdsudpsrc will receive RTP packets having any type of payload and will do de-packetization to form a frame before sending to downstream components. In this case, the frame boundary is not decided based on the parsing of the RTP / payload header but based on the configurable value of the number of packets. i.e., the value of payload-multiple property will decide on how many packets are considered as a frame and nvdsudpsrc will remove the RTP header of those many packets and combine the payloads to form a frame. This mode will be activated when the caps property is set with “application/x-custom, …..” caps.
SMPTE ST 2110-40 ancillary data as output (RFC 8331)
nvdsudpsrc supports reception of SMPTE 291M ancillary (ANC) data — for example, closed captions encoded as CEA-608/708 — over ST 2110 networks as per SMPTE ST 2110-40 / RFC 8331. In this mode, the plugin receives RFC 8331 RTP packets, performs per-packet bit-level extraction of each ANC sub-packet (DID, SDID, data count, user words and checksum) from the 10-bit bit-packed payload, and outputs one GstBuffer in ST2038 wire format per ANC packet for downstream processing.
- This mode is activated by setting
meta/x-st-2038caps on the source pad. - The RTP marker bit is propagated to downstream as buffer flags so that downstream elements can identify the last ANC packet of a field/frame.
use-rtp-timestampis honoured and the RTP timestamp from the incoming packets is propagated to the buffer PTS, enabling lip-sync between the ANC stream and the corresponding video/audio essence at the receiver.- Output buffers are always allocated in host memory. GPU Direct is not applicable for ancillary streams. If
gpu-idis set, it is automatically disabled with a warning whenmeta/x-st-2038caps are negotiated. - SMPTE 2022-7 dual-path reception is supported for ANC streams via the
st2022-7-streamsandlocal-iface-ipproperties — same semantics as for video/audio streams.
SMPTE 2022-7 feature support The plugin supports SMPTE 2022-7 dual path reception. Its main purpose is to ensure uninterrupted transport of media streams, by listening to redundant stream of RTP packets to safeguard against packet loss or network/interface failures.
To enable this SMPTE 2022-7 feature, make use of properties “st2022-7-streams” and “local-iface-ip”.
The order you list the streams and IP addresses is important. Each stream in “st2022-7-streams” must be paired, in order, with its matching IP address in “local-iface-ip”. It’s a strict 1:1 mapping. The first stream goes with the first IP, the second stream with the second IP, and so on
-
Example pipeline to receive two duplicate streams (SMPTE 2022-7) of 1920x1080 / 10bit / 4:2:2 / UYVP format / 30fps through two local interfaces:
Timestamps in RTP packet headers
-
By default, nvdsudpsrc ignores the timestamp in RTP packet and generates buffer pts/dts based on the system clock.
-
If
use-rtp-timestampproperty is set, the plugin will parse the RTP timestamp it received, and use it to calculate the buffer pts / running time. The logic for reconstruction of rtp ticks and converting it to running time is as follows:We should use CLOCK_REALTIME for the sender and receiver pipeline, in case we want to achieve reconstruction of RTP timestamp (punched from nvdsudpsink/sender) at nvdsudpsrc/receiver component. That is why, when
use-rtp-timestampproperty is enabled the nvdsudpsrc acts as a clock provider to the pipeline based on REALTIME_CLOCK. Also, for the above logic to work, it is important that the systems used are synchronized to same time using some protocols like NTP or PTP. -
The
adjust-leap-secondsproperty is used to subtract the leap-seconds (37) from the received RTP timestamp in TAI time, so that it matches the UTC time. Use it, if nvdsudpsrc is expected to receive RTP packets in TAI time and your pipeline is using UTC time for buffer PTS/DTS.For most scenarios “nvdsudpsink” component will sent TAI time as RTP timestamps, so this property should be enabled. Exception comes when
pass-rtp-timestampis employed bynvdsudpsinkand its 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.If
use-rtp-timestampis not enabled, thenadjust-leap-secondswill have no effect.
System can also have Gstreamer provided OSS implementation of udp source (udpsrc) component. In that case system would have two implementations for udp source - udpsrc and nvdsudpsrc.
nvdsudpsrc component can only be used with NVIDIA ConnectX-5 and above cards after having installed Rivermax SDK and its license.
-
Download and setup the
Rivermax1.70.x SDK here: https://developer.nvidia.com/networking/rivermax-getting-started -
Follow the instruction on the SDK page to obtain
Rivermaxdevelopment license. -
To select
nvdsudpsrcout of two installations, use eitherLOCAL_IFACE_IPenvironment variable orlocal-iface-ipproperty. Use the command below to export the environment variable: -
nvdsudpsrccomponent also requiresCAP_NET_RAWcapability. Either run the application that usesnvdsudpsrccomponent with superuser privilege or set theCAP_NET_RAWcapabilities using the following command.
-
Pipeline to receive and play Opus encoded 2 channel 48k audio RTP stream:
Mode 2: Receive RTP packets sent via Rivermax Media API
nvdsudpsrc receives RTP packets (with traffic shaping on the sender side) and pushes them to a downstream depayloader. The source pad uses application/x-rtp caps.
-
Pipeline to receive and display 10 bit YUV 4:2:2 1080p30 video stream using depayloader:
-
Pipeline to receive and play 24 bit 2 channel 48k audio stream using depayloader:
Mode 3: Receive uncompressed video / audio frames sent via Rivermax Media API (internal depacketization)
nvdsudpsrc performs depacketization internally as per SMPTE 2110-20/30 and outputs complete frames. No separate depayloader is needed. Activated by setting video/x-raw or audio/x-raw caps.
-
Pipeline to receive and display 10 bit YUV 4:2:2 1080p60 video stream without additional depayload component:
-
Pipeline to receive and play 24 bit 2 channel 48k audio stream without additional depayload component:
-
Pipeline to receive and display 10 bit YUV 4:2:2 1080p30 video stream without additional depayload component and using GPU Direct:
-
Pipeline to receive and display 10 bit YUV 4:2:2 1080p30 video stream, which uses RTP header timestamp for buffer PTS/Running time of pipeline:
-
Pipeline to receive 10 bit YUV 4:2:2 1080p30 video stream, use RTP header timestamp for buffer PTS/Running time of pipeline and pass the same timestamp to next node using nvdsudpsink:
Generic data as output
In this mode, nvdsudpsrc removes RTP headers and combines payloads into frames based on payload-multiple count. Activated by setting application/x-custom caps.
-
Pipeline to receive and depacketize generic payload. Following pipeline receives uncompressed video as generic payload:
SMPTE ST 2110-40 ancillary data (RFC 8331)
In this mode, nvdsudpsrc depayloads RFC 8331 RTP packets back into ST2038 wire-format buffers (one buffer per ANC packet). No downstream depayloader is required. Activated by setting meta/x-st-2038 caps. header-size=20 accounts for the 12-byte RTP header plus the 8-byte RFC 8331 ANC payload header.
-
Pipeline to receive an ST 2110-40 ancillary data stream and dump the ANC buffers for inspection:
-
Pipeline to receive an ST 2110-40 ancillary data stream over redundant paths using SMPTE 2022-7. The
st2022-7-streamsandlocal-iface-iplists are paired in order (first stream — first NIC, second stream — second NIC):