Padtemplates describe the possible media types a pad or an elementfactory can handle.
This allows for both inspection of handled types before loading the element plugin as well as identifying pads on elements that are not yet
created (request or sometimes pads).
Pad and PadTemplates have Caps attached to it to describe the media type they are
capable of dealing with. get_caps or
are used to get the caps of a padtemplate. It's not possible to modify the caps of a padtemplate after creation.
PadTemplates have a PadPresence property which identifies the lifetime of the
pad and that can be retrieved with
GST_PAD_TEMPLATE_PRESENCE. Also the direction of the pad can be retrieved from the
GST_PAD_TEMPLATE_NAME_TEMPLATE is important for GST_PAD_REQUEST pads because it has to be used as the name in the
get_request_pad call to instantiate a pad from this template.
Padtemplates can be created with PadTemplate or with
@get, which creates a PadTemplate from a
StaticPadTemplate that can be filled with the convenient
A padtemplate can be used to create a pad (see
Pad.from_template or Pad.from_static_template)
or to add to an element class (see add_pad_template).
The following code example shows the code to create a pad from a padtemplate.
Create a pad from a padtemplate:
GstStaticPadTemplate my_template =
"sink", // the name of the pad
GST_PAD_SINK, // the direction of the pad
GST_PAD_ALWAYS, // when this pad will be present
GST_STATIC_CAPS ( // the capabilities of the padtemplate
"channels = (int) [ 1, 6 ]"
pad = gst_pad_new_from_static_template (&my_template, "sink");
The following example shows you how to add the padtemplate to an element class, this is usually done in the base_init of the class:
my_element_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
Last reviewed on 2006-02-14 (0.10.3)