How to share the buffer in process context?

Hi,
There is new NvBuffer APIs on Jetpack 4.6(r32.6.1) for this use-case. Please upgrade to JP4.6 and check nvbuf_utils.h:

/**
 * Gets buffer extended parameters.
 * @param[in] dmabuf_fd `DMABUF FD` of buffer.
 * @param[out] exparams A pointer to the structure to fill with extended parameters.
 *
 * @returns 0 for success, -1 for failure.
 */
int NvBufferGetParamsEx (int dmabuf_fd, NvBufferParamsEx *exparams);
/**
 * Transforms one DMA buffer to another DMA buffer, API to be used for another process.
 * This function can support transforms for copying, scaling, fliping, rotating, and cropping.
 * @param[in] src_dmabuf_fd DMABUF FD of source buffer
 * @param[in] input_params extended input parameters for a hardware buffer.
 * @param[in] dst_dmabuf_fd DMABUF FD of destination buffer
 * @param[in] output_params extended output parameters for a hardware buffer.
 * @param[in] transform_params transform parameters
 *
 * @return 0 for sucess, -1 for failure.
 */
int NvBufferTransformEx (int src_dmabuf_fd, NvBufferParamsEx *input_params, int dst_dmabuf_fd, NvBufferParamsEx *output_params, NvBufferTransformParams *transform_params);

With the API you can send fd through unix domain socket and get the buffer in another process.

1 Like