2016-12-05 21:12:24 +00:00
|
|
|
# GstPipeline
|
|
|
|
|
2016-12-24 07:28:25 +00:00
|
|
|
A `GstPipeline` is usually a toplevel bin and provides all of its children
|
2016-12-05 21:12:24 +00:00
|
|
|
with a clock.
|
|
|
|
|
2016-12-24 07:28:25 +00:00
|
|
|
A `GstPipeline` also provides a toplevel `GstBus` (see [gstbus](design/gstbus.md))
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2017-03-13 23:10:01 +00:00
|
|
|
The pipeline also calculates the `running_time` based on the selected
|
2016-12-05 21:12:24 +00:00
|
|
|
clock (see also clocks.txt and [synchronisation](design/synchronisation.md)).
|
|
|
|
|
|
|
|
The pipeline will calculate a global latency for the elements in the
|
|
|
|
pipeline. (See also [latency](design/latency.md)).
|
|
|
|
|
|
|
|
## State changes
|
|
|
|
|
|
|
|
In addition to the normal state change procedure of its parent class
|
2016-12-24 07:28:25 +00:00
|
|
|
`GstBin`, the pipeline performs the following actions during a state
|
2016-12-05 21:12:24 +00:00
|
|
|
change:
|
|
|
|
|
2017-03-13 23:10:01 +00:00
|
|
|
- `NULL` → `READY`:
|
2016-12-05 21:12:24 +00:00
|
|
|
- set the bus to non-flushing
|
2017-03-13 23:10:01 +00:00
|
|
|
- `READY` → `PAUSED`:
|
|
|
|
- reset the `running_time` to 0
|
|
|
|
- `PAUSED` → `PLAYING`:
|
|
|
|
- Select a clock.
|
|
|
|
- calculate `base_time` using the `running_time`.
|
2016-12-05 21:12:24 +00:00
|
|
|
- calculate and distribute latency.
|
2017-03-13 23:10:01 +00:00
|
|
|
- set clock and `base_time` on all elements before performing the state
|
2016-12-05 21:12:24 +00:00
|
|
|
change.
|
2017-03-13 23:10:01 +00:00
|
|
|
- `PLAYING` → `PAUSED`:
|
|
|
|
- calculate the `running_time` when the pipeline was `PAUSED`.
|
|
|
|
- `READY` → `NULL`:
|
2016-12-05 21:12:24 +00:00
|
|
|
- set the bus to flushing (when auto-flushing is enabled)
|
|
|
|
|
2017-03-13 23:10:01 +00:00
|
|
|
The `running_time` represents the total elapsed time, measured in clock
|
2016-12-05 21:12:24 +00:00
|
|
|
units, that the pipeline spent in the PLAYING state (see
|
2017-03-13 23:10:01 +00:00
|
|
|
[synchronisation](design/synchronisation.md)). The `running_time` is set to 0 after a
|
2016-12-05 21:12:24 +00:00
|
|
|
flushing seek.
|
|
|
|
|
|
|
|
## Clock selection
|
|
|
|
|
2016-12-24 07:28:25 +00:00
|
|
|
Since all of the children of a `GstPipeline` must use the same clock, the
|
|
|
|
pipeline must select one. This clock selection happens when the
|
2017-03-13 23:10:01 +00:00
|
|
|
pipeline goes to the `PLAYING` state.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
The default clock selection algorithm works as follows:
|
|
|
|
|
|
|
|
- If the application selected a clock, use that clock. (see below)
|
|
|
|
|
2016-12-24 07:28:25 +00:00
|
|
|
- Use the clock of the most upstream element that can provide one.
|
2016-12-05 21:12:24 +00:00
|
|
|
This selection is performed by iterating the element starting from
|
|
|
|
the sinks going upstream.
|
2017-03-13 23:10:01 +00:00
|
|
|
- since this selection procedure happens in the `PAUSED` → `PLAYING`
|
2016-12-05 21:12:24 +00:00
|
|
|
state change, all the sinks are prerolled and we can thus be
|
|
|
|
sure that each sink is linked to some upstream element.
|
|
|
|
- in the case of a live pipeline (`NO_PREROLL`), the sink will not
|
|
|
|
yet be prerolled and the selection process will select the clock
|
|
|
|
of a more upstream element.
|
|
|
|
|
2017-03-13 23:10:01 +00:00
|
|
|
- Use `GstSystemClock`, this only happens when no element provides a
|
2016-12-05 21:12:24 +00:00
|
|
|
usable clock.
|
|
|
|
|
|
|
|
The application can influence this clock selection with two methods:
|
|
|
|
`gst_pipeline_use_clock()` and `gst_pipeline_auto_clock()`.
|
|
|
|
|
|
|
|
The `_use_clock()` method forces the use of a specific clock on the
|
2017-03-13 23:13:34 +00:00
|
|
|
pipeline regardless of what clock providers are available. Passing a
|
|
|
|
NULL `GstClock *clock` parameter to this method disables all clocking
|
|
|
|
and makes the pipeline run as fast as possible.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
The `_auto_clock()` method removes the fixed clock and reactivates the
|
|
|
|
auto- matic clock selection algorithm described above.
|
|
|
|
|
|
|
|
## GstBus
|
|
|
|
|
2016-12-24 07:28:25 +00:00
|
|
|
A `GstPipeline` provides a `GstBus` to the application. The bus can be
|
2016-12-05 21:12:24 +00:00
|
|
|
retrieved with `gst_pipeline_get_bus()` and can then be used to
|
|
|
|
retrieve messages posted by the elements in the pipeline (see
|
|
|
|
[gstbus](design/gstbus.md)).
|