Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

tut-gst-link-elements-intro

Linking Elements

You can link the different pads of elements together so that the elements form a chain.

linked-elements.png

By linking these three elements, we have created a very simple chain. The effect of this will be that the output of the source element (element1) will be used as input for the filter element (element2). The filter element will do something with the data and send the result to the final sink element (element3).

Imagine the above graph as a simple MPEG audio decoder. The source element is a disk source, the filter element is the MPEG decoder and the sink element is your audiocard. We will use this simple graph to construct an MPEG player later in this manual.

Making Simple Links

You can link two pads with:

srcpad = element1.get_pad("src")
sinpad = element2.get_pad("sink")

# link them
srcpad.link(sinkpad)

....

# and unlink them
srcpad.unlink(sinkpad)

A convenient shortcut for single-source, single-sink elements is the Gst::Element#link method:

# link them
element1.link(element2)

...

# and unlink them
element1.unlink(element2)

And an even more convenient shortcut is the Gst::Element#>> operator, which is an alias for Gst::Element#link:

# link them all
element1 >> element2 >> element3

You can query if a pad is linked with Gst::Pad#linked?.

Making Filtered Links

You can also force a specific media type on the link by using Gst::Pad#link_filtered and Gst::Element#link_filtered with capabilities.

Last modified:2004/04/01 20:56:02
Keyword(s):
References:[tut-gst]