PadTemplate

class PadTemplate(**properties: Any)

Superclasses: Object, InitiallyUnowned, Object

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 PAD_TEMPLATE_CAPS() 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 PAD_TEMPLATE_PRESENCE(). Also the direction of the pad can be retrieved from the PadTemplate with PAD_TEMPLATE_DIRECTION().

The GST_PAD_TEMPLATE_NAME_TEMPLATE () is important for GST_PAD_REQUEST pads because it has to be used as the name in the request_pad_simple() call to instantiate a pad from this template.

Padtemplates can be created with new() or with gst_static_pad_template_get (), which creates a PadTemplate from a StaticPadTemplate that can be filled with the convenient STATIC_PAD_TEMPLATE() macro.

A padtemplate can be used to create a pad (see new_from_template() or gst_pad_new_from_static_template ()) or to add to an element class (see gst_element_class_add_static_pad_template ()).

The following code example shows the code to create a pad from a padtemplate.

GstStaticPadTemplate my_template =
GST_STATIC_PAD_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
    "audio/x-raw, "
      "channels = (int) [ 1, 6 ]"
  )
);
void
my_method (void)
{
  GstPad *pad;
  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 class_init of the class:

static void
my_element_class_init (GstMyElementClass *klass)
{
  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);

  gst_element_class_add_static_pad_template (gstelement_class, &my_template);
}

Constructors

class PadTemplate
classmethod new(name_template: str, direction: PadDirection, presence: PadPresence, caps: Caps) PadTemplate | None

Creates a new pad template with a name according to the given template and with the given arguments.

Parameters:
  • name_template – the name template.

  • direction – the PadDirection of the template.

  • presence – the PadPresence of the pad.

  • caps – a Caps set for the template.

classmethod new_from_static_pad_template_with_gtype(pad_template: StaticPadTemplate, pad_type: type) PadTemplate | None

Converts a StaticPadTemplate into a PadTemplate with a type.

Added in version 1.14.

Parameters:
  • pad_template – the static pad template

  • pad_type – The Type of the pad to create

classmethod new_with_gtype(name_template: str, direction: PadDirection, presence: PadPresence, caps: Caps, pad_type: type) PadTemplate | None

Creates a new pad template with a name according to the given template and with the given arguments.

Added in version 1.14.

Parameters:
  • name_template – the name template.

  • direction – the PadDirection of the template.

  • presence – the PadPresence of the pad.

  • caps – a Caps set for the template.

  • pad_type – The Type of the pad to create

Methods

class PadTemplate
get_caps() Caps

Gets the capabilities of the pad template.

get_documentation_caps() Caps

See set_documentation_caps().

Added in version 1.18.

pad_created(pad: Pad) None

Emit the pad-created signal for this template when created by this pad.

Parameters:

pad – the Pad that created it

set_documentation_caps(caps: Caps) None

Certain elements will dynamically construct the caps of their pad templates. In order not to let environment-specific information into the documentation, element authors should use this method to expose “stable” caps to the reader.

Added in version 1.18.

Parameters:

caps – the documented capabilities

Properties

class PadTemplate
props.caps: Caps

The capabilities of the pad described by the pad template.

props.direction: PadDirection

The direction of the pad described by the pad template.

props.gtype: type

The type of the pad described by the pad template.

Added in version 1.14.

props.name_template: str

The name template of the pad template.

props.presence: PadPresence

When the pad described by the pad template will become available.

Signals

class PadTemplate.signals
pad_created(pad: Pad) None

This signal is fired when an element creates a pad from this template.

Parameters:

pad – the pad that was created.

Virtual Methods

class PadTemplate
do_pad_created(pad: Pad) None

Emit the pad-created signal for this template when created by this pad.

Parameters:

pad – the Pad that created it

Fields

class PadTemplate
caps
direction
name_template
object
presence