udpsrc

udpsrc — Receive data over the network via UDP

Synopsis




                    GstUDPSrc;

Object Hierarchy


  GObject
   +----GstObject
         +----GstOsxAudioSink
               +----GstBaseSrc
                     +----GstPushSrc
                           +----GstUDPSrc

Implemented Interfaces

GstUDPSrc implements GstURIHandler.

Properties


  "caps"                     GstCaps               : Read / Write
  "multicast-group"          gchararray            : Read / Write
  "port"                     gint                  : Read / Write
  "uri"                      gchararray            : Read / Write
  "sockfd"                   gint                  : Read / Write
  "buffer-size"              gint                  : Read / Write
  "timeout"                  guint64               : Read / Write
  "closefd"                  gboolean              : Read / Write
  "skip-first-bytes"         gint                  : Read / Write

Description

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

Examples

Here is a simple pipeline to read from the default port and dump the udp packets.

gst-launch -v udpsrc ! fakesink dump=1

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 -v audiotestsrc ! udpsink

The udpsrc element supports automatic port allocation by setting the "port" property to 0. the following pipeline reads UDP from a free port.

gst-launch -v udpsrc port=0 ! fakesink

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 "sockfd" 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 usefull for RTP implementations where the contents of the UDP packets is transfered out-of-bounds using SDP or other means.

The "buffer" property is used to change the default kernel buffer sizes 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 upstream elements such as an RTP session manager or demuxer (such as an MPEG demuxer).

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

Last reviewed on 2007-03-29 (0.10.6)

Element Information

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

Details

GstUDPSrc

typedef struct _GstUDPSrc GstUDPSrc;

Property Details

The "caps" property

  "caps"                     GstCaps               : Read / Write

The caps of the source pad.


The "multicast-group" property

  "multicast-group"          gchararray            : Read / Write

The Address of multicast group to join.

Default value: "0.0.0.0"


The "port" property

  "port"                     gint                  : Read / Write

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

Allowed values: [0,65535]

Default value: 4951


The "uri" property

  "uri"                      gchararray            : Read / Write

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

Default value: "udp://0.0.0.0:4951"


The "sockfd" property

  "sockfd"                   gint                  : Read / Write

Socket to use for UDP reception. (-1 == allocate).

Allowed values: >= G_MAXULONG

Default value: -1


The "buffer-size" property

  "buffer-size"              gint                  : Read / Write

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

Allowed values: >= 0

Default value: 0


The "timeout" property

  "timeout"                  guint64               : Read / Write

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

Default value: 0


The "closefd" property

  "closefd"                  gboolean              : Read / Write

Close sockfd if passed as property on state change.

Default value: TRUE


The "skip-first-bytes" property

  "skip-first-bytes"         gint                  : Read / Write

number of bytes to skip for each udp packet.

Allowed values: >= 0

Default value: 0

See Also

udpsink, multifdsink