udpsrc

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 GstUDPSrc:port 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 GstUDPSrc:multicast-group property to the IP address of the multicast group.

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

The GstUDPSrc:caps 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 GstUDPSrc:buffer-size 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 GstUDPSrc:skip-first-bytes 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 GstUDPSrc:timeout 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 GstUDPSrc:socket property. The socket will be closed when setting the element to READY by default. This behaviour can be overridden with the GstUDPSrc:close-socket property, in which case the application is responsible for closing the file descriptor.

Examples

 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.

Hierarchy

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──GstBaseSrc
                    ╰──GstPushSrc
                        ╰──udpsrc

Implemented interfaces

Factory details

Authors: – Wim Taymans , Thijs Vermeir

Classification:Source/Network

Rank – none

Plugin – udp

Package – GStreamer Good Plug-ins

Pad Templates

src

ANY

Presencealways

Directionsrc

Object typeGstPad


Properties

address

“address” gchararray

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

Flags : Read / Write

Default value : 0.0.0.0


auto-multicast

“auto-multicast” gboolean

Automatically join/leave multicast groups

Flags : Read / Write

Default value : true


buffer-size

“buffer-size” gint

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

Flags : Read / Write

Default value : 0


caps

“caps” GstCaps *

The caps of the source pad

Flags : Read / Write


close-socket

“close-socket” gboolean

Close socket if passed as property on state change

Flags : Read / Write

Default value : true


loop

“loop” gboolean

Used for setting the multicast loop parameter. TRUE = enable, FALSE = disable

Flags : Read / Write

Default value : true


mtu

“mtu” guint

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

Flags : Read / Write

Default value : 1492


multicast-group

“multicast-group” gchararray

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

Flags : Read / Write

Default value : 0.0.0.0


multicast-iface

“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

“port” gint

The port to receive the packets from, 0=allocate

Flags : Read / Write

Default value : 5004


retrieve-sender-address

“retrieve-sender-address” gboolean

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

Flags : Read / Write

Default value : true


reuse

“reuse” gboolean

Enable reuse of the port

Flags : Read / Write

Default value : true


skip-first-bytes

“skip-first-bytes” gint

number of bytes to skip for each udp packet

Flags : Read / Write

Default value : 0


socket

“socket” GSocket *

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

Flags : Read / Write


timeout

“timeout” guint64

Post a message after timeout nanoseconds (0 = disabled)

Flags : Read / Write

Default value : 0


uri

“uri” gchararray

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

Flags : Read / Write

Default value : udp://0.0.0.0:5004


used-socket

“used-socket” GSocket *

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

Flags : Read


The results of the search are