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 
69 private import glib.Str;
70 private import gstreamer.Bus;
71 private import gstreamer.Clock;
72 
73 
74 
75 private import gstreamer.Bin;
76 
77 /**
78  * A GstPipeline is a special GstBin used as the toplevel container for
79  * the filter graph. The GstPipeline will manage the selection and
80  * distribution of a global GstClock as well as provide a GstBus to the
81  * application.
82  *
83  * gst_pipeline_new() is used to create a pipeline. when you are done with
84  * the pipeline, use gst_object_unref() to free its resources including all
85  * added GstElement objects (if not otherwise referenced).
86  *
87  * Elements are added and removed from the pipeline using the GstBin
88  * methods like gst_bin_add() and gst_bin_remove() (see GstBin).
89  *
90  * Before changing the state of the GstPipeline (see GstElement) a GstBus
91  * can be retrieved with gst_pipeline_get_bus(). This bus can then be
92  * used to receive GstMessage from the elements in the pipeline.
93  *
94  * By default, a GstPipeline will automatically flush the pending GstBus
95  * messages when going to the NULL state to ensure that no circular
96  * references exist when no messages are read from the GstBus. This
97  * behaviour can be changed with gst_pipeline_set_auto_flush_bus().
98  *
99  * When the GstPipeline performs the PAUSED to PLAYING state change it will
100  * select a clock for the elements. The clock selection algorithm will by
101  * default select a clock provided by an element that is most upstream
102  * (closest to the source). For live pipelines (ones that return
103  * GST_STATE_CHANGE_NO_PREROLL from the gst_element_set_state() call) this
104  * will select the clock provided by the live source. For normal pipelines
105  * this will select a clock provided by the sinks (most likely the audio
106  * sink). If no element provides a clock, a default GstSystemClock is used.
107  *
108  * The clock selection can be controlled with the gst_pipeline_use_clock()
109  * method, which will enforce a given clock on the pipeline. With
110  * gst_pipeline_auto_clock() the default clock selection algorithm can be
111  * restored.
112  *
113  * A GstPipeline maintains a running time for the elements. The running
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 running 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. The effect is that the running time (as the difference
120  * between the clock time and the base time) will count how much time was spent
121  * in the PLAYING state. This default behaviour can be changed with the
122  * gst_element_set_start_time() method.
123  *
124  * Last reviewed on 2012-03-29 (0.11.3)
125  */
126 public class Pipeline : Bin
127 {
128 	
129 	/** the main Gtk struct */
130 	protected GstPipeline* gstPipeline;
131 	
132 	
133 	public GstPipeline* getPipelineStruct()
134 	{
135 		return gstPipeline;
136 	}
137 	
138 	
139 	/** the main Gtk struct as a void* */
140 	protected override void* getStruct()
141 	{
142 		return cast(void*)gstPipeline;
143 	}
144 	
145 	/**
146 	 * Sets our main struct and passes it to the parent class
147 	 */
148 	public this (GstPipeline* gstPipeline)
149 	{
150 		super(cast(GstBin*)gstPipeline);
151 		this.gstPipeline = gstPipeline;
152 	}
153 	
154 	protected override void setStruct(GObject* obj)
155 	{
156 		super.setStruct(obj);
157 		gstPipeline = cast(GstPipeline*)obj;
158 	}
159 	
160 	/**
161 	 */
162 	
163 	/**
164 	 * Create a new pipeline with the given name.
165 	 * Params:
166 	 * name = name of new pipeline. [allow-none]
167 	 * Throws: ConstructionException GTK+ fails to create the object.
168 	 */
169 	public this (string name)
170 	{
171 		// GstElement * gst_pipeline_new (const gchar *name);
172 		auto p = gst_pipeline_new(Str.toStringz(name));
173 		if(p is null)
174 		{
175 			throw new ConstructionException("null returned by gst_pipeline_new(Str.toStringz(name))");
176 		}
177 		this(cast(GstPipeline*) p);
178 	}
179 	
180 	/**
181 	 * Gets the GstBus of pipeline. The bus allows applications to receive
182 	 * GstMessage packets.
183 	 * Returns: a GstBus, unref after usage. MT safe. [transfer full]
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. [transfer none]
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. [transfer full]
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. [transfer none][allow-none]
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 	 * Usually, when a pipeline goes from READY to NULL state, it automatically
260 	 * flushes all pending messages on the bus, which is done for refcounting
261 	 * purposes, to break circular references.
262 	 * This means that applications that update state using (async) bus messages
263 	 * (e.g. do certain things when a pipeline goes from PAUSED to READY) might
264 	 * not get to see messages when the pipeline is shut down, because they might
265 	 * be flushed before they can be dispatched in the main thread. This behaviour
266 	 * can be disabled using this function.
267 	 * It is important that all messages on the bus are handled when the
268 	 * automatic flushing is disabled else memory leaks will be introduced.
269 	 * MT safe.
270 	 * Params:
271 	 * autoFlush = whether or not to automatically flush the bus when
272 	 * the pipeline goes from READY to NULL state
273 	 */
274 	public void setAutoFlushBus(int autoFlush)
275 	{
276 		// void gst_pipeline_set_auto_flush_bus (GstPipeline *pipeline,  gboolean auto_flush);
277 		gst_pipeline_set_auto_flush_bus(gstPipeline, autoFlush);
278 	}
279 	
280 	/**
281 	 * Check if pipeline will automatically flush messages when going to
282 	 * the NULL state.
283 	 * Returns: whether the pipeline will automatically flush its bus when going from READY to NULL state or not. MT safe.
284 	 */
285 	public int getAutoFlushBus()
286 	{
287 		// gboolean gst_pipeline_get_auto_flush_bus (GstPipeline *pipeline);
288 		return gst_pipeline_get_auto_flush_bus(gstPipeline);
289 	}
290 	
291 	/**
292 	 * Set the expected delay needed for all elements to perform the
293 	 * PAUSED to PLAYING state change. delay will be added to the
294 	 * base time of the elements so that they wait an additional delay
295 	 * amount of time before starting to process buffers and cannot be
296 	 * GST_CLOCK_TIME_NONE.
297 	 * This option is used for tuning purposes and should normally not be
298 	 * used.
299 	 * MT safe.
300 	 * Params:
301 	 * delay = the delay
302 	 */
303 	public void setDelay(GstClockTime delay)
304 	{
305 		// void gst_pipeline_set_delay (GstPipeline *pipeline,  GstClockTime delay);
306 		gst_pipeline_set_delay(gstPipeline, delay);
307 	}
308 	
309 	/**
310 	 * Get the configured delay (see gst_pipeline_set_delay()).
311 	 * Returns: The configured delay. MT safe.
312 	 */
313 	public GstClockTime getDelay()
314 	{
315 		// GstClockTime gst_pipeline_get_delay (GstPipeline *pipeline);
316 		return gst_pipeline_get_delay(gstPipeline);
317 	}
318 }