udpsrc is a network source that reads UDP packets from the network. It can be combined with RTP depayloaders to implement RTP streaming.

The udpsrc element supports automatic port allocation by setting the property to 0. After setting the udpsrc to PAUSED, the allocated port can be obtained by reading the port property.

udpsrc can read from multicast groups by setting the property to the IP address of the multicast group.

Alternatively one can provide a custom socket to udpsrc with the property, udpsrc will then not allocate a socket itself but use the provided one.

The property is mainly used to give a type to the UDP packet so that they can be autoplugged in GStreamer pipelines. This is very useful for RTP implementations where the contents of the UDP packets is transferred out-of-bounds using SDP or other means.

The property is used to change the default kernel buffersizes used for receiving packets. The buffer size may be increased for high-volume connections, or may be decreased to limit the possible backlog of incoming data. The system places an absolute limit on these values, on Linux, for example, the default buffer size is typically 50K and can be increased to maximally 100K.

The property is used to strip off an arbitrary number of bytes from the start of the raw udp packet and can be used to strip off proprietary header, for example.

The udpsrc is always a live source. It does however not provide a GstClock, this is left for downstream elements such as an RTP session manager or demuxer (such as an MPEG demuxer). As with all live sources, the captured buffers will have their timestamp set to the current running time of the pipeline.

udpsrc implements a GstURIHandler interface that handles udp://host:port type URIs.

If the property is set to a value bigger than 0, udpsrc will generate an element message named GstUDPSrcTimeout if no data was received in the given timeout.

The message's structure contains one field:

  • guint64 timeout: the timeout in microseconds that expired when waiting for data.

The message is typically used to detect that no UDP arrives in the receiver because it is blocked by a firewall.

A custom file descriptor can be configured with the property. The socket will be closed when setting the element to READY by default. This behaviour can be overridden with the property, in which case the application is responsible for closing the file descriptor.


 gst-launch-1.0 -v udpsrc ! fakesink dump=1

A pipeline to read from the default port and dump the udp packets. To actually generate udp packets on the default port one can use the udpsink element. When running the following pipeline in another terminal, the above mentioned pipeline should dump data packets to the console.

 gst-launch-1.0 -v audiotestsrc ! udpsink
 gst-launch-1.0 -v udpsrc port=0 ! fakesink

read udp packets from a free port.



Implemented interfaces

Factory details

Authors: – Wim Taymans , Thijs Vermeir


Rank – none

Plugin – udp

Package – GStreamer Good Plug-ins

Pad Templates





Object typeGstPad



“address” gchararray

Address to receive packets for. This is equivalent to the multicast-group property for now

Flags : Read / Write

Default value :


“auto-multicast” gboolean

Automatically join/leave multicast groups

Flags : Read / Write

Default value : true


“buffer-size” gint

Size of the kernel receive buffer in bytes, 0=default

Flags : Read / Write

Default value : 0


“caps” GstCaps *

The caps of the source pad

Flags : Read / Write


“close-socket” gboolean

Close socket if passed as property on state change

Flags : Read / Write

Default value : true


“loop” gboolean

Can be used to disable multicast loopback.

Flags : Read / Write

Default value : true


“mtu” guint

Maximum expected packet size. This directly defines the allocation size of the receive buffer pool.

In case more data is received, a new GstMemory is appended to the output buffer, ensuring no data is lost, this however leads to that buffer being freed and reallocated.

Flags : Read / Write

Default value : 1492


“multicast-group” gchararray

The Address of multicast group to join. (DEPRECATED: Use address property instead)

Flags : Read / Write

Default value :


“multicast-iface” gchararray

The network interface on which to join the multicast group.This allows multiple interfaces separated by comma. ("eth0,eth1")

Flags : Read / Write

Default value : NULL


“port” gint

The port to receive the packets from, 0=allocate

Flags : Read / Write

Default value : 5004


“retrieve-sender-address” gboolean

Whether to retrieve the sender address and add it to the buffers as meta. Disabling this might result in minor performance improvements in certain scenarios.

Flags : Read / Write

Default value : true


“reuse” gboolean

Enable reuse of the port

Flags : Read / Write

Default value : true


“skip-first-bytes” gint

number of bytes to skip for each udp packet

Flags : Read / Write

Default value : 0


“socket” GSocket *

Socket to use for UDP reception. (NULL == allocate)

Flags : Read / Write


“socket-timestamp” Socket-timestamp-mode *

Can be used to read the timestamp on incoming buffers using socket control messages and set as the DTS.

Flags : Read / Write

Default value : disabled (0)


“timeout” guint64

Post a message after timeout nanoseconds (0 = disabled)

Flags : Read / Write

Default value : 0


“uri” gchararray

URI in the form of udp://multicast_group:port

Flags : Read / Write

Default value : udp://


“used-socket” GSocket *

Socket currently in use for UDP reception. (NULL = no socket)

Flags : Read

Named constants



disabled (0) – Disable additional timestamps
realtime (1) – Timestamp with realtime clock (nsec resolution, may not be monotonic)

The results of the search are