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 gst.base.FlowCombiner;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gst.base.c.functions;
30 public  import gst.base.c.types;
31 private import gstreamer.Pad;
32 private import gtkd.Loader;
33 
34 
35 /**
36  * Utility struct to help handling #GstFlowReturn combination. Useful for
37  * #GstElement<!-- -->s that have multiple source pads and need to combine
38  * the different #GstFlowReturn for those pads.
39  * 
40  * #GstFlowCombiner works by using the last #GstFlowReturn for all #GstPad
41  * it has in its list and computes the combined return value and provides
42  * it to the caller.
43  * 
44  * To add a new pad to the #GstFlowCombiner use gst_flow_combiner_add_pad().
45  * The new #GstPad is stored with a default value of %GST_FLOW_OK.
46  * 
47  * In case you want a #GstPad to be removed, use gst_flow_combiner_remove_pad().
48  * 
49  * Please be aware that this struct isn't thread safe as its designed to be
50  * used by demuxers, those usually will have a single thread operating it.
51  * 
52  * These functions will take refs on the passed #GstPad<!-- -->s.
53  * 
54  * Aside from reducing the user's code size, the main advantage of using this
55  * helper struct is to follow the standard rules for #GstFlowReturn combination.
56  * These rules are:
57  * 
58  * * %GST_FLOW_EOS: only if all returns are EOS too
59  * * %GST_FLOW_NOT_LINKED: only if all returns are NOT_LINKED too
60  * * %GST_FLOW_ERROR or below: if at least one returns an error return
61  * * %GST_FLOW_NOT_NEGOTIATED: if at least one returns a not-negotiated return
62  * * %GST_FLOW_FLUSHING: if at least one returns flushing
63  * * %GST_FLOW_OK: otherwise
64  * 
65  * %GST_FLOW_ERROR or below, GST_FLOW_NOT_NEGOTIATED and GST_FLOW_FLUSHING are
66  * returned immediatelly from the gst_flow_combiner_update_flow() function.
67  *
68  * Since: 1.4
69  */
70 public class FlowCombiner
71 {
72 	/** the main Gtk struct */
73 	protected GstFlowCombiner* gstFlowCombiner;
74 	protected bool ownedRef;
75 
76 	/** Get the main Gtk struct */
77 	public GstFlowCombiner* getFlowCombinerStruct(bool transferOwnership = false)
78 	{
79 		if (transferOwnership)
80 			ownedRef = false;
81 		return gstFlowCombiner;
82 	}
83 
84 	/** the main Gtk struct as a void* */
85 	protected void* getStruct()
86 	{
87 		return cast(void*)gstFlowCombiner;
88 	}
89 
90 	/**
91 	 * Sets our main struct and passes it to the parent class.
92 	 */
93 	public this (GstFlowCombiner* gstFlowCombiner, bool ownedRef = false)
94 	{
95 		this.gstFlowCombiner = gstFlowCombiner;
96 		this.ownedRef = ownedRef;
97 	}
98 
99 	~this ()
100 	{
101 		if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef )
102 			gst_flow_combiner_unref(gstFlowCombiner);
103 	}
104 
105 
106 	/** */
107 	public static GType getType()
108 	{
109 		return gst_flow_combiner_get_type();
110 	}
111 
112 	/**
113 	 * Creates a new #GstFlowCombiner, use gst_flow_combiner_free() to free it.
114 	 *
115 	 * Returns: A new #GstFlowCombiner
116 	 *
117 	 * Since: 1.4
118 	 *
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this()
122 	{
123 		auto p = gst_flow_combiner_new();
124 
125 		if(p is null)
126 		{
127 			throw new ConstructionException("null returned by new");
128 		}
129 
130 		this(cast(GstFlowCombiner*) p);
131 	}
132 
133 	/**
134 	 * Adds a new #GstPad to the #GstFlowCombiner.
135 	 *
136 	 * Params:
137 	 *     pad = the #GstPad that is being added
138 	 *
139 	 * Since: 1.4
140 	 */
141 	public void addPad(Pad pad)
142 	{
143 		gst_flow_combiner_add_pad(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct());
144 	}
145 
146 	/**
147 	 * Removes all pads from a #GstFlowCombiner and resets it to its initial state.
148 	 *
149 	 * Since: 1.6
150 	 */
151 	public void clear()
152 	{
153 		gst_flow_combiner_clear(gstFlowCombiner);
154 	}
155 
156 	/**
157 	 * Frees a #GstFlowCombiner struct and all its internal data.
158 	 *
159 	 * Since: 1.4
160 	 */
161 	public void free()
162 	{
163 		gst_flow_combiner_free(gstFlowCombiner);
164 		ownedRef = false;
165 	}
166 
167 	/** */
168 	public FlowCombiner doref()
169 	{
170 		auto p = gst_flow_combiner_ref(gstFlowCombiner);
171 
172 		if(p is null)
173 		{
174 			return null;
175 		}
176 
177 		return ObjectG.getDObject!(FlowCombiner)(cast(GstFlowCombiner*) p, true);
178 	}
179 
180 	/**
181 	 * Removes a #GstPad from the #GstFlowCombiner.
182 	 *
183 	 * Params:
184 	 *     pad = the #GstPad to remove
185 	 *
186 	 * Since: 1.4
187 	 */
188 	public void removePad(Pad pad)
189 	{
190 		gst_flow_combiner_remove_pad(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct());
191 	}
192 
193 	/**
194 	 * Reset flow combiner and all pads to their initial state without removing pads.
195 	 *
196 	 * Since: 1.6
197 	 */
198 	public void reset()
199 	{
200 		gst_flow_combiner_reset(gstFlowCombiner);
201 	}
202 
203 	/** */
204 	public void unref()
205 	{
206 		gst_flow_combiner_unref(gstFlowCombiner);
207 	}
208 
209 	/**
210 	 * Computes the combined flow return for the pads in it.
211 	 *
212 	 * The #GstFlowReturn parameter should be the last flow return update for a pad
213 	 * in this #GstFlowCombiner. It will use this value to be able to shortcut some
214 	 * combinations and avoid looking over all pads again. e.g. The last combined
215 	 * return is the same as the latest obtained #GstFlowReturn.
216 	 *
217 	 * Params:
218 	 *     fret = the latest #GstFlowReturn received for a pad in this #GstFlowCombiner
219 	 *
220 	 * Returns: The combined #GstFlowReturn
221 	 *
222 	 * Since: 1.4
223 	 */
224 	public GstFlowReturn updateFlow(GstFlowReturn fret)
225 	{
226 		return gst_flow_combiner_update_flow(gstFlowCombiner, fret);
227 	}
228 
229 	/**
230 	 * Sets the provided pad's last flow return to provided value and computes
231 	 * the combined flow return for the pads in it.
232 	 *
233 	 * The #GstFlowReturn parameter should be the last flow return update for a pad
234 	 * in this #GstFlowCombiner. It will use this value to be able to shortcut some
235 	 * combinations and avoid looking over all pads again. e.g. The last combined
236 	 * return is the same as the latest obtained #GstFlowReturn.
237 	 *
238 	 * Params:
239 	 *     pad = the #GstPad whose #GstFlowReturn to update
240 	 *     fret = the latest #GstFlowReturn received for a pad in this #GstFlowCombiner
241 	 *
242 	 * Returns: The combined #GstFlowReturn
243 	 *
244 	 * Since: 1.6
245 	 */
246 	public GstFlowReturn updatePadFlow(Pad pad, GstFlowReturn fret)
247 	{
248 		return gst_flow_combiner_update_pad_flow(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct(), fret);
249 	}
250 }