1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GstPadTemplate.html
27  * outPack = gstreamer
28  * outFile = PadTemplate
29  * strct   = GstPadTemplate
30  * realStrct=
31  * ctorStrct=
32  * clss    = PadTemplate
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_pad_template_
41  * 	- gst_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gstreamer.Pad
49  * 	- gstreamer.Caps
50  * structWrap:
51  * 	- GstCaps* -> Caps
52  * 	- GstPad* -> Pad
53  * 	- GstPadTemplate* -> PadTemplate
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gstreamer.PadTemplate;
60 
61 public  import gstreamerc.gstreamertypes;
62 
63 private import gstreamerc.gstreamer;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 
70 private import glib.Str;
71 private import gstreamer.Pad;
72 private import gstreamer.Caps;
73 
74 
75 
76 private import gstreamer.ObjectGst;
77 
78 /**
79  * Description
80  * Padtemplates describe the possible media types a pad or an elementfactory can
81  * handle. This allows for both inspection of handled types before loading the
82  * element plugin as well as identifying pads on elements that are not yet
83  * created (request or sometimes pads).
84  * Pad and PadTemplates have GstCaps attached to it to describe the media type
85  * they are capable of dealing with. gst_pad_template_get_caps() or
86  * GST_PAD_TEMPLATE_CAPS() are used to get the caps of a padtemplate. It's not
87  * possible to modify the caps of a padtemplate after creation.
88  * PadTemplates have a GstPadPresence property which identifies the lifetime
89  * of the pad and that can be retrieved with GST_PAD_TEMPLATE_PRESENCE(). Also
90  * the direction of the pad can be retrieved from the GstPadTemplate with
91  * GST_PAD_TEMPLATE_DIRECTION().
92  * The GST_PAD_TEMPLATE_NAME_TEMPLATE() is important for GST_PAD_REQUEST pads
93  * because it has to be used as the name in the gst_element_request_pad_by_name()
94  * call to instantiate a pad from this template.
95  * Padtemplates can be created with gst_pad_template_new() or with
96  * gst_static_pad_template_get(), which creates a GstPadTemplate from a
97  * GstStaticPadTemplate that can be filled with the
98  * convenient GST_STATIC_PAD_TEMPLATE() macro.
99  * A padtemplate can be used to create a pad (see gst_pad_new_from_template()
100  * or gst_pad_new_from_static_template()) or to add to an element class
101  * (see gst_element_class_add_pad_template()).
102  * The following code example shows the code to create a pad from a padtemplate.
103  * $(DDOC_COMMENT example)
104  * The following example shows you how to add the padtemplate to an
105  * element class, this is usually done in the base_init of the class:
106  * $(DDOC_COMMENT example)
107  * Last reviewed on 2006-02-14 (0.10.3)
108  */
109 public class PadTemplate : ObjectGst
110 {
111 	
112 	/** the main Gtk struct */
113 	protected GstPadTemplate* gstPadTemplate;
114 	
115 	
116 	public GstPadTemplate* getPadTemplateStruct()
117 	{
118 		return gstPadTemplate;
119 	}
120 	
121 	
122 	/** the main Gtk struct as a void* */
123 	protected override void* getStruct()
124 	{
125 		return cast(void*)gstPadTemplate;
126 	}
127 	
128 	/**
129 	 * Sets our main struct and passes it to the parent class
130 	 */
131 	public this (GstPadTemplate* gstPadTemplate)
132 	{
133 		super(cast(GstObject*)gstPadTemplate);
134 		this.gstPadTemplate = gstPadTemplate;
135 	}
136 	
137 	protected override void setStruct(GObject* obj)
138 	{
139 		super.setStruct(obj);
140 		gstPadTemplate = cast(GstPadTemplate*)obj;
141 	}
142 	
143 	/**
144 	 */
145 	int[string] connectedSignals;
146 	
147 	void delegate(Pad, PadTemplate)[] onPadCreatedListeners;
148 	/**
149 	 * This signal is fired when an element creates a pad from this template.
150 	 * See Also
151 	 * GstPad, GstElementFactory
152 	 */
153 	void addOnPadCreated(void delegate(Pad, PadTemplate) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
154 	{
155 		if ( !("pad-created" in connectedSignals) )
156 		{
157 			Signals.connectData(
158 			getStruct(),
159 			"pad-created",
160 			cast(GCallback)&callBackPadCreated,
161 			cast(void*)this,
162 			null,
163 			connectFlags);
164 			connectedSignals["pad-created"] = 1;
165 		}
166 		onPadCreatedListeners ~= dlg;
167 	}
168 	extern(C) static void callBackPadCreated(GstPadTemplate* padTemplateStruct, GstPad* pad, PadTemplate _padTemplate)
169 	{
170 		foreach ( void delegate(Pad, PadTemplate) dlg ; _padTemplate.onPadCreatedListeners )
171 		{
172 			dlg(ObjectG.getDObject!(Pad)(pad), _padTemplate);
173 		}
174 	}
175 	
176 	
177 	/**
178 	 * Converts a GstStaticPadTemplate into a GstPadTemplate.
179 	 * Params:
180 	 * padTemplate = the static pad template
181 	 * Returns: a new GstPadTemplate.
182 	 */
183 	public static PadTemplate staticPadTemplateGet(GstStaticPadTemplate* padTemplate)
184 	{
185 		// GstPadTemplate* gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
186 		auto p = gst_static_pad_template_get(padTemplate);
187 		
188 		if(p is null)
189 		{
190 			return null;
191 		}
192 		
193 		return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p);
194 	}
195 	
196 	/**
197 	 * Gets the capabilities of the static pad template.
198 	 * Params:
199 	 * templ = a GstStaticPadTemplate to get capabilities of.
200 	 * Returns: the GstCaps of the static pad template. If you need to keep a reference to the caps, take a ref (see gst_caps_ref()).
201 	 */
202 	public static Caps staticPadTemplateGetCaps(GstStaticPadTemplate* templ)
203 	{
204 		// GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
205 		auto p = gst_static_pad_template_get_caps(templ);
206 		
207 		if(p is null)
208 		{
209 			return null;
210 		}
211 		
212 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
213 	}
214 	
215 	/**
216 	 * Creates a new pad template with a name according to the given template
217 	 * and with the given arguments. This functions takes ownership of the provided
218 	 * caps, so be sure to not use them afterwards.
219 	 * Params:
220 	 * nameTemplate = the name template.
221 	 * direction = the GstPadDirection of the template.
222 	 * presence = the GstPadPresence of the pad.
223 	 * caps = a GstCaps set for the template. The caps are taken ownership of.
224 	 * Throws: ConstructionException GTK+ fails to create the object.
225 	 */
226 	public this (string nameTemplate, GstPadDirection direction, GstPadPresence presence, Caps caps)
227 	{
228 		// GstPadTemplate* gst_pad_template_new (const gchar *name_template,  GstPadDirection direction,  GstPadPresence presence,  GstCaps *caps);
229 		auto p = gst_pad_template_new(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct());
230 		if(p is null)
231 		{
232 			throw new ConstructionException("null returned by gst_pad_template_new(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct())");
233 		}
234 		this(cast(GstPadTemplate*) p);
235 	}
236 	
237 	/**
238 	 * Gets the capabilities of the pad template.
239 	 * Returns: the GstCaps of the pad template. If you need to keep a reference to the caps, take a ref (see gst_caps_ref()). Signal Details The "pad-created" signal void user_function (GstPadTemplate *pad_template, GstPad *pad, gpointer user_data) : Run Last This signal is fired when an element creates a pad from this template.
240 	 */
241 	public Caps getCaps()
242 	{
243 		// GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
244 		auto p = gst_pad_template_get_caps(gstPadTemplate);
245 		
246 		if(p is null)
247 		{
248 			return null;
249 		}
250 		
251 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
252 	}
253 }