2016-12-05 21:12:24 +00:00
|
|
|
# Streams
|
|
|
|
|
2016-12-30 08:24:42 +00:00
|
|
|
This document describes the objects that are passed from element to
|
|
|
|
element in the streaming thread.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
|
2016-12-05 21:12:24 +00:00
|
|
|
## Stream objects
|
|
|
|
|
|
|
|
The following objects are to be expected in the streaming thread:
|
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
- events, including:
|
|
|
|
- `STREAM_START` (START)
|
|
|
|
- `SEGMENT` (SEGMENT)
|
|
|
|
- `EOS` * (EOS)
|
|
|
|
- `TAG` (T)
|
2016-12-05 21:12:24 +00:00
|
|
|
- buffers * (B)
|
|
|
|
|
|
|
|
Objects marked with * need to be synchronised to the clock in sinks and
|
|
|
|
live sources.
|
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
|
2016-12-05 21:12:24 +00:00
|
|
|
## Typical stream
|
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
A typical stream starts with a `STREAM_START` event that marks the start of the
|
|
|
|
stream, followed by a `SEGMENT` event that marks the buffer timestamp
|
|
|
|
range. After that buffers are sent one after the other. After the last buffer an
|
|
|
|
`EOS` event marks the end of the stream. No more buffers are to be processed
|
|
|
|
after the `EOS` event.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
+-----+-------+ +-++-+ +-+ +---+
|
|
|
|
|START|SEGMENT| |B||B| ... |B| |EOS|
|
|
|
|
+-----+-------+ +-++-+ +-+ +---+
|
|
|
|
```
|
|
|
|
|
|
|
|
1) **`STREAM_START`**
|
2017-01-23 04:30:52 +00:00
|
|
|
- marks the start of a stream; unlike the `SEGMENT` event, there
|
|
|
|
will be no `STREAM_START` event after flushing seeks.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
2) **`SEGMENT`**, rate, start/stop, time. (See also
|
|
|
|
[Segments](additional/design/segments.md))
|
2016-12-05 21:12:24 +00:00
|
|
|
- marks valid buffer timestamp range (start, stop)
|
2016-12-30 08:24:42 +00:00
|
|
|
- marks `stream_time` of buffers (time). This is the stream time of buffers
|
2017-01-23 04:30:52 +00:00
|
|
|
with a timestamp of `S.start`.
|
2016-12-05 21:12:24 +00:00
|
|
|
- marks playback rate (rate). This is the required playback rate.
|
2016-12-30 08:24:42 +00:00
|
|
|
- marks applied rate (`applied_rate`). This is the already applied playback
|
2019-05-26 22:32:55 +00:00
|
|
|
rate. (See also [trickmodes](additional/design/trickmodes.md))
|
2016-12-30 08:24:42 +00:00
|
|
|
- marks `running_time` of buffers. This is the time used to synchronize
|
2016-12-05 21:12:24 +00:00
|
|
|
against the clock.
|
|
|
|
|
|
|
|
3) **N buffers**
|
2016-12-30 08:24:42 +00:00
|
|
|
- displayable buffers are between start/stop of the `SEGMENT` (S). Buffers
|
2016-12-05 21:12:24 +00:00
|
|
|
outside the segment range should be dropped or clipped.
|
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
- `running_time`: For each buffer, a monotonically increasing value that can
|
|
|
|
be used to synchronize against the clock (See also
|
|
|
|
[synchronisation](additional/design/synchronisation.md)).
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
``` c
|
|
|
|
if (S.rate > 0.0)
|
|
|
|
running_time = (B.timestamp - S.start) / ABS (S.rate) + S.base;
|
|
|
|
else
|
|
|
|
running_time = (S.stop - B.timestamp) / ABS (S.rate) + S.base;
|
|
|
|
```
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
- `stream_time`: The current position in the stream, between 0 and duration.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
``` c
|
|
|
|
stream_time = (B.timestamp - S.start) * ABS (S.applied_rate) + S.time;
|
|
|
|
```
|
2016-12-05 21:12:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
4) **`EOS`**
|
2016-12-30 08:24:42 +00:00
|
|
|
- marks the end of data, nothing is to be expected after `EOS`, elements
|
|
|
|
should refuse more data and return `GST_FLOW_EOS`. A `FLUSH_STOP`
|
|
|
|
event clears the `EOS` state of an element.
|
2016-12-05 21:12:24 +00:00
|
|
|
|
2020-05-12 06:08:10 +00:00
|
|
|
|
2016-12-05 21:12:24 +00:00
|
|
|
## Elements
|
|
|
|
|
2016-12-30 08:24:42 +00:00
|
|
|
These events are generated typically either by the `GstBaseSrc` class for
|
2016-12-05 21:12:24 +00:00
|
|
|
sources operating in push mode, or by a parser/demuxer operating in
|
|
|
|
pull-mode and pushing parsed/demuxed data downstream.
|