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