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