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