NVIDIA Tegra
NVIDIA DRIVE OS 5.1 Linux SDK

Developer Guide
5.1.6.0 Release


 
EGL Stream (nvm_eglstream)
 
Architecture
EGL Image Frame
EGLStream Producer
EGLStream Consumer
EGLStream Operation Modes
EGLStream Pipeline
EGLStream Application
Command Line Switches
Required Switches
Other Switches
Single-Process Examples
Cross-Process Examples
Cross-Partition Examples
EGL is an interface between Khronos rendering APIs such as OpenGL and the underlying native platform window system. It handles:
Graphics context management
Surface/buffer binding
Rendering synchronization
It also enables high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs.
Architecture
EGLStream is an EGL object that exposes a set of APIs that transfer a sequence of EGL image frames between software components (e.g., video frames from NvMedia to OpenGL ES). Each EGLStream is associated with a producer that generates EGL image frames and inserts them into the EGLStream. The producer is responsible for inserting each EGL image frame into the EGLStream at the correct time so that the consumer can process the frame for the appropriate duration; for example, to display the EGL image frame.
Each EGLStream is also associated with a consumer that retrieves EGL image frames from the EGLStream. The consumer is responsible for determining when an image frame is available, and displaying it or consuming it in some other way. The consumer is also responsible for indicating the latency when that is possible. The latency is the interval from the time when an image frame is retrieved from the EGLStream to the time it is delivered to the user.
EGL Image Frame
An EGL image frame is the entity posted by the producer to the EGLStream and acquired later by the consumer. A sequence of image frames may be:
Frames of video data decoded from a video file
Images output by a camera sensor
Surfaces rendered using OpenGL commands
Frames generated in some other manner
The color format for the image frame can be:
RGBA and YUV420 planar
YUV420 semi-planar
Different types of image frames must be posted to the EGLStream using different types of producers.
EGLStream Producer
The EGLStream producer is the entity that posts EGL image frames into the EGLStream. In the NvMedia domain there are two types of producers:
Video producer: Posts NvMedia video surfaces as EGL image frames. Video surfaces can be generated by an NvMedia video decoder, by NvMedia video capture, etc. The supported video surface formats include:
NvMediaSurfaceType_R8G8B8A8
NvMediaSurfaceType_Video_420
Image producer: Posts NvMedia image surfaces as EGL image frames. Image surfaces can be generated by an NvMedia image JPEG decoder, by NvMedia image capture, etc. The supported image surface formats include:
NvMediaSurfaceType_Image_RGBA
NvMediaSurfaceType_Image_YUV_420
Other types of producers outside the NvMedia domain are:
CUDA producer: Posts a CUDA array or CUDA pointer as EGL image frames to the EGLStream.
GL producer: Posts graphic surfaces as EGL image frames to the EGLStream.
EGLStream Consumer
The EGLStream consumer is the entity that retrieves or acquires EGL image frames from the EGLStream. In the NvMedia domain, there are two types of consumers:
Video consumer: Acquires EGL image frames and fills the frame information in NvMedia video surfaces. Video surfaces acquired can then be consumed by NvMedia video encoder, or NvMedia video display, etc.
Image consumer: Acquires EGL image frames and fills the frame information in NvMedia image surfaces (NvMediaImage). Image surfaces acquired can then be consumed by NvMedia image encoder, or NvMedia image display, etc.
Other types of consumers outside the NvMedia domain are:
CUDA consumer: Retrieves EGL image frames and fills the frame information as a CUDA array or CUDA pointer. The CUDA frames can then be processed in the CUDA domain.
GL consumer: Retrieves EGL image frames that can then be used in graphic rendering.
EGL output consumer (egldevice window interface only): Retrieves EGL image frames and renders them directly to EGL output. This consumer is valid when EGL output is used on the egldevice window interface.
EGLStream Operation Modes
There are two types of EGLStream operation modes: mailbox mode and FIFO mode. NvMedia producers and consumers support both modes.
Mailbox Mode
In mailbox mode, EGLStream conceptually operates as a mailbox. When a new frame is generated, the producer waits for a certain time for the consumer to process the frame. If the consumer does not consume the frame, the producer discards the frame when it posts the next frame into the stream. This means that if the consumer consumes frames slower than the producer posts them, some frames may be lost and never be seen by the consumer. The producer is never stalled. Therefore, the timing of EGLStream in mailbox mode is controlled by the producer.
FIFO Mode
In FIFO mode, EGLStream operates as a FIFO queue rather than a mailbox. If the previous frame is not used by the consumer yet, the newly generated frame is added into an available slot in the queue. EGLStream sets the queue size when it creates the queue. If the queue is full, the producer is stalled until there is room in the queue, that is, until the consumer has consumed some previous frames. In this mode, frames are not discarded.
The timing of an EGLStream in FIFO mode is controlled by the consumer. Each frame in the queue has a timestamp set by the producer. The consumer uses this timestamp to determine when the frame is intended to be processed.
EGLStream Pipeline
EGL provides functions to create and destroy EGLStreams, to query and set attributes of EGLStreams, and to connect EGLStreams to producers and consumers.
Each EGLStream must be connected to only one producer and one consumer. Once an EGLStream is connected to a consumer, it is connected to that consumer until the EGLStream is destroyed. Likewise, once an EGLStream is connected to a producer it is connected to that producer until the EGLStream is destroyed.
An EGLStream must be connected to a consumer before it is connected to a producer.
Building a Simple EGLStream Pipeline
Before you build a simple EGLStream pipeline, you must initialize the EGL interface on the platform and create the EGLDisplay.
1. Create the EGLDisplay object for the EGLStream to bind to it.
The following window interfaces are supported in the application:
X11 (Linux only)
EGL device
There is a separate implementation for each window system. For code details, see the following dictionary:
home/nvidia/samples/nvmedia/eglstream/winintf/
2. Call eglInitialize() to initialize EGL on the created display or on the default display.
If the GL consumer or EGL output consumer is used, you must initialize the rendering window before creating the EGL pipeline.
If the NvMedia/CUDA producer-consumer is used, window system initialization is not required. In the absence of available display devices, EGL can be initialized using the default display. Instead of rendering output, EGL can write an encoded (H.264) output file for NvMedia consumer.
There is a separate implementation of WindowSystemInit() for each window system. For more information, see the EGL initialization implementations in the winintf directory.
3. Create an EGLStream.
The following example of creating an EGLStream is from eglstrm_setup.c:
// Standalone consumer or no standalone mode
eglStream = eglCreateStreamKHR(display,
args->fifoMode ? streamAttrFIFOMode : streamAttrMailboxMode);
if (eglStream == EGL_NO_STREAM_KHR) {
LOG_ERR("EGLStreamInit: Couldn't create eglStream.\n");
return 0;
}
Depending on whether mailbox mode or FIFO mode is used, the EGLStream sample sets the attrib_list to one of the arrays shown in the following example.
static const EGLint streamAttrMailboxMode[] = {
EGL_METADATA0_SIZE_NV, 16*1024,
EGL_METADATA1_SIZE_NV, 16*1024,
EGL_METADATA2_SIZE_NV, 16*1024,
EGL_METADATA3_SIZE_NV, 16*1024, EGL_NONE };
static const EGLint streamAttrFIFOMode[] = {
EGL_STREAM_FIFO_LENGTH_KHR, 4,
EGL_METADATA0_SIZE_NV, 16*1024,
EGL_METADATA1_SIZE_NV, 16*1024,
EGL_METADATA2_SIZE_NV, 16*1024,
EGL_METADATA3_SIZE_NV, 16*1024, EGL_NONE };
4. Create a consumer and connect it to the EGLStream.
The EGLStream sample application defines the following consumer creation functions:
video_display_init(); // Initializes an NvMedia video consumer.
image_display_init(); // Initializes an NvMedia image consumer.
cuda_consumer_init(); // Initializes a CUDA consumer.
glConsumer_init(); // Initializes a GL consumer.
Each consumer creation function starts a process thread for procThreadFunc(). procThreadFunc(), which is specific to the consumer, acquires and processes EGL frames. The following example is from cuda_consumer.c:
pthread_create(&cudaConsumer->procThread, NULL, procThreadFunc, (void *)cudaConsumer);
if (!cudaConsumer->procThread) {
LOG_ERR("Cuda consumer init: Unable to create process thread\n");
cudaConsumer->procThreadExited = NV_TRUE;
return NV_FALSE;
}
Once an EGLStream is connected to a consumer, it remains connected to the same consumer until the EGLStream is destroyed.
5. Create a producer and connect it to the EGLStream.
The EGLStream sample application defines the following producer creation functions:
VideoDecoderInit(); // Initializes an NvMedia video producer.
Image2DInit(); // Initializes an NvMedia image producer.
CudaProducerInit(); // Initializes a CUDA producer.
GearProducerInit(); // Initializes a GL producer.
Once an EGLStream is connected to a producer, it must remain connected to the same producer until the EGLStream is destroyed.
The initialization function also starts a process thread for generating and posting EGL frames.
Acquiring a Single Frame
A consumer acquires one frame, processes it, and releases it before acquiring the next frame. Consequently a consumer holds, at most, one frame at any time in both mailbox and FIFO modes.
Single Frame communication between producer and consumer in the EGLStream pipeline is as follows:
The producer posts an EGL image frame (video surface or image surface) to the EGLStream using NvMediaEglStreamProducerPostSurface() or NvMediaEglStreamProducerPostImage().
The following example is from nvmvid_producer.c:
status = NvMediaEglStreamProducerPostSurface(parser->producer,
renderSurface, timestamp);
if(status != NVMEDIA_STATUS_OK) {
EGLint streamState = 0;
if(!eglQueryStreamKHR(
parser->eglDisplay,
parser->eglStream,
EGL_STREAM_STATE_KHR,
&streamState)) {
LOG_ERR("main: eglQueryStreamKHR EGL_STREAM_STATE_KHR
failed\n");
}
if(streamState != EGL_STREAM_STATE_DISCONNECTED_KHR &&
!parser->stopDecoding)
LOG_ERR("SendRenderSurface: NvMediaPostSurface
failed\n");
return 0;
The consumer acquires/retrieves the EGL image frame from the EGLStream. The consumer acquires/retrieves the frame with NvMediaEglStreamConsumerAcquireSurface() or NvMediaEglStreamConsumerAcquireImage(). If there is no new frame available for the surface, those functions return NULL.
The following example is from nvmvid_consumer.c:
if(NVMEDIA_STATUS_ERROR ==
NvMediaEglStreamConsumerAcquireSurface(display->consumer,
&surface, 16, &timeStamp)) {
LOG_DBG("Nvmedia video Consumer: - surface acquire
failed\n");
display->quit = NV_TRUE;
goto done;
}
The consumer releases the EGL image frame (surface) after consuming it, using NvMediaEglStreamConsumerReleaseSurface() or NvMediaEglStreamConsumerReleaseImage().
The producer gets the EGL image frame back after consumer releases it. The producer can then update the surface and repost it later. If the consumer does not release a frame, it must return NULL for the surface using NvMediaEglStreamProducerGetSurface() or NvMediaEglStreamProducerGetImage().
The following example is from nvmvid_producer.c:
NvMediaVideoSurface *videoSurface = NULL;
NvMediaStatus status;
status = NvMediaEglStreamProducerGetSurface(ctx->producer,
&videoSurface, 100);
if(status == NVMEDIA_STATUS_TIMED_OUT) {
LOG_DBG("cbAllocPictureBuffer: NvMediaGetSurface
waiting\n");
} else if(status == NVMEDIA_STATUS_OK) {
ReleaseFrame(ctx, videoSurface);
} else
goto failed;
In the NvMedia EGLStream sample application, two threads are created: one for the producer, and one for the consumer.
For each of the thread process functions ProducerProc() and ConsumerProc(), the following diagram shows which functions are called in each thread for EGLStream frame communication.
Acquiring Multiple Frames
Before releasing a frame for the first time, the consumer acquires multiple frames. Thus, the consumer can hold more than one frame during the active processing time. For NvMedia consumer types, the maximum number of frames a consumer can hold is 6.
Use FIFO mode for acquiring multiple frames. The frame communication is the same as for acquiring a single case, except that ConsumerProc() calls ConsumerAcquireSurface()more than once before calling ConsumerReleaseSurface(). The consumer must verify that the surfaces are released in the same order as they are acquired, i.e., first in first out.
Managing the EGLStream Pipeline Buffer
To prevent the producer from overwriting the frame buffer while the consumer is still processing the frame, it is recommended that you create a buffer pool on the producer side. The buffer pool size can be 2 or more, depending on the application. If the buffer pool size is 2, the producer can generate and post one frame to the EGLStream, then generate a second frame using the second buffer without waiting for the consumer to consume the first frame. When the consumer releases the first frame back to the producer, the producer can then reuse the first frame buffer to generate a third frame.
When acquiring multiple frames, the buffer pool size must be at least <n>+1, where <n> is the number of frames the consumer holds at any time.
Destroying the EGLStream Pipeline
To destroy the EGLStream pipeline, you must:
1. Destroy the producer
2. Destroy the consumer
3. Destroy the EGLStream
4. Destroy the resources for the window system
EGLStream sample functions that destroy producers are:
VideoDecoderDeinit() // Video producer destroy
Image2DDeinit() // Image producer destroy
CudaProducerDeinit() // CUDA producer destroy
EGLStream sample functions that destroy consumers are:
video_display_Deinit() // Video consumer destroy
image_display_Deinit() // Image consumer destroy
cuda_consumer_Deinit() // CUDA consumer destroy
For example:
if(args.nvmediaVideoProducer)
VideoDecoderFlush();
else if(args.nvmediaImageProducer)
Image2DproducerFlush();
LOG_DBG("main - flush produer and consumer eglstream: Done\n");
LOG_DBG("main - program end, clean up start\n");
if(args.nvmediaVideoProducer)
VideoDecoderDeinit();
else if (args.nvmediaImageProducer)
Image2DDeinit();
else if (args.cudaProducer) {
#ifdef CUDA_SUPPORT
CudaProducerDeinit();
#endif
}
else if(args.glProducer) {
GearProducerDeinit();
}
The EGLStream sample function that destroys the EGLStream is:
EGLStreamFini()
The EGLStream sample code that shuts down the window interface is:
EGLUtilDeinit()
EGLUtilDeinit() is in the folder:
eglstream/winintf
It calls WindowSystemWindowTerminate() and WindowSystemTerminate(). Each of these functions has different implementation for each window interface.
Transitioning the EGLStream State
After an EGLStream is created, at any given time, the EGLStream is in one of the following defined states:
EGL_STREAM_STATE_CREATED_KHR: The EGLStream has been created but not yet connected to a producer or a consumer.
EGL_STREAM_STATE_CONNECTING_KHR: The EGLStream has been connected to a consumer but not yet connected to a producer.
EGL_STREAM_STATE_EMPTY_KHR: The EGLStream has been connected to a consumer and a producer, but the producer has not yet posted any image frames.
EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR: The producer has posted at least one image frame that the consumer has not yet acquired.
EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR: The producer has posted at least one image frame, and the consumer has acquired the most recently posted image frame.
EGL_STREAM_STATE_DISCONNECTED_KHR: The producer, or the consumer, or both, are no longer connected to the EGLStream (e.g. they have been destroyed). Once the EGLStream is in this state it remains in this state until the EGLStream is destroyed. In this state only eglQueryStreamKHR() and eglDestroyStreamKHR() are valid operations.
The EGLStream state is queried as follows:
EGLBoolean eglQueryStreamKHR(
EGLDisplay dpy,
EGLStreamKHR stream,
EGLenum attribute,
EGLuint64KHR *value);
The following state transitions may occur:
1. EGL_STREAM_STATE_CREATED_KHR: A new EGLStream is created in this state.
2. EGL_STREAM_STATE_CREATED_KHR to EGL_STREAM_STATE_CONNECTING_KHR: Occurs when a consumer is connected to the EGLStream.
3. EGL_STREAM_STATE_CONNECTING_KHR to EGL_STREAM_STATE_EMPTY_KHR: Occurs when a producer is connected to the EGLStream.
4. EGL_STREAM_STATE_EMPTY_KHR to EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR: Occurs the first time the producer inserts an EGL image frame.
5. EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR to EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR: Occurs when the consumer begins acquiring a newly posted EGL image frame.
6. EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR to EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR: Occurs when the producer posts a new EGL image frame.
7. Any state to EGL_STREAM_STATE_DISCONNECTED_KHR: Occurs when the producer or consumer is destroyed.
Building a Cross-Process EGLStream Pipeline
To build a cross-process EGLStream pipeline, the consumer process creates the EGLStream. The consumer then gets the file descriptor for the EGLStream and sends the file descriptor through the socket to the producer process.
In the producer process, the producer receives the file descriptor through socket, then creates the EGLStream from the file descriptor. After the EGLStream is created in both consumer and producer processes, the consumer and the producer are created and connected to the EGLStream.
Building a Cross-Partition EGLStream Pipeline
You can also use an EGLStream across multiple partitions in a multi-OS environment. For more details about setting up and configuring multiple OSes, see Cross-Partition Examples.
To build a cross-partition EGLStream pipeline, the consumer process creates the EGLStream on the consumer partition. The consumer then creates a socket and waits for the producer to connect to that socket.
The producer uses the IP of the partition on which the consumer is running and the specific port on which the consumer created the EGLStream to connect to it. After a successful connection, the producer creates an EGLStream using the same handle. After the EGLStream is created in both consumer and producer processes, the consumer and the producer are created and connected to the same EGLStream.
EGLStream Application
The NvMedia EGLStream sample application demonstrates how to:
Create and initialize EGLStream, NvMedia EGLStream producers, NvMedia EGLStream consumers.
Get the EGLStreams to work together to post and acquire video or image surfaces.
Make the code modular so that the producers and consumers are running in their own threads in the same or different partitions.
Two types of NvMedia producers and two types of NvMedia consumers are supported:
For the NvMedia video producer, video decoder is used to generate video frames. Then the video producer posts the video surface, in the form of an NvMediaVideoSurface, to the EGLStream.
On the NvMedia video consumer side, after the video consumer acquires the video surface, it uses either the video mixer to display the video frames, or the video encoder to encode them.
For the NvMedia image producer, the image data is read from the YUV file to generate image surfaces in the form of NvMediaImage. Then the image producer posts the image surfaces to the EGLStream.
On the NvMedia image consumer side, after the image consumer acquires the image surface, it uses the image display to display the image frames.
To demonstrate NvMedia/GL/CUDA/EGLOut EGLStream interoperability, the application includes sample code for creating and using a GL producer, GL consumer, CUDA producer, CUDA consumer, and EGLOut consumer.
For a GL producer, the Gear application is used to generate graphic frames.
For a GL consumer, graphic display is used.
For a CUDA producer, the image is read from the YUV or RGB file and is copied to a CUDA array or CUDA device pointer. The producer posts it to the EGLStream.
For a CUDA consumer, after the consumer acquires the frame, the data is saved to a file.
For an EGLOut consumer, the received frames are rendered directly to the display in the egldevice window interface.
Command Line Switches
The EGLStream sample application’s command syntax is:
./nvm_eglstream -f <input filename> -producer <producer_type> -consumer <consumer_type> [-optional_switches]
To run the EGLStream sample application in an X11 target
This procedure applies to Linux only.
For an X11 target:
1. Start X11.
X -ac
2. Set the display.
export DISPLAY=:0
3. Run the application.
For an EGL device:
Run the application
Required Switches
The following table describes required command line switches.
Switch
Parameter
Description
-f
<input_file>
Input filename for producer. The file may be:
An H.264 file for Video producer.
A YUV 420 file for Image producer.
An RGBA file for CUDA producer when -ot is rgba.
A YUV file for CUDA producer when -ot is yuv420 or yuv420p.
-producer
<type>
Set producer type. The type may be:
0: Video producer
1: Image producer
2: GL producer
3: CUDA producer
The producer type must be specified in the consumer process for cross-process and cross-partition use.
-consumer
<type>
Set consumer type. The type may be:
0: Video consumer
1: Image consumer
2: GL consumer
3: CUDA consumer
4: EGL output consumer (using EGL output on egldevice window interface only)
The consumer type must be specified in the producer process for cross-process and cross-partition use.
-d
<id>
Display ID
-ot
<type>
Set surface type. The type may be: yuv420/yuv420p/rgba/yuv422p. Default is RGBA.
yuv420 for posting YUV420 semiplanar surfaces.
yuv420p for posting planar surfaces; supported only by CUDA and image producers and consumers
rgba for posting RGBA surfaces. The GL producer supports only the rgba surface type.
yuv422p for acquiring YUV 422 planar surfaces; supported only by CUDA and image consumers in standalone consumer modes. yuv422p is not supported by any producer in this application.
The rgba surface type is the default.
-fr
<W>x<H>
Input file resolution. Mandatory for the CUDA image producer.
-enc
<output_file>
Consumer encodes the acquired surfaces to an H.264 stream. Enabled for consumer type 0 and 1 only.
Other Switches
The following table describes other command line switches. These switches are either optional in all cases, or are required in some cases but optional or unused in others.
Switch
Parameter
Description
-h
N/A
Displays guidance on using this application.
-v
[level]
Sets logging level. The value may be:
0: Errors (default)
1: Warnings
2: Information
3: Debug
-fifo
N/A
Sets FIFO mode for EGLStream; if omitted, mailbox mode is used.
-metadata
N/A
Enables metadata for the EGLStream.
-standalone
[mode]
Sets standalone mode (cross-process/cross-partition mode for producer and consumer). The value may be:
0: Single process mode (default)
1: Cross-process producer
2: Cross-process consumer
3: Cross-partition producer
4: Cross-partition consumer
-pl
N/A
CUDA image producer uses pitch linear surface, if present. If omitted, it uses block linear surface.
-consumervm
[partition_id]
Sets VM ID of the partition in which a cross-partition consumer is running for a cross-partition producer. Required to run across partitions; otherwise not used.
-ip
[ip_address]
Sets the IP address of the partition in which a cross-partition consumer is running for cross-partition producer. Required to run across partitions; otherwise not used.
-socketport
[port_num]
Sets the port number used by the cross-partition consumer during EGLStream creation for cross-partition producer. Required to run across partitions; otherwise not used.
-defaultdisplay
N/A
Avoids initializing the window system. Uses the default EGL display for an NvMedia/CUDA producer/consumer in eglInitialize().
-w
[window_id]
Displays window ID for video/image consumer. The value may be 0, 1, or 2; the default is 1.
-l
[loop_num]
Number of loops for video/image producer. The default is 1.
-shader
[type]
Shader type; used when GL consumer is enabled.
The value may be YUV or RGB. RGB is the default.
-kpi
 
Enables KPI measures for EGLStream.
The nvm_eglstream application supports only NvMedia/CUDA producer/consumer combinations.
Single-Process Examples
This topic gives examples of how to perform single-process tasks.
To run an image consumer/video consumer
./nvm_eglstream -f disney.264 -producer 0 -consumer 0 -ot rgba -defaultdisplay -enc encode.264
To run an NvMedia video for a producer and consumer
./nvm_eglstream -f test.264 -producer 0 -consumer 0 -d 1 [-ot yuv420]
To run an NvMedia image for a producer and consumer
./nvm_eglstream -f test.yuv -fr 720x480 -producer 1 -consumer 1 -d 1 [-ot yuv420]
To run an NvMedia video producer and a GL consumer
./nvm_eglstream -f test.264 -producer 0 -consumer 2 [-ot yuv420]
To run an NvMedia image producer and a GL consumer
./nvm_eglstream -f test.yuv -fr 720x480 -producer 1 -consumer 2 [-ot yuv420]
To run an NvMedia video producer and a CUDA consumer
./nvm_eglstream -f test.264 -producer 0 -consumer 3 [-ot yuv420 -pl]
After running the application, you can view the saved output using yuvviewer. The output is saved to cuda.yuv.
To run an NvMedia image producer and a CUDA consumer
./nvm_eglstream -f test.yuv -fr 720x480 -producer 1 -consumer 3 [-ot yuv420 -pl]
After running the application, you can view the saved output using yuvviewer. The output is saved to cuda.yuv.
To run a CUDA producer and consumer
./nvm_eglstream -f test.yuv -fr 720x480 -producer 3 -consumer 3 [-ot yuv420 -pl]
After running the application, you can view the save output using yuvviewer. The output is saved to cuda.yuv.
To run an NvMedia video producer and an EGLOutput consumer
This example is valid only for an egldevice window interface and EGLOutput.
./nvm_eglstream -f test.264 -producer 0 -consumer 4 [-ot yuv420]
To run an NvMedia image producer and an EGLOutput consumer
This example is valid only for an egldevice window interface with EGLOutput.
./nvm_eglstream -f test.yuv -fr 720x480 -producer 1 -consumer 4 [-ot yuv420]
Cross-Process Examples
You can execute the following cross-process examples in two shells, or run one in the background in one shell.
The examples are similar to those described for single-process samples except for an additional argument, -consumer.
To run cross-process samples, add the switch ‑standalone 1 to the producer, and ‑standalone 2 to the consumer. Specify the consumer type in the producer command line with the -consumer argument.
To run an image consumer/video consumer
./nvm_eglstream -standalone 2 -producer 1 -consumer 0 -ot rgba -enc encode.264
./nvm_eglstream -standalone 1 -producer 1 -consumer 0 -f -ot rgba
To run an NvMedia video producer and consumer
./nvm_eglstream -f test.h264 -producer 0 -standalone 1 -consumer 0 [-ot yuv420]
./nvm_eglstream -consumer 0 -standalone 2 -producer 0 -d 1 [-ot yuv420]
To run an NvMedia video producer and an nvmedia image consumer
./nvm_eglstream -f test.h264 -producer 0 -standalone 1 -consumer 1 [-ot yuv420]
./nvm_eglstream -consumer 1 -standalone 2 -producer 0 -d 1 [-ot yuv420]
Cross-Partition Examples
You can execute the following cross-partition examples in two shells, one for each partition.
The examples are similar to those described for cross-process examples except for a few additional arguments: -consumervm, -ip, and -socketport.
To run cross-partition samples, hv0 of the consumer and producer partition must be configured to use two different IP addresses. For example, on VM1 (the producer partition), set it to 12.0.0.2 using:
ifconfig hv0 12.0.0.2
Similarly, on the consumer partition, you can set it to 12.0.0.1.
Add the switch ‑standalone 3 for the producer, and ‑standalone 4 for the consumer.
In the producer process, mention the VM ID of the consumer partition using the ‑consumervm argument. Set ‑ip to the IP address of the consumer partition, e.g. 12.0.0.1, as in the above example. Set -socketport to the same port number used to create the EGLStream in the consumer process.
If the producer is running on a partition that does not own the display, specify the ‑defaultdisplay switch in the command line for the producer to use the default EGL display for EGL initialization.
Set the DISPLAY_VM environment variable on the consumer partition. If the EGLOutput consumer is being used, set the DISPLAY_VM environment variable on the producer partition as well before executing the producer thread.
To run an NvMedia video producer and consumer
On VM1, where the producer will run, execute:
./nvm_eglstream -f test.h264 -producer 0 -standalone 3 -consumer 0 [-ot yuv420] -consumervm 0 -ip 12.0.0.2 -socketport 8000
On VM0, where the consumer will run, execute:
./nvm_eglstream -consumer 0 -standalone 4 -producer 0 -d 1 [-ot yuv420] -ip 12.0.0.1 -socketport 8000
To run an NvMedia video producer and an NvMedia image consumer
On VM1, where the producer will run, execute:
./nvm_eglstream -f test.h264 -producer 0 -standalone 3 -consumer 1 [-ot yuv420] -consumervm 0 -ip 12.0.0.2 -socketport 8000
On VM0, where the consumer will run, execute:
./nvm_eglstream -consumer 1 -standalone 4 -producer 0 -d 1 [-ot yuv420]