Copy on content of input buffer to output buffer

Hi, can you please provide an example how to copy the content of one gst_buffer to another gst_buffer?

Hi,
Your request is not very clear, but for customization, we have implemented dsexample:
https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/index.html#page/DeepStream_Development_Guide%2Fdeepstream_custom_plugin.html%23

You may refer to README to enable it and try.

deepstream_sdk_v4.0_jetson\sources\gst-plugins\gst-dsexample\README

Hi DaneLLL, thank you for you reply.
I’m trying to implement a function similar to gst_dsexample_transform_ip but since my transformation is not “in place” I want to use something like gst_dsexample_transform with an output buffer. Can you provide an example on how to properly set up this buffer and as a first operation, fill the output buffer with valid data (for example the frame-data which is stored in the input buffer)?

Hi,
Please refer to https://developer.gnome.org/gstreamer-libs/stable/GstBaseTransform.html

/* transform */
GstFlowReturn (*transform)    (GstBaseTransform *trans, GstBuffer *inbuf,
                             GstBuffer *outbuf);
GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);

In the sample code it registers a transform_ip callback. You can do processing on the inbuf and it will be copied to outbuf.

Above suggestion should work fine for your usecase, but for more flexibility, you may try to register a transform callback and do full implementation.

Hi DaneLLL, thank you for the answer, I am currently trying to implement a function which is based on gst_dsexample_transform_ip. The example provides only code to read the GstBuffer. Can you provide an example on how to write data to this buffer?

Even a minimal working example like this doesn’t work:

gint size = 10;
inbuf = gst_buffer_new_allocate(NULL, size, NULL);
gst_buffer_fill(inbuf, 0, &size, sizeof(size));

Hi,
With further investigation, it may not be possible to implement transform callback based on NvBufSurface. Certain hookup between NvBufSurface and GstBuffer are private.

We suggest you do processing in transform_ip. The inbuf will be copied to outbuf after the callback.

Hi DaneLLL,
thank you for the hint, I implemented the function transform_ip and did a NvBufSurfaceCopy to copy the surface from one location to another, therefore I can process the data and write back to the original inbuf.

Hi,
Great to hear that and thanks for sharing the solution. It can help other users who is working on similar usecases.

transform plugin example:
https://devtalk.nvidia.com/default/topic/1061492/deepstream-sdk/deepstream-sdk-4-0-faq/ -> 4. Here is gstnvsegvisual.cpp code