## udpsrc

udpsrc

## Properties

GstCaps * | caps | Read / Write
gchar * | multicast-group | Read / Write
gint | port | Read / Write
gchar * | uri | Read / Write
gint | buffer-size | Read / Write
guint64 | timeout | Read / Write
gint | skip-first-bytes | Read / Write
gboolean | auto-multicast | Read / Write
gchar * | multicast-iface | Read / Write
gboolean | reuse | Read / Write
gboolean | close-socket | Read / Write
GSocket * | socket | Read / Write
GSocket * | used-socket | Read
gchar * | address | Read / Write
gboolean | loop | Read / Write
gboolean | retrieve-sender-address | Read / Write
guint | mtu | Read / Write

## Types and Values

struct | GstUDPSrc

## Object Hierarchy

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

## Implemented Interfaces

GstUDPSrc implements GstURIHandler.

## Description

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 transfered 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 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 “socket” property. The socket will be closed when setting the element to READY by default. This behaviour can be overriden with the “close-socket” property, in which case the application is responsible for closing the file descriptor.

### Examples

    1

    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.

    1

    gst-launch-1.0 -v audiotestsrc ! udpsink

    1

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

read udp packets from a free port.

## Synopsis

### Element Information

plugin | udp
author | Wim Taymans <wim@fluendo.com>, Thijs Vermeir <thijs.vermeir@barco.com>
class | Source/Network

### Element Pads

name | src
direction | source
presence | always
details | ANY

## Functions

## Types and Values

### struct GstUDPSrc

    struct GstUDPSrc;

## Property Details

### The `“caps”` property

      “caps”                     GstCaps *

The caps of the source pad.

Owner: GstUDPSrc

Flags: Read / Write

### The `“multicast-group”` property

      “multicast-group”          gchar *

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: "0.0.0.0"

### The `“port”` property

      “port”                     gint

The port to receive the packets from, 0=allocate.

Owner: GstUDPSrc

Flags: Read / Write

Allowed values: [0,65535]

Default value: 5004

### The `“uri”` property

      “uri”                      gchar *

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: "udp://0.0.0.0:5004"

### The `“buffer-size”` property

      “buffer-size”              gint

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

Owner: GstUDPSrc

Flags: Read / Write

Allowed values: >= 0

Default value: 0

### The `“timeout”` property

      “timeout”                  guint64

Post a message after timeout nanoseconds (0 = disabled).

Owner: GstUDPSrc

Flags: Read / Write

Default value: 0

### The `“skip-first-bytes”` property

      “skip-first-bytes”         gint

number of bytes to skip for each udp packet.

Owner: GstUDPSrc

Flags: Read / Write

Allowed values: >= 0

Default value: 0

### The `“auto-multicast”` property

      “auto-multicast”           gboolean

Automatically join/leave multicast groups.

Owner: GstUDPSrc

Flags: Read / Write

Default value: TRUE

### The `“multicast-iface”` property

      “multicast-iface”          gchar *

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: NULL

### The `“reuse”` property

      “reuse”                    gboolean

Enable reuse of the port.

Owner: GstUDPSrc

Flags: Read / Write

Default value: TRUE

### The `“close-socket”` property

      “close-socket”             gboolean

Close socket if passed as property on state change.

Owner: GstUDPSrc

Flags: Read / Write

Default value: TRUE

### The `“socket”` property

      “socket”                   GSocket *

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

Owner: GstUDPSrc

Flags: Read / Write

### The `“used-socket”` property

      “used-socket”              GSocket *

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

Owner: GstUDPSrc

Flags: Read

### The `“address”` property

      “address”                  gchar *

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: "0.0.0.0"

### The `“loop”` property

      “loop”                     gboolean

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: TRUE

### The `“retrieve-sender-address”` property

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

Owner: GstUDPSrc

Flags: Read / Write

Default value: TRUE

### The `“mtu”` property

      “mtu”                      guint

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

Owner: GstUDPSrc

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 1492

## See Also

udpsink, multifdsink