NVIDIA DRIVE OS Linux API Reference

5.1.3.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvros_egl_cuda_io.h
Go to the documentation of this file.
1 /*Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
2 
3 NVIDIA CORPORATION and its licensors retain all intellectual property
4 and proprietary rights in and to this software, related documentation
5 and any modifications thereto. Any use, reproduction, disclosure or
6 distribution of this software and related documentation without an express
7 license agreement from NVIDIA CORPORATION is strictly prohibited.*/
8 
9 
19 #ifndef _NVROS_EGL_CUDA_IO_
20 #define _NVROS_EGL_CUDA_IO_
21 #include <queue>
22 #include <mutex>
23 #include <condition_variable>
24 
25 #include "nvros_egl_utils/nvros_egl_utils.h"
26 
31 namespace nvros
32 {
45  typedef enum _EglCuIOErrors
46  {
49 
52 
55 
56  } EglCuIOErrors;
57 
61  typedef struct _EglFrameParams
62  {
64  unsigned int frameWidth;
65 
67  unsigned int frameHeight;
68 
70  unsigned int channels;
71 
73  unsigned int colorFormat;
74 
76  unsigned int planes;
77 
79  unsigned int frameType;
80 
82  unsigned int pitch;
83 
85  unsigned int depth;
86 
88 
101 {
102 
103  private:
104  NvRosEglUtil mNvRosEglUtilIn;
105  NvRosEglUtil mNvRosEglUtilOut;
106  std::queue<CUarray> inQ;
107  std::queue<CUarray> outQ;
108  std::queue<CUdeviceptr> inQPl;
109  std::queue<CUdeviceptr> outQPl;
110  const char* inSocketPath;
111  const char* outSocketPath;
112  EglFrameParams mEglFrameParamsIn;
113  EglFrameParams mEglFrameParamsOut;
114  CudaEglParams* mCudaConsumerParams;
115  CudaEglParams* mCudaProducerParams;
116  EGLStreamKHR eglStreamIn;
117  EGLStreamKHR eglStreamOut;
118  EGLDisplay eglDisplayIn;
119  EGLDisplay eglDisplayOut;
120  EglUtilState* eglUtilStateIn;
121  EglUtilState* eglUtilStateOut;
122  void (*errCallback)(unsigned int);
123  bool stopCuEglLoop;
124 
125  /*Synchronization vars*/
126  std::mutex inQMutex;
127  std::condition_variable inQCV;
128  std::mutex outFrameParamsWaitCVMtx;
129  std::condition_variable outFrameParamsWaitCV;
130  std::mutex outQMutex;
131  std::condition_variable outQCV;
132 
133 
134  /*Private methods*/
135  NvRosErr EglCudaInputLooper();
136  NvRosErr EglCudaOutputLooper();
137 
138  public:
139 
143  NvRosEglCudaIO();
144 
148  ~NvRosEglCudaIO();
149 
158  NvRosErr SetGlobalContext(CUcontext& context);
159 
176  NvRosErr InitEglCuIO(const char* inputSocketPath, const char* outputSocketPath);
177 
187 
198 
206 
214 
225  NvRosErr RegisterErrCallbackFunc(void(*errCallback)(unsigned int));
226 
233 
242  NvRosErr SetOutEglFrameParams(EglFrameParams mOutEglFrameParams);
243 
250 
257  CUarray GetEglFrameContent();
258 
267  CUdeviceptr GetEglFrameContent(bool pitchLinearFrame);
268 
276  NvRosErr PushEglFrameOut(CUarray outputArray);
277 
285  NvRosErr PushEglFrameOut(CUdeviceptr outCUdevptr);
286  };
287 
289 }
290 #endif
NvRosErr RegisterErrCallbackFunc(void(*errCallback)(unsigned int))
Registers a callback function for CUDA EGL library to invoke when an error is encountered.
Class to initialize the EGLStream for the following roles: EGLOUTPUT_CONSUMER, CUDA_CONSUMER, CUDA_PRODUCER, IMAGE_PRODUCER.
NvRosErr PushEglFrameOut(CUarray outputArray)
Pushes processed EGL frames out.
NvRosErr RunEglCuInputLoop()
Fetches frames from the EGL CUDA pipeline over the input EGLStream and places them into the queue...
EglFrameParams GetInEglFrameParams()
Gets parameters of input EGL frames.
int GetAvailableFrameCount()
Gets the number of frames available for processing.
NvRosErr SetOutEglFrameParams(EglFrameParams mOutEglFrameParams)
Sets parameters of output EGL frames.
NvRosErr StopEglCuInputLoop()
Stops the iterative processing of the EGL CUDA pipeline over the input stream as started by RunEglCuI...
NvRosErr StopEglCuOutputLoop()
Stops the iterative processing of the EGL CUDA pipeline over the output stream as started by RunEglCu...
Indicates that an error occurred during the CUDA driver/runtime API call.
CUarray GetEglFrameContent()
Gets the contents from the first, oldest unprocessed EGL frame in the form of a CUarray that can be p...
unsigned int depth
Specifies the depth.
Indicates that EGLStream is in a disconnected state.
unsigned int frameType
Specifies the frame type.
NvRosEglCudaIO()
Constructs the NvRosEglCudaIO class object.
enum nvros::_EglCuIOErrors EglCuIOErrors
Defines the error codes emitted by the EGL CUDA IO library.
Creates CUDA processing pipelines for EGLStreams.
Holds the required EGL frame-related parameters for processing that frame.
unsigned int frameWidth
Specifies the width of the frame.
Indicates that the EGL frame is unsupported.
unsigned int colorFormat
Specifies the color format.
enum nvros::_NvRosErrCode NvRosErr
Declares error codes for all NvROS modules and packages.
~NvRosEglCudaIO()
Destroys the NvRosEglCudaIO object.
unsigned int frameHeight
Specifies the height of the frame.
unsigned int planes
Specifies the number of planes in the frame.
NvRosErr InitEglCuIO(const char *inputSocketPath, const char *outputSocketPath)
Initializes the EGL CUDA pipeline over the given input and output EGLStream socket paths...
Holds EGL related parameters.
unsigned int channels
Specifies the number of channels.
NvRosErr SetGlobalContext(CUcontext &context)
Sets the global CUDA context for all threads that perform CUDA EGL inter-operations and executes cert...
struct nvros::_EglFrameParams EglFrameParams
Holds the required EGL frame-related parameters for processing that frame.
Holds CUDA EGL related parameters.
_EglCuIOErrors
Defines the error codes emitted by the EGL CUDA IO library.
NvRosErr RunEglCuOutputLoop()
Sets up the CUDA context for the CUDA producer role.
unsigned int pitch
Specifies the pitch.