NVIDIA DRIVE OS Linux SDK API Reference

5.1.15.0 Release
For Test and Development only
nvros_egl_cuda_io.h
Go to the documentation of this file.
1 /*Copyright (c) 2020, 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
nvros::EGL_CU_IO_UNSUPPORTED_EGL_FRAME
@ EGL_CU_IO_UNSUPPORTED_EGL_FRAME
Indicates that the EGL frame is unsupported.
Definition: nvros_egl_cuda_io.h:54
nvros::NvRosEglCudaIO::StopEglCuOutputLoop
NvRosErr StopEglCuOutputLoop()
Stops the iterative processing of the EGL CUDA pipeline over the output stream as started by RunEglCu...
nvros::NvRosEglCudaIO::RunEglCuInputLoop
NvRosErr RunEglCuInputLoop()
Fetches frames from the EGL CUDA pipeline over the input EGLStream and places them into the queue.
nvros::NvRosEglCudaIO::InitEglCuIO
NvRosErr InitEglCuIO(const char *inputSocketPath, const char *outputSocketPath)
Initializes the EGL CUDA pipeline over the given input and output EGLStream socket paths.
nvros::_EglCuIOErrors
_EglCuIOErrors
Defines the error codes emitted by the EGL CUDA IO library.
Definition: nvros_egl_cuda_io.h:45
nvros::_EglFrameParams::depth
unsigned int depth
Specifies the depth.
Definition: nvros_egl_cuda_io.h:85
nvros::NvRosEglCudaIO::GetEglFrameContent
CUarray GetEglFrameContent()
Gets the contents from the first, oldest unprocessed EGL frame in the form of a CUarray that can be p...
nvros::NvRosEglUtil
Class to initialize the EGLStream for the following roles: EGLOUTPUT_CONSUMER, CUDA_CONSUMER,...
Definition: nvros_egl_utils.h:285
nvros::EglCuIOErrors
enum nvros::_EglCuIOErrors EglCuIOErrors
Defines the error codes emitted by the EGL CUDA IO library.
nvros::NvRosEglCudaIO::NvRosEglCudaIO
NvRosEglCudaIO()
Constructs the NvRosEglCudaIO class object.
nvros::NvRosEglCudaIO::~NvRosEglCudaIO
~NvRosEglCudaIO()
Destroys the NvRosEglCudaIO object.
nvros::_EglFrameParams::frameType
unsigned int frameType
Specifies the frame type.
Definition: nvros_egl_cuda_io.h:79
nvros::NvRosEglCudaIO::RunEglCuOutputLoop
NvRosErr RunEglCuOutputLoop()
Sets up the CUDA context for the CUDA producer role.
nvros::_EglUtilState
Holds EGL related parameters.
Definition: nvros_egl_utils.h:198
nvros::NvRosEglCudaIO::GetAvailableFrameCount
int GetAvailableFrameCount()
Gets the number of frames available for processing.
nvros::NvRosEglCudaIO::PushEglFrameOut
NvRosErr PushEglFrameOut(CUarray outputArray)
Pushes processed EGL frames out.
nvros::_EglFrameParams::colorFormat
unsigned int colorFormat
Specifies the color format.
Definition: nvros_egl_cuda_io.h:73
nvros::EglFrameParams
struct nvros::_EglFrameParams EglFrameParams
Holds the required EGL frame-related parameters for processing that frame.
nvros::NvRosEglCudaIO
Creates CUDA processing pipelines for EGLStreams.
Definition: nvros_egl_cuda_io.h:100
nvros::NvRosErr
enum nvros::_NvRosErrCode NvRosErr
Declares error codes for all NvROS modules and packages.
nvros::_CudaEglParams
Holds CUDA EGL related parameters.
Definition: nvros_egl_utils.h:251
nvros::_EglFrameParams::frameWidth
unsigned int frameWidth
Specifies the width of the frame.
Definition: nvros_egl_cuda_io.h:64
nvros::NvRosEglCudaIO::RegisterErrCallbackFunc
NvRosErr RegisterErrCallbackFunc(void(*errCallback)(unsigned int))
Registers a callback function for CUDA EGL library to invoke when an error is encountered.
nvros::NvRosEglCudaIO::GetInEglFrameParams
EglFrameParams GetInEglFrameParams()
Gets parameters of input EGL frames.
nvros::NvRosEglCudaIO::SetGlobalContext
NvRosErr SetGlobalContext(CUcontext &context)
Sets the global CUDA context for all threads that perform CUDA EGL inter-operations and executes cert...
nvros::_EglFrameParams::frameHeight
unsigned int frameHeight
Specifies the height of the frame.
Definition: nvros_egl_cuda_io.h:67
nvros::_EglFrameParams::channels
unsigned int channels
Specifies the number of channels.
Definition: nvros_egl_cuda_io.h:70
nvros::_EglFrameParams
Holds the required EGL frame-related parameters for processing that frame.
Definition: nvros_egl_cuda_io.h:61
nvros::EGL_CU_IO_CUDA_API_ERR
@ EGL_CU_IO_CUDA_API_ERR
Indicates that an error occurred during the CUDA driver/runtime API call.
Definition: nvros_egl_cuda_io.h:51
nvros::NvRosEglCudaIO::StopEglCuInputLoop
NvRosErr StopEglCuInputLoop()
Stops the iterative processing of the EGL CUDA pipeline over the input stream as started by RunEglCuI...
nvros::NvRosEglCudaIO::SetOutEglFrameParams
NvRosErr SetOutEglFrameParams(EglFrameParams mOutEglFrameParams)
Sets parameters of output EGL frames.
nvros::_EglFrameParams::planes
unsigned int planes
Specifies the number of planes in the frame.
Definition: nvros_egl_cuda_io.h:76
nvros::EGL_CU_IO_STREAM_DISCONNECTED
@ EGL_CU_IO_STREAM_DISCONNECTED
Indicates that EGLStream is in a disconnected state.
Definition: nvros_egl_cuda_io.h:48
nvros
A global namespace for NvRos packages.
nvros::_EglFrameParams::pitch
unsigned int pitch
Specifies the pitch.
Definition: nvros_egl_cuda_io.h:82