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