dynamic stream recording

Milian Wolff milian.wolff at kdab.com
Wed Nov 27 15:38:41 UTC 2019


On Mittwoch, 27. November 2019 10:05:51 CET Milian Wolff wrote:
> On Mittwoch, 27. November 2019 08:55:12 CET Tim Müller wrote:
> > On Tue, 2019-11-26 at 17:39 +0100, Milian Wolff wrote:
> > 
> > Hi Milian,
> 
> Hey Tim!
> 
> > > Is this still the recommended way of doing things? For a novice, it
> > > is extremely difficult to follow - the code is complex and apparently
> > > requires  manual setup of the pipeline, which is unfortunate - the
> > > flexibility of `gst_parse_launch` has helped me a lot so far.
> > 
> > I think by and large this is still correct, but it depends a bit on
> > what exactly you want to do.
> > 
> > Can you describe your goals/requirements? There are many types of
> > 'dynamic' stream recording.
> 
> Will do, see below.
> 
> > gst_parse_launch() just doesn't work very well for dynamic things.
> > Having
> > said that, you can still use helpers like
> > gst_parse_bin_from_description(),
> > which are like gst_parse_launch() but  give you a bin / pipeline part
> > instead of a full top-level pipeline. So you can use it for branches
> > for example.
> 
> Great, that's exactly the kind of method I was looking for. May I suggest
> that a link to gst_parse_bin_from_description is added to gst_parse_launch?

FTR, I have now implemented the dynamic pipeline logic and it works like a 
charm. The rough outline is as follows:

a) gst_parse_launch to build the "main" pipeline that should be always running 
with a tee at the place where recording can be hooked in dynamically

b) To enable recording, use gst_parse_bin_from_description to build the 
recording branch, then gst_bin_add it to the previously created pipeline and 
gst_pad_link the sink of my record branch with a new src pad from the tee 
element, cf. the first branch within `tick_cb` in `dynamic-tee-vsink.c`.

Then it's important to also gst_element_set_state the newly added recording 
branch to GST_STATE_PLAYING, otherwise the whole pipeline gets blocked. This 
is missing from `dynamic-tee-vsink.c` but even adding it doesn't fix the 
"black screen" problem for me when trying it out locally...

d) To stop recording we use the gst_pad_add_probe trick (cf. second branch in 
`tick_cb` in `dynamic-tee-vsink.c`) and then in the callback we ref our 
branch, unlink the pad, set the state to null, remove the branch from the 
pipeline and then finally unref the branch and the request pad.

I'm happy! While this isn't trivial, it's much simpler than `dynamic-tee-
vsink.c` which confused me initially due to it's dynamic nature of supporting 
more than one dynamically added branch. I think adding a simpler scenario to 
exemplify a more common "on/off" state for recording would be appreciated by 
many?

Cheers
-- 
Milian Wolff | milian.wolff at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3826 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20191127/b8711b77/attachment.bin>


More information about the gstreamer-devel mailing list