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 module gstreamer.GhostPad;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gstreamer.ObjectGst;
31 private import gstreamer.Pad;
32 private import gstreamer.PadTemplate;
33 private import gstreamer.ProxyPad;
34 private import gstreamerc.gstreamer;
35 public  import gstreamerc.gstreamertypes;
36 
37 
38 /**
39  * GhostPads are useful when organizing pipelines with #GstBin like elements.
40  * The idea here is to create hierarchical element graphs. The bin element
41  * contains a sub-graph. Now one would like to treat the bin-element like any
42  * other #GstElement. This is where GhostPads come into play. A GhostPad acts as
43  * a proxy for another pad. Thus the bin can have sink and source ghost-pads
44  * that are associated with sink and source pads of the child elements.
45  * 
46  * If the target pad is known at creation time, gst_ghost_pad_new() is the
47  * function to use to get a ghost-pad. Otherwise one can use gst_ghost_pad_new_no_target()
48  * to create the ghost-pad and use gst_ghost_pad_set_target() to establish the
49  * association later on.
50  * 
51  * Note that GhostPads add overhead to the data processing of a pipeline.
52  */
53 public class GhostPad : ProxyPad
54 {
55 	/** the main Gtk struct */
56 	protected GstGhostPad* gstGhostPad;
57 
58 	/** Get the main Gtk struct */
59 	public GstGhostPad* getGhostPadStruct()
60 	{
61 		return gstGhostPad;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gstGhostPad;
68 	}
69 
70 	protected override void setStruct(GObject* obj)
71 	{
72 		gstGhostPad = cast(GstGhostPad*)obj;
73 		super.setStruct(obj);
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (GstGhostPad* gstGhostPad, bool ownedRef = false)
80 	{
81 		this.gstGhostPad = gstGhostPad;
82 		super(cast(GstProxyPad*)gstGhostPad, ownedRef);
83 	}
84 
85 
86 	/** */
87 	public static GType getType()
88 	{
89 		return gst_ghost_pad_get_type();
90 	}
91 
92 	/**
93 	 * Create a new ghostpad with @target as the target. The direction will be taken
94 	 * from the target pad. @target must be unlinked.
95 	 *
96 	 * Will ref the target.
97 	 *
98 	 * Params:
99 	 *     name = the name of the new pad, or %NULL to assign a default name
100 	 *     target = the pad to ghost.
101 	 *
102 	 * Return: a new #GstPad, or %NULL in
103 	 *     case of an error.
104 	 *
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this(string name, Pad target)
108 	{
109 		auto p = gst_ghost_pad_new(Str.toStringz(name), (target is null) ? null : target.getPadStruct());
110 		
111 		if(p is null)
112 		{
113 			throw new ConstructionException("null returned by new");
114 		}
115 		
116 		this(cast(GstGhostPad*) p);
117 	}
118 
119 	/**
120 	 * Create a new ghostpad with @target as the target. The direction will be taken
121 	 * from the target pad. The template used on the ghostpad will be @template.
122 	 *
123 	 * Will ref the target.
124 	 *
125 	 * Params:
126 	 *     name = the name of the new pad, or %NULL to assign a default name.
127 	 *     target = the pad to ghost.
128 	 *     templ = the #GstPadTemplate to use on the ghostpad.
129 	 *
130 	 * Return: a new #GstPad, or %NULL in
131 	 *     case of an error.
132 	 *
133 	 * Throws: ConstructionException GTK+ fails to create the object.
134 	 */
135 	public this(string name, Pad target, PadTemplate templ)
136 	{
137 		auto p = gst_ghost_pad_new_from_template(Str.toStringz(name), (target is null) ? null : target.getPadStruct(), (templ is null) ? null : templ.getPadTemplateStruct());
138 		
139 		if(p is null)
140 		{
141 			throw new ConstructionException("null returned by new_from_template");
142 		}
143 		
144 		this(cast(GstGhostPad*) p, true);
145 	}
146 
147 	/**
148 	 * Create a new ghostpad without a target with the given direction.
149 	 * A target can be set on the ghostpad later with the
150 	 * gst_ghost_pad_set_target() function.
151 	 *
152 	 * The created ghostpad will not have a padtemplate.
153 	 *
154 	 * Params:
155 	 *     name = the name of the new pad, or %NULL to assign a default name.
156 	 *     dir = the direction of the ghostpad
157 	 *
158 	 * Return: a new #GstPad, or %NULL in
159 	 *     case of an error.
160 	 *
161 	 * Throws: ConstructionException GTK+ fails to create the object.
162 	 */
163 	public this(string name, GstPadDirection dir)
164 	{
165 		auto p = gst_ghost_pad_new_no_target(Str.toStringz(name), dir);
166 		
167 		if(p is null)
168 		{
169 			throw new ConstructionException("null returned by new_no_target");
170 		}
171 		
172 		this(cast(GstGhostPad*) p, true);
173 	}
174 
175 	/**
176 	 * Create a new ghostpad based on @templ, without setting a target. The
177 	 * direction will be taken from the @templ.
178 	 *
179 	 * Params:
180 	 *     name = the name of the new pad, or %NULL to assign a default name
181 	 *     templ = the #GstPadTemplate to create the ghostpad from.
182 	 *
183 	 * Return: a new #GstPad, or %NULL in
184 	 *     case of an error.
185 	 *
186 	 * Throws: ConstructionException GTK+ fails to create the object.
187 	 */
188 	public this(string name, PadTemplate templ)
189 	{
190 		auto p = gst_ghost_pad_new_no_target_from_template(Str.toStringz(name), (templ is null) ? null : templ.getPadTemplateStruct());
191 		
192 		if(p is null)
193 		{
194 			throw new ConstructionException("null returned by new_no_target_from_template");
195 		}
196 		
197 		this(cast(GstGhostPad*) p, true);
198 	}
199 
200 	/**
201 	 * Invoke the default activate mode function of a ghost pad.
202 	 *
203 	 * Params:
204 	 *     pad = the #GstPad to activate or deactivate.
205 	 *     parent = the parent of @pad or %NULL
206 	 *     mode = the requested activation mode
207 	 *     active = whether the pad should be active or not.
208 	 *
209 	 * Return: %TRUE if the operation was successful.
210 	 */
211 	public static bool activateModeDefault(Pad pad, ObjectGst parent, GstPadMode mode, bool active)
212 	{
213 		return gst_ghost_pad_activate_mode_default((pad is null) ? null : pad.getPadStruct(), (parent is null) ? null : parent.getObjectGstStruct(), mode, active) != 0;
214 	}
215 
216 	/**
217 	 * Invoke the default activate mode function of a proxy pad that is
218 	 * owned by a ghost pad.
219 	 *
220 	 * Params:
221 	 *     pad = the #GstPad to activate or deactivate.
222 	 *     parent = the parent of @pad or %NULL
223 	 *     mode = the requested activation mode
224 	 *     active = whether the pad should be active or not.
225 	 *
226 	 * Return: %TRUE if the operation was successful.
227 	 */
228 	public static bool internalActivateModeDefault(Pad pad, ObjectGst parent, GstPadMode mode, bool active)
229 	{
230 		return gst_ghost_pad_internal_activate_mode_default((pad is null) ? null : pad.getPadStruct(), (parent is null) ? null : parent.getObjectGstStruct(), mode, active) != 0;
231 	}
232 
233 	/**
234 	 * Finish initialization of a newly allocated ghost pad.
235 	 *
236 	 * This function is most useful in language bindings and when subclassing
237 	 * #GstGhostPad; plugin and application developers normally will not call this
238 	 * function. Call this function directly after a call to g_object_new
239 	 * (GST_TYPE_GHOST_PAD, "direction", @dir, ..., NULL).
240 	 *
241 	 * Return: %TRUE if the construction succeeds, %FALSE otherwise.
242 	 */
243 	public bool construct()
244 	{
245 		return gst_ghost_pad_construct(gstGhostPad) != 0;
246 	}
247 
248 	/**
249 	 * Get the target pad of @gpad. Unref target pad after usage.
250 	 *
251 	 * Return: the target #GstPad, can be
252 	 *     %NULL if the ghostpad has no target set. Unref target pad after
253 	 *     usage.
254 	 */
255 	public Pad getTarget()
256 	{
257 		auto p = gst_ghost_pad_get_target(gstGhostPad);
258 		
259 		if(p is null)
260 		{
261 			return null;
262 		}
263 		
264 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
265 	}
266 
267 	/**
268 	 * Set the new target of the ghostpad @gpad. Any existing target
269 	 * is unlinked and links to the new target are established. if @newtarget is
270 	 * %NULL the target will be cleared.
271 	 *
272 	 * Params:
273 	 *     newtarget = the new pad target
274 	 *
275 	 * Return: %TRUE if the new target could be set. This function
276 	 *     can return %FALSE when the internal pads could not be linked.
277 	 */
278 	public bool setTarget(Pad newtarget)
279 	{
280 		return gst_ghost_pad_set_target(gstGhostPad, (newtarget is null) ? null : newtarget.getPadStruct()) != 0;
281 	}
282 }