2016-12-05 21:12:24 +00:00
|
|
|
# Live sources
|
|
|
|
|
|
|
|
A live source is a source that cannot be arbitrarily `PAUSED` without
|
|
|
|
losing data.
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
A live source such as an element capturing audio or video, needs to be
|
2016-12-05 21:12:24 +00:00
|
|
|
handled in a special way. It does not make sense to start the dataflow
|
|
|
|
in the `PAUSED` state for those devices as the user might wait a long time
|
2016-12-24 08:15:21 +00:00
|
|
|
between going from `PAUSED` to `PLAYING`, making the previously captured
|
2016-12-05 21:12:24 +00:00
|
|
|
buffers irrelevant.
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
A live source therefore only produces buffers in the `PLAYING` state. This
|
2016-12-05 21:12:24 +00:00
|
|
|
has implications for sinks waiting for a buffer to complete the preroll
|
|
|
|
state since such a buffer might never arrive.
|
|
|
|
|
|
|
|
Live sources return `NO_PREROLL` when going to the `PAUSED` state to inform
|
|
|
|
the bin/pipeline that this element will not be able to produce data in
|
|
|
|
the `PAUSED` state. `NO_PREROLL` should be returned for both READY→PAUSED
|
|
|
|
and PLAYING→PAUSED.
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
When performing a `get_state()` on a bin with a non-zero timeout value,
|
2016-12-05 21:12:24 +00:00
|
|
|
the bin must be sure that there are no live sources in the pipeline
|
2016-12-24 08:15:21 +00:00
|
|
|
because otherwise, the `get_state()` function would block on the sinks.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
A gstbin therefore always performs a zero timeout `get_state()` on its
|
2016-12-05 21:12:24 +00:00
|
|
|
elements to discover the `NO_PREROLL` (and ERROR) elements before
|
|
|
|
performing a blocking wait.
|
|
|
|
|
|
|
|
## Scheduling
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
Live sources will not produce data in the `PAUSED` state. They block in
|
|
|
|
the `get_range()` function or in the loop function until they go to PLAYING.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
## Latency
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
The live source timestamps its data with the time of the clock when
|
|
|
|
the data was captured. Normally, it will take some time to capture
|
|
|
|
the first sample of data and the last one. This means that when the
|
2016-12-05 21:12:24 +00:00
|
|
|
buffer arrives at the sink, it will already be late and will be dropped.
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
The latency is the time it takes to construct one buffer of data and it's
|
|
|
|
exposed with a `LATENCY` query.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
See [latency](design/latency.md)
|
|
|
|
|
|
|
|
## Timestamps
|
|
|
|
|
2016-12-24 08:15:21 +00:00
|
|
|
Live sources always timestamp their buffers with the `running_time` of
|
2016-12-05 21:12:24 +00:00
|
|
|
the pipeline. This is needed to be able to match the timestamps of
|
|
|
|
different live sources in order to synchronize them.
|
|
|
|
|
|
|
|
This is in contrast to non-live sources, which timestamp their buffers
|
2016-12-24 08:15:21 +00:00
|
|
|
starting from `running_time` 0.
|