:right-sidebar: True PadTemplate =================================================================== .. currentmodule:: gi.repository.Gst .. class:: PadTemplate(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gst.Object`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.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 :obj:`~gi.repository.Gst.Caps` attached to it to describe the media type they are capable of dealing with. :func:`~gi.repository.Gst.PadTemplate.get_caps` or :func:`~gi.repository.Gst.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 :obj:`~gi.repository.Gst.PadPresence` property which identifies the lifetime of the pad and that can be retrieved with :func:`~gi.repository.Gst.PAD_TEMPLATE_PRESENCE`. Also the direction of the pad can be retrieved from the :obj:`~gi.repository.Gst.PadTemplate` with :func:`~gi.repository.Gst.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 :func:`~gi.repository.Gst.Element.request_pad_simple` call to instantiate a pad from this template. Padtemplates can be created with :func:`~gi.repository.Gst.PadTemplate.new` or with gst_static_pad_template_get (), which creates a :obj:`~gi.repository.Gst.PadTemplate` from a :obj:`~gi.repository.Gst.StaticPadTemplate` that can be filled with the convenient :func:`~gi.repository.Gst.STATIC_PAD_TEMPLATE` macro. A padtemplate can be used to create a pad (see :func:`~gi.repository.Gst.Pad.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. .. code-block:: C :dedent: 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: .. code-block:: C :dedent: 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 ------------ .. rst-class:: interim-class .. class:: PadTemplate :no-index: .. classmethod:: new(name_template: str, direction: ~gi.repository.Gst.PadDirection, presence: ~gi.repository.Gst.PadPresence, caps: ~gi.repository.Gst.Caps) -> ~gi.repository.Gst.PadTemplate | None Creates a new pad template with a name according to the given template and with the given arguments. :param name_template: the name template. :param direction: the :obj:`~gi.repository.Gst.PadDirection` of the template. :param presence: the :obj:`~gi.repository.Gst.PadPresence` of the pad. :param caps: a :obj:`~gi.repository.Gst.Caps` set for the template. .. classmethod:: new_from_static_pad_template_with_gtype(pad_template: ~gi.repository.Gst.StaticPadTemplate, pad_type: ~gobject.GType) -> ~gi.repository.Gst.PadTemplate | None Converts a :obj:`~gi.repository.Gst.StaticPadTemplate` into a :obj:`~gi.repository.Gst.PadTemplate` with a type. .. versionadded:: 1.14 :param pad_template: the static pad template :param pad_type: The :obj:`~gi.repository.GObject.Type` of the pad to create .. classmethod:: new_with_gtype(name_template: str, direction: ~gi.repository.Gst.PadDirection, presence: ~gi.repository.Gst.PadPresence, caps: ~gi.repository.Gst.Caps, pad_type: ~gobject.GType) -> ~gi.repository.Gst.PadTemplate | None Creates a new pad template with a name according to the given template and with the given arguments. .. versionadded:: 1.14 :param name_template: the name template. :param direction: the :obj:`~gi.repository.Gst.PadDirection` of the template. :param presence: the :obj:`~gi.repository.Gst.PadPresence` of the pad. :param caps: a :obj:`~gi.repository.Gst.Caps` set for the template. :param pad_type: The :obj:`~gi.repository.GObject.Type` of the pad to create Methods ------- .. rst-class:: interim-class .. class:: PadTemplate :no-index: .. method:: do_pad_created(self, pad: ~gi.repository.Gst.Pad) -> None :param pad: .. method:: get_caps() -> ~gi.repository.Gst.Caps Gets the capabilities of the pad template. .. method:: get_documentation_caps() -> ~gi.repository.Gst.Caps See :func:`~gi.repository.Gst.PadTemplate.set_documentation_caps`. .. versionadded:: 1.18 .. method:: pad_created(pad: ~gi.repository.Gst.Pad) -> None Emit the pad-created signal for this template when created by this pad. :param pad: the :obj:`~gi.repository.Gst.Pad` that created it .. method:: set_documentation_caps(caps: ~gi.repository.Gst.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. .. versionadded:: 1.18 :param caps: the documented capabilities Properties ---------- .. rst-class:: interim-class .. class:: PadTemplate :no-index: .. attribute:: props.caps :type: ~gi.repository.Gst.Caps The capabilities of the pad described by the pad template. .. attribute:: props.direction :type: ~gi.repository.Gst.PadDirection The direction of the pad described by the pad template. .. attribute:: props.gtype :type: ~gobject.GType The type of the None singleton. .. versionadded:: 1.14 .. attribute:: props.name_template :type: str The type of the None singleton. .. attribute:: props.presence :type: ~gi.repository.Gst.PadPresence When the pad described by the pad template will become available. Signals ------- .. rst-class:: interim-class .. class:: PadTemplate.signals :no-index: .. method:: pad_created(pad: ~gi.repository.Gst.Pad) -> None The type of the None singleton. :param pad: the pad that was created. Virtual Methods --------------- .. rst-class:: interim-class .. class:: PadTemplate :no-index: .. method:: do_pad_created(pad: ~gi.repository.Gst.Pad) -> None Emit the pad-created signal for this template when created by this pad. :param pad: the :obj:`~gi.repository.Gst.Pad` that created it Fields ------ .. rst-class:: interim-class .. class:: PadTemplate :no-index: .. attribute:: caps .. attribute:: direction .. attribute:: name_template .. attribute:: object .. attribute:: presence