#ifndef __DX__DxDecoderWrap__ #define __DX__DxDecoderWrap__ #include #include #include #include #include "cuda_kernels.h" #include "FFNvDecoder.h" #define DX_GPU_FRAME_DEFAULT_SIZE 1 typedef struct DxConfig { int devId; // 设备(GPU)ID int decMode; // 解码模式: 0 全解码; 1 关键帧解码 int colorFmt; // 颜色空间 bool forceTcp; // 对于实时流,是否强制为TCP取流 std::string name; }DxConfig; typedef struct DxGPUFrame { void * frame {nullptr}; unsigned int size; unsigned int width; unsigned int height; unsigned long long timestamp; std::string dec_name; }DxGPUFrame; typedef struct DxGPUFrames { unsigned int size; unsigned int read; unsigned int write; unsigned int width; unsigned int height; unsigned int counts; DxGPUFrame * frames; }DxGPUFrames; class DxDecoderWrap { public: DxDecoderWrap( const DxConfig * cfg ); virtual ~DxDecoderWrap(); int DxOpenDecoder( const char * uri, unsigned int skip ); int DxCloseDecoder(); bool DxDecoderIsRun() const; bool DxDecoderIsFinished(); int DxGetFrameCount(); int DxGetResolution( int &width, int &height ); bool DxFrameIsEmpty(); int DxLockFrame(DxGPUFrame& frame ); DxGPUFrame DxGetFrame(); int PauseDecoder(); int ResumeDecoder(); public: string GetName() {return m_name;}; void post_decode_callback(GPUFrame * gpuFrame); void decode_finished_callback(); private: bool m_bClose; bool m_bReal; FFDecConfig m_cfg; string m_name; FFNvDecoder* m_pDec; std::queue m_queue_frames; std::mutex m_queue_frames_mutex; int m_decMode{0}; }; #endif