2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GstPadTemplate.html
27 * outFile = PadTemplate
28 * strct = GstPadTemplate
51 * - GstPadTemplate* -> PadTemplate
56 module gstreamer
.PadTemplate
;
58 private import gstreamerc
.gstreamertypes
;
60 private import gstreamerc
.gstreamer
;
62 private import glib
.Str
;
63 private import gstreamer
.Pad
;
64 private import gstreamer
.Caps
;
70 * Padtemplates describe the possible media types a pad or an elementfactory can
71 * handle. This allows for both inspection of handled types before loading the
72 * element plugin as well as identifying pads on elements that are not yet
73 * created (request or sometimes pads).
74 * Pad and PadTemplates have GstCaps attached to it to describe the media type
75 * they are capable of dealing with. gst_pad_template_get_caps() or
76 * GST_PAD_TEMPLATE_CAPS() are used to get the caps of a padtemplate. It's not
77 * possible to modify the caps of a padtemplate after creation.
78 * PadTemplates have a GstPadPresence property which identifies the lifetime
79 * of the pad and that can be retrieved with GST_PAD_TEMPLATE_PRESENCE(). Also
80 * the direction of the pad can be retrieved from the GstPadTemplate with
81 * GST_PAD_TEMPLATE_DIRECTION().
82 * The GST_PAD_TEMPLATE_NAME_TEMPLATE() is important for GST_PAD_REQUEST pads
83 * because it has to be used as the name in the gst_element_request_pad_by_name()
84 * call to instantiate a pad from this template.
85 * Padtemplates can be created with gst_pad_template_new() or with
86 * gst_static_pad_template_get(), which creates a GstPadTemplate from a
87 * GstStaticPadTemplate that can be filled with the
88 * convenient GST_STATIC_PAD_TEMPLATE() macro.
89 * A padtemplate can be used to create a pad (see gst_pad_new_from_template()
90 * or gst_pad_new_from_static_template()) or to add to an element class
91 * (see gst_element_class_add_pad_template()).
92 * The following code example shows the code to create a pad from a padtemplate.
93 * Example12.Create a pad from a padtemplate
94 * GstStaticPadTemplate my_template =
95 * GST_STATIC_PAD_TEMPLATE (
96 * "sink", // the name of the pad
97 * GST_PAD_SINK, // the direction of the pad
98 * GST_PAD_ALWAYS, // when this pad will be present
99 * GST_STATIC_CAPS ( // the capabilities of the padtemplate
100 * "audio/x-raw-int, "
101 * "channels = (int) [ 1, 6 ]"
108 * pad = gst_pad_new_from_static_template (my_template, "sink");
111 * The following example shows you how to add the padtemplate to an
112 * element class, this is usually done in the base_init of the class:
114 * my_element_base_init (gpointer g_class)
116 * GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
117 * gst_element_class_add_pad_template (gstelement_class,
118 * gst_static_pad_template_get (my_template));
120 * Last reviewed on 2006-02-14 (0.10.3)
122 private import gstreamer
.ObjectGst
;
123 public class PadTemplate
: ObjectGst
126 /** the main Gtk struct */
127 protected GstPadTemplate
* gstPadTemplate
;
130 public GstPadTemplate
* getPadTemplateStruct()
132 return gstPadTemplate
;
136 /** the main Gtk struct as a void* */
137 protected void* getStruct()
139 return cast(void*)gstPadTemplate
;
143 * Sets our main struct and passes it to the parent class
145 public this (GstPadTemplate
* gstPadTemplate
)
147 super(cast(GstObject
*)gstPadTemplate
);
148 this.gstPadTemplate
= gstPadTemplate
;
154 // imports for the signal processing
155 private import gobject
.Signals
;
156 private import gtkc
.gdktypes
;
157 int[char[]] connectedSignals
;
159 void delegate(Pad
, PadTemplate
)[] onPadCreatedListeners
;
160 void addOnPadCreated(void delegate(Pad
, PadTemplate
) dlg
)
162 if ( !("pad-created" in connectedSignals
) )
167 cast(GCallback
)&callBackPadCreated
,
170 cast(ConnectFlags
)0);
171 connectedSignals
["pad-created"] = 1;
173 onPadCreatedListeners
~= dlg
;
175 extern(C
) static void callBackPadCreated(GstPadTemplate
* padTemplateStruct
, GstPad
* pad
, PadTemplate padTemplate
)
177 bit consumed
= false;
179 foreach ( void delegate(Pad
, PadTemplate
) dlg
; padTemplate
.onPadCreatedListeners
)
181 dlg(new Pad(pad
), padTemplate
);
191 * Converts a GstStaticPadTemplate into a GstPadTemplate.
193 * the static pad template
195 * a new GstPadTemplate.
197 public static PadTemplate
staticPadTemplateGet(GstStaticPadTemplate
* padTemplate
)
199 // GstPadTemplate* gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
200 return new PadTemplate( gst_static_pad_template_get(padTemplate
) );
204 * Gets the capabilities of the static pad template.
206 * a GstStaticPadTemplate to get capabilities of.
208 * the GstCaps of the static pad template. If you need to keep a
209 * reference to the caps, take a ref (see gst_caps_ref()).
211 public static Caps
staticPadTemplateGetCaps(GstStaticPadTemplate
* templ
)
213 // GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
214 return new Caps( gst_static_pad_template_get_caps(templ
) );
226 * Creates a new pad template with a name according to the given template
227 * and with the given arguments. This functions takes ownership of the provided
228 * caps, so be sure to not use them afterwards.
232 * the GstPadDirection of the template.
234 * the GstPadPresence of the pad.
236 * a GstCaps set for the template. The caps are taken ownership of.
238 * a new GstPadTemplate.
240 public this (char[] nameTemplate
, GstPadDirection direction
, GstPadPresence presence
, Caps caps
)
242 // GstPadTemplate* gst_pad_template_new (const gchar *name_template, GstPadDirection direction, GstPadPresence presence, GstCaps *caps);
243 this(cast(GstPadTemplate
*)gst_pad_template_new(Str
.toStringz(nameTemplate
), direction
, presence
, (caps
is null) ?
null : caps
.getCapsStruct()) );
247 * Gets the capabilities of the pad template.
249 * a GstPadTemplate to get capabilities of.
251 * the GstCaps of the pad template. If you need to keep a reference to
252 * the caps, take a ref (see gst_caps_ref()).
254 * The "pad-created" signal
255 * void user_function (GstPadTemplate *pad_template,
257 * gpointer user_data) : Run last
258 * This signal is fired when an element creates a pad from this template.
260 * the object which received the signal.
262 * the pad that was created.
264 * user data set when the signal handler was connected.
266 * GstPad, GstElementFactory
268 public Caps
getCaps()
270 // GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
271 return new Caps( gst_pad_template_get_caps(gstPadTemplate
) );