Manually dropping video frame in element

Ryan Brigden ryan at inokyo.com
Wed Jan 20 00:32:09 UTC 2021


Hello!

I was directed to this mailing list in this issue [1] in the
gstreamer-rs repo on gitlab. My goal was to create a CustomMetaAPI in
Rust that is defined in a standalone crate, and then consumed in other
crates that run gst::Pipeline s and crates that define plugins. In my
example, the CustomMetaAPI is defined in a standalone crate and
consumed by both the crate creating the pipeline and writing the meta
to buffers using a pad probe AND a plugin that consumes the meta
downstream.

After some more digging to identify the cause of the problem I
mentioned in [1], I realized that the `gst_meta_api_type_register` was
being called twice:

1. In a crate that creates the pipeline and attaches my custom meta to
each buffer in a pad probe.
2. In a downstream plugin that consumes the meta from each buffer

I found this issue [2] on the gstreamer-rs gitlab repo to exactly
describe this double invocation of the meta registration (despite
having been declared as `Lazy`).

@slomo mentioned a possible solution (if I understand its implications
correctly) is to put the `imp` module in the official example [3] into
a separate cdylib and then copy over the wrapper code into each place
the custom meta is to be used -- in my case this would be in both the
crate invoking the pipeline and the crate with the plugin.

from the issue [2]
> For that you'll have to put the imp module into a cdylib and make those two functions that use
> the Lazy type public, and from everywhere else you would only use the non-imp part of the
> meta and dynamically link to that cdylib for accessing the functions.

So I'm not sure how to set up this solution correctly in my case.
Currently I am isolating the `imp` module in its own crate, building
it as a cdylib. Then in both the pipeline crate and the plugin crate I
am adding the wrapper code (everything outside the `imp` module in the
example[3]). Unfortunately I can't seem to get the linking to work in
this case.

Does anyone have a suggestion for a simpler way to accomplish a shared
CustomMetaAPI in Rust? It seems... not great to have to duplicate the
wrapper code or keep it in a separate crate as the ffi.

Thank you :)

- Ryan

[1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/303
[2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/261
[3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/blob/master/examples/src/bin/custom_meta.rs


More information about the gstreamer-devel mailing list