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