Object Hierarchy:

Object hierarchy for Pad


public class Pad : Object

A Element is linked to other elements via "pads", which are extremely light-weight generic link points.

Pads have a PadDirection, source pads produce data, sink pads consume data.

Pads are typically created from a PadTemplate with Pad.from_template and are then added to a Element. This usually happens when the element is created but it can also happen dynamically based on the data that the element is processing or based on the pads that the application requests.

Pads without pad templates can be created with Pad, which takes a direction and a name as an argument. If the name is null, then a guaranteed unique name will be assigned to it.

A Element creating a pad will typically use the various gst_pad_set_*_function() calls to register callbacks for events, queries or dataflow on the pads.

gst_pad_get_parent will retrieve the Element that owns the pad.

After two pads are retrieved from an element by get_static_pad, the pads can be linked with gst_pad_link. (For quick links, you can also use link, which will make the obvious link for you if it's straightforward.). Pads can be unlinked again with unlink. get_peer can be used to check what the pad is linked to.

Before dataflow is possible on the pads, they need to be activated with set_active.

query and peer_query can be used to query various properties of the pad and the stream.

To send a Event on a pad, use send_event and push_event. Some events will be sticky on the pad, meaning that after they pass on the pad they can be queried later with get_sticky_event and sticky_events_foreach. get_current_caps and has_current_caps are convenience functions to query the current sticky CAPS event on a pad.

GstElements will use push and pull_range to push out or pull in a buffer.

The dataflow, events and queries that happen on a pad can be monitored with probes that can be installed with add_probe. is_blocked can be used to check if a block probe is installed on the pad. is_blocking checks if the blocking probe is currently blocking the pad. remove_probe is used to remove a previously installed probe and unblock blocking probes if any.

Pad have an offset that can be retrieved with get_offset. This offset will be applied to the running_time of all data passing over the pad. set_offset can be used to change the offset.

Convenience functions exist to start, pause and stop the task on a pad with start_task, pause_task and stop_task respectively.

Example: Dynamic pipelines:

// See
// for a detailed description

public class Main {
private Gst.Pipeline pipeline;
private Gst.Element source;
private Gst.Element convert;
private Gst.Element sink;

// Handler for the pad-added signal.
// This function will be called by the pad-added signal.
private void pad_added_handler (Gst.Element src, Gst.Pad new_pad) {
Gst.Pad sink_pad = this.convert.get_static_pad ("sink");
print ("Received new pad '%s' from '%s':\n",,;

// If our converter is already linked, we have nothing to do here:
if (sink_pad.is_linked ()) {
print (" We are already linked. Ignoring.\n");
return ;

// Check the new pad's type:
Gst.Caps new_pad_caps = new_pad.query_caps (null);
weak Gst.Structure new_pad_struct = new_pad_caps.get_structure (0);
string new_pad_type = new_pad_struct.get_name ();
if (!new_pad_type.has_prefix ("audio/x-raw")) {
print (" It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type);
return ;

// Attempt the link:
Gst.PadLinkReturn ret = (sink_pad);
if (ret != Gst.PadLinkReturn.OK) {
print (" Type is '%s' but link failed.\n", new_pad_type);
} else {
print (" Link succeeded (type '%s').\n", new_pad_type);

// Example runner
public int run () {
// Create the elements:
this.source = Gst.ElementFactory.make ("uridecodebin", "source");
this.convert = Gst.ElementFactory.make ("audioconvert", "convert");
this.sink = Gst.ElementFactory.make ("autoaudiosink", "sink");

// Create the empty pipeline:
this.pipeline = new Gst.Pipeline ("test-pipeline");

if (this.pipeline == null || this.source == null || this.convert == null || this.sink == null) {
print ("Not all elements could be created.\n");
return -1;

// Build the pipeline. Note that we are NOT linking the source at this
// point. We will do it later.

this.pipeline.add_many (this.source, this.convert , this.sink);
if (! (this.sink)) {
print ("Elements could not be linked.\n");
return -1;

// Set the URI to play:
this.source.set ("uri", "");

// Connect to the pad-added signal:
this.source.pad_added.connect (pad_added_handler);

// Start playing:
Gst.StateChangeReturn ret = this.pipeline.set_state (Gst.State.PLAYING);
if (ret == Gst.StateChangeReturn.FAILURE) {
stderr.puts ("Unable to set the pipeline to the playing state.\n");
return -1;

// Listen to the bus:
Gst.Bus bus = this.pipeline.get_bus ();
bool terminate = false;
do {
Gst.Message msg = bus.timed_pop_filtered (Gst.CLOCK_TIME_NONE,
Gst.MessageType.STATE_CHANGED | Gst.MessageType.ERROR | Gst.MessageType.EOS);

// Parse message:
if (msg != null) {
switch (msg.type) {
case Gst.MessageType.ERROR:
GLib.Error err;
string debug_info;

msg.parse_error (out err, out debug_info);
stderr.printf ("Error received from element %s: %s\n",, err.message);
stderr.printf ("Debugging information: %s\n", (debug_info != null)? debug_info : "none");
terminate = true;

case Gst.MessageType.EOS:
print ("End-Of-Stream reached.\n");
terminate = true;

case Gst.MessageType.STATE_CHANGED:
// We are only interested in state-changed messages from the pipeline:
if (msg.src == this.pipeline) {
Gst.State old_state;
Gst.State new_state;
Gst.State pending_state;

msg.parse_state_changed (out old_state, out new_state, out pending_state);
print ("Pipeline state changed from %s to %s:\n",
Gst.Element.state_get_name (old_state),
Gst.Element.state_get_name (new_state));

//We should not reach here:
assert_not_reached ();
} while (!terminate);

// Free resources:
bus = null;
this.pipeline.set_state (Gst.State.NULL);
this.pipeline = null;

return 0;

public static int main (string[] args) {
// Initialize GStreamer:
Gst.init (ref args);

// Run the example:
return new Main ().run ();

valac --pkg gstreamer-1.0 dynamic-pipelines.vala

All known sub-classes:

Namespace: Gst
Package: gstreamer-1.0



Static methods:

Creation methods:




Inherited Members: