gstreamer/subprojects/gst-docs/markdown/additional/rtp.md

5.4 KiB

RTP and RTSP support

GStreamer has excellent support for both RTP and RTSP, and its RTP/RTSP stack has proved itself over years of being widely used in production use in a variety of mission-critical and low-latency scenarios, from small embedded devices to large-scale videoconferencing and command-and-control systems.

GStreamer RTSP Server

GStreamer's RTSP server (gst-rtsp-server) is a featureful and easy-to-use library that allows applications to implement a complete RTSP server with just a couple of lines of code.

It is multi-threaded, scalable and flexible, and provides support for static or dynamic mount points, authentication, retransmission (rtx), encryption (srtp, secure RTP), UDP unicast and multicast as well as TCP interleaving, seeking, and optionally also cgroup integration for advanced resource management and control. It can also distribute a GStreamer net client clock to GStreamer RTSP clients to facilitate multi-device synchronization.

GStreamer RTSP Client

The GStreamer rtspsrc element from gst-plugins-good is GStreamer's high-level RTSP client abstraction. It can be used as a standalone element directly, or can be used via playbin by passing an rtsp:// URI to playbin. rtspsrc features a number of GObject properties that allow you to configure it in all kinds of different ways, most notably a "latency" property to configure the default jitterbuffer latency, which you may want to configure to a lower value to achieve lower latency.

RTP components

Most of GStreamer's key RTP components live in gst-plugins-good:

  • The rtpmanager plugin contains elements like rtpbin and rtpjitterbuffer
  • The rtp plugin contains RTP payloading and depayloading elements for many different codecs and container formats

with some lower-level libraries in gst-plugins-base:

  • The GStreamer RTP library contains things such as RTP payloader/depayloader base classes and functions to handle RTP and RTCP buffers
  • The GStreamer MIKEY library contains helper functions to deal with MIKEY messages for secure RTP
  • The GStreamer RTSP library contains low-level RTSP functionality used by gst-rtsp-server and higher-level objects such as rtspsrc.
  • The GStreamer SDP library contains utility functions for SDP message parsing and creation.

Some of the main components are:

  • rtpbin is the high-level RTP component and supports sending and receiving, just sending or just receiving data, with and without RTCP support. This is the bin that does it all: it adapts dynamically to your needs based on the requested pads; it also contains an rtpjitterbuffer.
  • rtpjitterbuffer is an RTP buffer that controls network jitter and reorders packets. It also dumps packets that arrive too late, handles packet retransmission and lost packet notification and adjusts for sender-receiver clock drift.
  • rtpptdemux is an element that usually sits on the rtpbin src pad and will detect any new payload types that arrive in the RTP stream. It will then create a pad for that new payload and you can connect a depayloader/decoder pipeline to that pad.
  • rtpssrcdemux is an element that usually sits on the rtpbin src pad and will detect any new SSRCs that arrive in the RTP stream. It will then create a pad for that new SSRC and you can connect a depayloader/decoder pipeline to that pad.
  • GstRTPBaseDepayload is a base class for RTP depayloaders
  • GstRTPBasePayload is a base class for RTP payloaders
  • GstRTPBaseAudioPayload is a base class for audio RTP payloaders

Note that many RTP elements assume they receive RTP buffers with GstNetAddressMeta meta data set on them (as udpsrc will produce).