Gst.PadTemplate
const Gst = imports.gi.Gst; let pad_template = new Gst.PadTemplate({ caps: value, direction: value, name_template: value, presence: value, });
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 Gst.Caps attached to it to describe the media type they are capable of dealing with. Gst.get_caps or 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 Gst.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.PadTemplate with 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 Gst.Element.prototype.get_request_pad call to instantiate a pad from this template.
Padtemplates can be created with Gst.new or with gst_static_pad_template_get (), which creates a Gst.PadTemplate from a Gst.StaticPadTemplate that can be filled with the convenient GST_STATIC_PAD_TEMPLATE() macro.
A padtemplate can be used to create a pad (see Gst.Pad.new_from_template or gst_pad_new_from_static_template ()) or to add to an element class (see gst_element_class_add_pad_template ()).
The following code example shows the code to create a pad from a padtemplate. <example> <title>Create a pad from a padtemplate</title> <programlisting> 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"); ... } </programlisting> </example>
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: <informalexample> <programlisting> static void my_element_class_init (GstMyElementClass *klass) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&my_template)); } </programlisting> </informalexample>
Last reviewed on 2006-02-14 (0.10.3)
Hierarchy
-
GObject.Object
-
GObject.InitiallyUnowned
-
Gst.Object
- Gst.PadTemplate
-
-