Building a Cross-Process EGLStream Pipeline

A cross-process EGLStream is one where the producer and consumer are in different processes.

NVIDIA provides two options for establishing a cross-process stream. One uses the EGL_KHR_stream_cross_process_fd extension, and the other uses the EGL_NV_stream_remote extension. In both cases, producer and consumer processes are responsible for establishing a socket connection with each other before beginning to create the stream.

With the EGL_KHR_stream_cross_process_fd extension, one of the applications creates the EGLStream and then gets a file descriptor from it. In the sample code, the consumer creates the stream, but it could be either end. The creator then obtains a file descriptor from the stream and passes it over to the socket to the other process. That process receives the file descriptor and uses it to create the other end of the EGLStream. After both endpoints have created their EGLStream object, consumer and producer connection proceeds as in the single process case. The processes maintain ownership of the socket, and can continue to use it for any other communication they need.

With the EGL_NV_stream_remote extension, the processes may use the sockets they create for any initial handshaking and communication, but then pass ownership of them to the stream. Producer and consumer both create EGLStream endpoints from their socket. For cross-process streams within the same partition, NVIDIA requires that the type used for the socket in the EGLStream creation call be UNIX. INET sockets are not supported. (This is in constrast with cross-partition streams described below.)

You can execute the following cross-process examples in two shells or run one in the background in one shell.