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