How to use EGLStream to support multiple producers and consumers on PX2


I’m currently working on a project in which we need to have one EGLStream producer and multiple EGLStream consumers on PX2.
We tried to do this based on img_cap_eglprod and eglstream sample codes.
I already looked into this page , and I have some questions.

  1. Are there any sample code which has more details than the link? It would be even better to have some sample applications.
  2. After looking into the page, I knew that I can establish two EGLStreams for two producers/consumers and use the same image buffer to send by setting multisend attribute. However, what I don't know is what should I do when calling NvMediaEglStreamProducerGetImage? From your sample code, img_cap_eglprod, I can see that producer always calls this api and returns the buffer back to the queue. But, in the two producers scenario, should I call it twice in both EGLStreams? Or should I just call it with any one of the producers?
  3. Another similar question, but in the consumer side, is that from the page looks like we only need to release the image back to the EGLStream once by any of the consumers who is the last one to reference this image? Or should we do something like, in the eglstream sample code, calling NvMediaEglStreamConsumerReleaseImage twice by each consumer?
  4. Any suggestion if the two consumers are in the two different processes?

Thanks in advance!


Dear chenghul,

Using EGL Stream, only one producer can be connected to one consumer at a time. However, the same image buffer can be sent from multiple producers to multiple consumers using multiple streams. Both consumers and producers can be in different processes as well.

In case of two producer and two consumers, the application has to call NvMediaEglStreamProducerGetImage and NvMediaEglStreamConsumerReleaseImage APIs on both streams.

If multiple producers and consumer are using same image buffer, it is the application’s responsibility to make sure that NvMediaEglStreamProducerGetImage is called on both streams before feeding the buffer back to the producer. Thanks.

Hi Steve,

Thank you for your response!
Right now I can send the same image buffer to two different processes and handle the memory very well.