Next: , Previous: GstParse, Up: Top


27 GstPipeline

Top-level bin with clocking and bus management functionality.

27.1 Overview

A <gst-pipeline> is a special <gst-bin> used as the toplevel container for the filter graph. The <gst-pipeline> will manage the selection and distribution of a global <gst-clock> as well as provide a <gst-bus> to the application. It will also implement a default behavour for managing seek events (see gst-element-seek).

gst-pipeline-new is used to create a pipeline. when you are done with the pipeline, use gst-object-unref to free its resources including all added <gst-element> objects (if not otherwise referenced).

Elements are added and removed from the pipeline using the <gst-bin> methods like gst-bin-add and gst-bin-remove (see <gst-bin>).

Before changing the state of the <gst-pipeline> (see <gst-element>) a <gst-bus> can be retrieved with gst-pipeline-get-bus. This bus can then be used to receive <gst-message> from the elements in the pipeline.

By default, a <gst-pipeline> will automatically flush the pending <gst-bus> messages when going to the NULL state to ensure that no circular references exist when no messages are read from the <gst-bus>. This behaviour can be changed with gst-pipeline-set-auto-flush-bus.

When the <gst-pipeline> performs the PAUSED to PLAYING state change it will select a clock for the elements. The clock selection algorithm will by default select a clock provided by an element that is most upstream (closest to the source). For live pipelines (ones that return <gst-state-change-no-preroll> from the gst-element-set-state call) this will select the clock provided by the live source. For normal pipelines this will select a clock provided by the sinks (most likely the audio sink). If no element provides a clock, a default <gst-system-clock> is used.

The clock selection can be controlled with the gst-pipeline-use-clock method, which will enforce a given clock on the pipeline. With gst-pipeline-auto-clock the default clock selection algorithm can be restored.

A <gst-pipeline> maintains a stream time for the elements. The stream time is defined as the difference between the current clock time and the base time. When the pipeline goes to READY or a flushing seek is performed on it, the stream time is reset to 0. When the pipeline is set from PLAYING to PAUSED, the current clock time is sampled and used to configure the base time for the elements when the pipeline is set to PLAYING again. This default behaviour can be changed with the gst-pipeline-set-new-stream-time method.

When sending a flushing seek event to a GstPipeline (see gst-element-seek), it will make sure that the pipeline is properly PAUSED and resumed as well as set the new stream time to 0 when the seek succeeded.

Last reviewed on 2006-03-12 (0.10.5)

27.2 Usage

— Class: <gst-pipeline>

This <gobject> class defines the following properties:

delay
Expected delay needed for elements to spin up to PLAYING in nanoseconds
auto-flush-bus
Whether to automatically flush the pipeline's bus when going from READY into NULL state
— Function: gst-pipeline-new (name mchars)   (ret <gst-element>)

Create a new pipeline with the given name.

name
name of new pipeline
ret
newly created GstPipeline MT safe.
— Function: gst-pipeline-get-bus (self <gst-pipeline>)   (ret <gst-bus>)
— Method: get-bus

Gets the <gst-bus> of pipeline.

pipeline
a <gst-pipeline>
ret
a <gst-bus>, unref after usage. MT safe.
— Function: gst-pipeline-set-clock (self <gst-pipeline>) (clock <gst-clock>)   (ret bool)
— Method: set-clock

Set the clock for pipeline. The clock will be distributed to all the elements managed by the pipeline.

pipeline
a <gst-pipeline>
clock
the clock to set
ret
TRUE if the clock could be set on the pipeline. FALSE if some element did not accept the clock. MT safe.
— Function: gst-pipeline-get-clock (self <gst-pipeline>)   (ret <gst-clock>)
— Method: get-clock

Gets the current clock used by pipeline.

pipeline
a <gst-pipeline>
ret
a <gst-clock>, unref after usage.
— Function: gst-pipeline-use-clock (self <gst-pipeline>) (clock <gst-clock>)
— Method: use-clock

Force pipeline to use the given clock. The pipeline will always use the given clock even if new clock providers are added to this pipeline.

If clock is NULL all clocking will be disabled which will make the pipeline run as fast as possible.

MT safe.

pipeline
a <gst-pipeline>
clock
the clock to use
— Function: gst-pipeline-auto-clock (self <gst-pipeline>)
— Method: auto-clock

Let pipeline select a clock automatically. This is the default behaviour.

Use this function if you previous forced a fixed clock with gst-pipeline-use-clock and want to restore the default pipeline clock selection algorithm.

MT safe.

pipeline
a <gst-pipeline>
— Function: gst-pipeline-set-new-stream-time (self <gst-pipeline>) (time unsigned-long-long)
— Method: set-new-stream-time

Set the new stream time of pipeline to time. The stream time is used to set the base time on the elements (see gst-element-set-base-time) in the PAUSED->PLAYING state transition.

Setting time to <gst-clock-time-none> will disable the pipeline's management of element base time. The application will then be responsible for performing base time distribution. This is sometimes useful if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.

MT safe.

pipeline
a <gst-pipeline>
time
the new stream time to set
— Function: gst-pipeline-get-last-stream-time (self <gst-pipeline>)   (ret unsigned-long-long)
— Method: get-last-stream-time

Gets the last stream time of pipeline. If the pipeline is PLAYING, the returned time is the stream time used to configure the element's base time in the PAUSED->PLAYING state. If the pipeline is PAUSED, the returned time is the stream time when the pipeline was paused.

This function returns <gst-clock-time-none> if the pipeline was configured to not handle the management of the element's base time (see gst-pipeline-set-new-stream-time).

pipeline
a <gst-pipeline>
ret
a <gst-clock-time>. MT safe.
— Function: gst-pipeline-set-auto-flush-bus (self <gst-pipeline>) (auto_flush bool)
— Method: set-auto-flush-bus

Usually, when a pipeline goes from READY to NULL state, it automatically flushes all pending messages on the bus, which is done for refcounting purposes, to break circular references.

This means that applications that update state using (async) bus messages (e.g. do certain things when a pipeline goes from PAUSED to READY) might not get to see messages when the pipeline is shut down, because they might be flushed before they can be dispatched in the main thread. This behaviour can be disabled using this function.

It is important that all messages on the bus are handled when the automatic flushing is disabled else memory leaks will be introduced.

MT safe.

pipeline
a <gst-pipeline>
auto-flush
whether or not to automatically flush the bus when the pipeline goes from READY to NULL state

Since 0.10.4

— Function: gst-pipeline-get-auto-flush-bus (self <gst-pipeline>)   (ret bool)
— Method: get-auto-flush-bus

Check if pipeline will automatically flush messages when going to the NULL state.

pipeline
a <gst-pipeline>
ret
whether the pipeline will automatically flush its bus when going from READY to NULL state or not. MT safe.

Since 0.10.4

— Function: gst-pipeline-set-delay (self <gst-pipeline>) (delay unsigned-long-long)
— Method: set-delay

Set the expected delay needed for all elements to perform the PAUSED to PLAYING state change. delay will be added to the base time of the elements so that they wait an additional delay amount of time before starting to process buffers and cannot be <gst-clock-time-none>.

This option is used for tuning purposes and should normally not be used.

MT safe.

pipeline
a <gst-pipeline>
delay
the delay

Since 0.10.5

— Function: gst-pipeline-get-delay (self <gst-pipeline>)   (ret unsigned-long-long)
— Method: get-delay

Get the configured delay (see gst-pipeline-set-delay).

pipeline
a <gst-pipeline>
ret
The configured delay. MT safe.

Since 0.10.5