I’ve developed a gstreamer plugin with 2 elements that provide timeshift functionality: timeshiftsink and timeshiftsrc. The former creates a ring buffer and the latter is able to access it if a pointer to the timeshiftsink element is given in the “sink” property.
To use them, you must split your pipeline in two:
- A live pipeline which ends in the
timeshiftsinkelement - Another pipeline whose source is the
timeshiftsrcelement
Remember to set the “sink” property of timeshiftsrc to a GstElement* to the timeshiftsink, to connect both elements.
When used correctly, this setup allows seeking freely within the ring-buffer.
Here’s an example pipeline pair which I have tested successfully:
dvbsrc ! queue ! tsparse set-timestamps=true ! timeshiftsink(this also works if I swapdvbsrc ! queuewithudpsrc ! rtpjitterbuffer ! rtpmp2tdepay)timeshiftsrc ! decodebin name=decoder decoder. ! videoconvert ! autovideosink decoder. ! audioconvert ! autovideosink
To my understanding, the “set-timestamps” property of tsparse here is key. GstBuffers that go into the ring buffer already have timestamps representing the time when they were received. This information is then used by timeshiftsrc to enable playing and seeking.
I want to get feedback/criticism on these elements so I got authorized by my employer to make them public. I would be very glad to receive comments, either here or in the issues page of the GitHub repository.
Thanks in advance