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  * Conversion parameters:
26  * inFile  = GstPipeline.html
27  * outPack = gstreamer
28  * outFile = Pipeline
29  * strct   = GstPipeline
30  * realStrct=
31  * ctorStrct=GstElement
32  * clss    = Pipeline
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_pipeline_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gstreamer.Bus
48  * 	- gstreamer.Clock
49  * structWrap:
50  * 	- GstBus* -> Bus
51  * 	- GstClock* -> Clock
52  * module aliases:
53  * local aliases:
54  * overrides:
55  * 	- getBus
56  * 	- setClock
57  * 	- getClock
58  */
59 
60 module gstreamer.Pipeline;
61 
62 public  import gstreamerc.gstreamertypes;
63 
64 private import gstreamerc.gstreamer;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import glib.Str;
69 private import gstreamer.Bus;
70 private import gstreamer.Clock;
71 
72 
73 private import gstreamer.Bin;
74 
75 /**
76  * A GstPipeline is a special GstBin used as the toplevel container for
77  * the filter graph. The GstPipeline will manage the selection and
78  * distribution of a global GstClock as well as provide a GstBus to the
79  * application.
80  *
81  * gst_pipeline_new() is used to create a pipeline. when you are done with
82  * the pipeline, use gst_object_unref() to free its resources including all
83  * added GstElement objects (if not otherwise referenced).
84  *
85  * Elements are added and removed from the pipeline using the GstBin
86  * methods like gst_bin_add() and gst_bin_remove() (see GstBin).
87  *
88  * Before changing the state of the GstPipeline (see GstElement) a GstBus
89  * can be retrieved with gst_pipeline_get_bus(). This bus can then be
90  * used to receive GstMessage from the elements in the pipeline.
91  *
92  * By default, a GstPipeline will automatically flush the pending GstBus
93  * messages when going to the NULL state to ensure that no circular
94  * references exist when no messages are read from the GstBus. This
95  * behaviour can be changed with gst_pipeline_set_auto_flush_bus().
96  *
97  * When the GstPipeline performs the PAUSED to PLAYING state change it will
98  * select a clock for the elements. The clock selection algorithm will by
99  * default select a clock provided by an element that is most upstream
100  * (closest to the source). For live pipelines (ones that return
101  * GST_STATE_CHANGE_NO_PREROLL from the gst_element_set_state() call) this
102  * will select the clock provided by the live source. For normal pipelines
103  * this will select a clock provided by the sinks (most likely the audio
104  * sink). If no element provides a clock, a default GstSystemClock is used.
105  *
106  * The clock selection can be controlled with the gst_pipeline_use_clock()
107  * method, which will enforce a given clock on the pipeline. With
108  * gst_pipeline_auto_clock() the default clock selection algorithm can be
109  * restored.
110  *
111  * A GstPipeline maintains a running time for the elements. The running
112  * time is defined as the difference between the current clock time and
113  * the base time. When the pipeline goes to READY or a flushing seek is
114  * performed on it, the running time is reset to 0. When the pipeline is
115  * set from PLAYING to PAUSED, the current clock time is sampled and used to
116  * configure the base time for the elements when the pipeline is set
117  * to PLAYING again. The effect is that the running time (as the difference
118  * between the clock time and the base time) will count how much time was spent
119  * in the PLAYING state. This default behaviour can be changed with the
120  * gst_element_set_start_time() method.
121  *
122  * Last reviewed on 2012-03-29 (0.11.3)
123  */
124 public class Pipeline : Bin
125 {
126 	
127 	/** the main Gtk struct */
128 	protected GstPipeline* gstPipeline;
129 	
130 	
131 	/** Get the main Gtk struct */
132 	public GstPipeline* getPipelineStruct()
133 	{
134 		return gstPipeline;
135 	}
136 	
137 	
138 	/** the main Gtk struct as a void* */
139 	protected override void* getStruct()
140 	{
141 		return cast(void*)gstPipeline;
142 	}
143 	
144 	/**
145 	 * Sets our main struct and passes it to the parent class
146 	 */
147 	public this (GstPipeline* gstPipeline)
148 	{
149 		super(cast(GstBin*)gstPipeline);
150 		this.gstPipeline = gstPipeline;
151 	}
152 	
153 	protected override void setStruct(GObject* obj)
154 	{
155 		super.setStruct(obj);
156 		gstPipeline = cast(GstPipeline*)obj;
157 	}
158 	
159 	/**
160 	 */
161 	
162 	/**
163 	 * Create a new pipeline with the given name.
164 	 * Params:
165 	 * name = name of new pipeline. [allow-none]
166 	 * Throws: ConstructionException GTK+ fails to create the object.
167 	 */
168 	public this (string name)
169 	{
170 		// GstElement * gst_pipeline_new (const gchar *name);
171 		auto p = gst_pipeline_new(Str.toStringz(name));
172 		if(p is null)
173 		{
174 			throw new ConstructionException("null returned by gst_pipeline_new(Str.toStringz(name))");
175 		}
176 		this(cast(GstPipeline*) p);
177 	}
178 	
179 	/**
180 	 * Gets the GstBus of pipeline. The bus allows applications to receive
181 	 * GstMessage packets.
182 	 * Returns: a GstBus, unref after usage. MT safe. [transfer full]
183 	 */
184 	public override Bus getBus()
185 	{
186 		// GstBus * gst_pipeline_get_bus (GstPipeline *pipeline);
187 		auto p = gst_pipeline_get_bus(gstPipeline);
188 		
189 		if(p is null)
190 		{
191 			return null;
192 		}
193 		
194 		return ObjectG.getDObject!(Bus)(cast(GstBus*) p);
195 	}
196 	
197 	/**
198 	 * Set the clock for pipeline. The clock will be distributed
199 	 * to all the elements managed by the pipeline.
200 	 * Params:
201 	 * clock = the clock to set. [transfer none]
202 	 * Returns: TRUE if the clock could be set on the pipeline. FALSE if some element did not accept the clock. MT safe.
203 	 */
204 	public override int setClock(Clock clock)
205 	{
206 		// gboolean gst_pipeline_set_clock (GstPipeline *pipeline,  GstClock *clock);
207 		return gst_pipeline_set_clock(gstPipeline, (clock is null) ? null : clock.getClockStruct());
208 	}
209 	
210 	/**
211 	 * Gets the current clock used by pipeline.
212 	 * Returns: a GstClock, unref after usage. [transfer full]
213 	 */
214 	public override Clock getClock()
215 	{
216 		// GstClock * gst_pipeline_get_clock (GstPipeline *pipeline);
217 		auto p = gst_pipeline_get_clock(gstPipeline);
218 		
219 		if(p is null)
220 		{
221 			return null;
222 		}
223 		
224 		return ObjectG.getDObject!(Clock)(cast(GstClock*) p);
225 	}
226 	
227 	/**
228 	 * Force pipeline to use the given clock. The pipeline will
229 	 * always use the given clock even if new clock providers are added
230 	 * to this pipeline.
231 	 * If clock is NULL all clocking will be disabled which will make
232 	 * the pipeline run as fast as possible.
233 	 * MT safe.
234 	 * Params:
235 	 * clock = the clock to use. [transfer none][allow-none]
236 	 */
237 	public void useClock(Clock clock)
238 	{
239 		// void gst_pipeline_use_clock (GstPipeline *pipeline,  GstClock *clock);
240 		gst_pipeline_use_clock(gstPipeline, (clock is null) ? null : clock.getClockStruct());
241 	}
242 	
243 	/**
244 	 * Let pipeline select a clock automatically. This is the default
245 	 * behaviour.
246 	 * Use this function if you previous forced a fixed clock with
247 	 * gst_pipeline_use_clock() and want to restore the default
248 	 * pipeline clock selection algorithm.
249 	 * MT safe.
250 	 */
251 	public void autoClock()
252 	{
253 		// void gst_pipeline_auto_clock (GstPipeline *pipeline);
254 		gst_pipeline_auto_clock(gstPipeline);
255 	}
256 	
257 	/**
258 	 * Usually, when a pipeline goes from READY to NULL state, it automatically
259 	 * flushes all pending messages on the bus, which is done for refcounting
260 	 * purposes, to break circular references.
261 	 * This means that applications that update state using (async) bus messages
262 	 * (e.g. do certain things when a pipeline goes from PAUSED to READY) might
263 	 * not get to see messages when the pipeline is shut down, because they might
264 	 * be flushed before they can be dispatched in the main thread. This behaviour
265 	 * can be disabled using this function.
266 	 * It is important that all messages on the bus are handled when the
267 	 * automatic flushing is disabled else memory leaks will be introduced.
268 	 * MT safe.
269 	 * Params:
270 	 * autoFlush = whether or not to automatically flush the bus when
271 	 * the pipeline goes from READY to NULL state
272 	 */
273 	public void setAutoFlushBus(int autoFlush)
274 	{
275 		// void gst_pipeline_set_auto_flush_bus (GstPipeline *pipeline,  gboolean auto_flush);
276 		gst_pipeline_set_auto_flush_bus(gstPipeline, autoFlush);
277 	}
278 	
279 	/**
280 	 * Check if pipeline will automatically flush messages when going to
281 	 * the NULL state.
282 	 * Returns: whether the pipeline will automatically flush its bus when going from READY to NULL state or not. MT safe.
283 	 */
284 	public int getAutoFlushBus()
285 	{
286 		// gboolean gst_pipeline_get_auto_flush_bus (GstPipeline *pipeline);
287 		return gst_pipeline_get_auto_flush_bus(gstPipeline);
288 	}
289 	
290 	/**
291 	 * Set the expected delay needed for all elements to perform the
292 	 * PAUSED to PLAYING state change. delay will be added to the
293 	 * base time of the elements so that they wait an additional delay
294 	 * amount of time before starting to process buffers and cannot be
295 	 * GST_CLOCK_TIME_NONE.
296 	 * This option is used for tuning purposes and should normally not be
297 	 * used.
298 	 * MT safe.
299 	 * Params:
300 	 * delay = the delay
301 	 */
302 	public void setDelay(GstClockTime delay)
303 	{
304 		// void gst_pipeline_set_delay (GstPipeline *pipeline,  GstClockTime delay);
305 		gst_pipeline_set_delay(gstPipeline, delay);
306 	}
307 	
308 	/**
309 	 * Get the configured delay (see gst_pipeline_set_delay()).
310 	 * Returns: The configured delay. MT safe.
311 	 */
312 	public GstClockTime getDelay()
313 	{
314 		// GstClockTime gst_pipeline_get_delay (GstPipeline *pipeline);
315 		return gst_pipeline_get_delay(gstPipeline);
316 	}
317 }