New plugin for MPEG TS time shifting
Submitted by Krzysztof Konopko
Link to original bug (#692397)
Description
Created attachment 234220
Proposed implementation
tstimeshift: New plugin for MPEG TS time shifting
This is an initial proposal. I'd like to ask for any help, views, suggestions and directions.
The plugin is base on Fluendo timeshift element [1] although quite substantially changed. The proposed code is maintained on GitHub [2]. The gsttstimeshift comprises several elements that can be used for MPEG TS time shifting:
tsshifter : Time Shift for MPEG TS streams
tsshifterbin : Time Shift + TS parser for MPEG TS streams
tsseeker : Time Shift seeker
tsindexer : Indexer for MPEG-TS streams
A typical pipeline that makes use of them would look like:
<some MPEG TS src>
! tsshifterbin ! <some MPEG TS sink>
The tsshifterbin element will instantiate elements as follows:
tsparse ! tsindexer ! tsshifter ! tsseeker
and prepare tsindexer ("tune" it to look for the right PID containing PCRs).
Potentially tsshifter can be replaced with queue2 (see the problems below) and this is actually one of the goals.
Problems still to be considered/solved/improved:
-
naming
Both tsindexer and tsseeker are supposed to be MPEG TS agnostic but ATM they are TS specific, hence their names.
Also the tsshifter is actually a ring buffer. -
tsindexer
- uses overengineered for this use case and abandoned GstIndex API (local copy)
- can't remove index entries
- can't write the index to the disk
- duplicates parsing TS packets logic from tsparse
tsparse would have to be improved to send some additional timestamp information (e. g. as tags or as buffer timestamps) so that the indexer could pick them up. The indexer itself could be a generic component (no knowledge about TS packets), hard to come up with the right format though.
- uses overengineered for this use case and abandoned GstIndex API (local copy)
-
tsindexer and tsseeker share an index object while it should be shared through some index database
-
tsshifter
- it's actually a ring buffer, not a shifter (see naming notes above)
- ideally it should be replaced with queue2
- as a first attempt, replacement could be optional (both tsshifter and queue2 co-exist)
There are still some issues when using queue2 instead of tsshifter that have to be solved. - as a goal tsshifter could be completely replaced with queue2 which might require some changes/improvements of the latter:
- custom allocator can be used (see FileMemAllocator: https://bugzilla.gnome.org/show_bug.cgi?id=691299)
- as a first attempt, replacement could be optional (both tsshifter and queue2 co-exist)
-
tests still to be written
-
documentation
[1] https://github.com/kkonopko/gst-fluendo-timeshift
[2] https://github.com/kkonopko/gst-plugins-bad/tree/ts-timeshifter-element
Patch 234220, "Proposed implementation":
0001-tstimeshift-New-plugin-for-MPEG-TS-time-shifting.patch