Support custom data in AppSink
I am trying to use cuda (the Nvidia API to use the GPU for computation) to do image analysis in real time on buffers coming from a camera.
I have abstracted the coda processing with a rust type (a struct) that contains everything that's needed.
Let's call this CudaProcessor
.
The problem is, this struct is not Send
, and AFAIK cannot be made Send
because the underlying cuda machinery is not Send
.
I already have the gst pipeline in place and working (it receives buffers from the camera) but the processing callback cannot capture the CudaProcessor
because it is not Send
.
I think that the idiomatic gstreamer solution to this would be to have the CudaProcessor
instance belong to the AppSink
instance, so that they are on the correct thread.
I see from the docs that in plain gstreamer (C API) AppSink
supports that user pointer when using calbacks. However it is not exposed in the rust API, probably because making it type safe would be tricky.
Perhaps, more than an issue, this is a question: what is the proper way to support this scenario using the rust API?
Would subclassing AppSink
(at the glib level) work?
I mean putting the CudaProcessor
as a property of a custom AppSink
subclass.
The calbacks would need to downcast the AppSink
bit it's not a big deal.
Would it work?
Are there examples of how to do it?
Thanks!