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

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

The 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 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 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 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 nanoseconds 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 socket property. The socket will be closed when setting the element to READY by default. This behaviour can be overridden with the 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

    GstURIHandler

## Factory details

Authors: – Wim Taymans <wim>, Thijs Vermeir <thijs.vermeir></thijs.vermeir></wim>

Classification: – `Source/Network`

Rank – none

Plugin – udp

Package – GStreamer Good Plug-ins

## Pad Templates

### `src`

    ANY

Presence – always

Direction – src

Object type – GstPad

## 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

Can be used to disable multicast loopback.

Flags : Read / Write

Default value : true

Since : 1.8

### mtu

    “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

Since : 1.14

### 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

### multicast-source

    “multicast-source” gchararray

List of source to receive the stream from. (IGMPv3 SSM RFC 4604)

Flags : Read / Write

Default value : NULL

Since : 1.24

### 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 the buffers as meta. Disabling this might result in minor performance improvements in certain scenarios.

Flags : Read / Write

Default value : true

Since : 1.10

### 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

### socket-timestamp

    “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)

Since : 1.20

### 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

## Named constants

### Socket-timestamp-mode

#### Members

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

Since : 1.20

The results of the search are