I want to use nvmap api to get and share the buffer in different process.
use NvBufferCreate to create a buf and than to use ExtractFdFromNvBuffer to get out the fd.but failed in different process.
process A → NvBufferCreate ,and show the phy addr in the NvBufferParams.
process B-> ExtractFdFromNvBuffer (phyaddr_from_A,dmabuf_fd);
this cause the Segment Fault.
Does the V4L2 export the dmabuf_fd can be used in different process?like mmap.
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.
Would it be so kind for you to show me the sample?
the thing is I can handle the Unix message to send and recv the message,but still not knowing how to use NvBuffer APIs within different process to get the dmabuf_fd.
Process : A send msg
Process : B recv msg
PS: in the version from 32.6.1in nvbuffer_utils.h I did not find the API as NvBufferTransformEx instead of NvBufferTransform.
I’m trying to share a buffer between two processes. I succeeded in sharing the file descriptor, however I’m having issues (SEGFAULT) on calling NvBufferTransformEx: Failed to configure NvDdkVic Source Surface.
The documentation on that topic is very sparse. Any chance you could show us a sample of how to use NvBufferTransformEx? Or may you please tell me rough date when we can expect a sample? 🙂
i try this test,one process send [1920x1080] yuv dmabuf data;
another process recv yuv dmabuf and NvBufferTransformEx;
but when i send frame every 30ms;and the recv process will failed at the 1011 frame later;
and i try many times,and recv process always failed at the 1011 frame later;
the error code SYNC_IOC_FENCE_INFO ioctl failed with 9
Do you send fd in every frame? Or send all fd in initialization? You should have like 6 Nvbuffers for capturing frame data in producer. Please send the fds in initialization to consumers. Once the buffer is updated, please send messages to all consumers. No need to keep sending fd for every frame update.
1 、the send fd is always the same,NvJPEGDecoder decode from a jpg picture;
m_pJpegDec->decodeToFd(jpgfd, pFileBuffer, nFileSize, nPixFmt, nWidth, nHeight)
2、the test is only one producer process and one consumer process;
1、why “decodeToFd” so many times?could not reuse the jpgfd?
2、“wait_for_ack_from_consumers_that_buffer_is_read” ?just consumer echo a message?or more comsumer process methods?more detailed explanation or example code?
We have updated the pseudo code. Please check if it is more clear. Assume you will update new JPEG data to pFileBuffer and then do continuous decoding. It is decoded to the same NvBuffer and then inform consumers the buffer is updated.
For publishing a new sample we would need to go through some process. It is underway and would take some time.
In server producer ,i add "int m_nFlag[MAX_CLIENT] " to save consumer client confirm messages,and send the next new fd which is produced by [00_video_decode sample]; it also failed on 1011 frames;
I did not know how to fix this problem…
why?why always 1011 frames?what is this problem?the fd need to free or destroy?