#ifndef __DX__DxDecoderWrap__ #define __DX__DxDecoderWrap__ #include #include #include #include #include "cuda_kernels.h" #include "SfxDecoder.h" #define DX_GPU_FRAME_DEFAULT_SIZE 1 using namespace std; typedef struct DxConfig { int devId; // 设备(GPU)ID int decMode; // 解码模式: 0 全解码; 1 关键帧解码 int colorFmt; // 颜色空间 bool forceTcp; // 对于实时流,是否强制为TCP取流 std::string name; int skip_frame; string uri; LOG_ALL_CALLBACK log_all; void* log_user_ptr; }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(); virtual ~DxDecoderWrap(); int DxOpenDecoder(const DxConfig& cfg); int DxCloseDecoder(); bool DxDecoderIsRun() const; bool DxDecoderIsFinished(); unsigned 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;}; bool isStream(string sVideoFileName); void DxCUDADecoderCallback(void * buf, unsigned int size, int width, int height, unsigned long long timestamp ); int DxDecoderLogCallback(DxLogLevel level, const char * log, unsigned int logLen ); private: bool m_bReal; bool m_bRun; bool m_bPause; unsigned int m_nums; string m_name; SfxDecoder* m_pDec; std::queue m_queue_frames; std::mutex m_queue_frames_mutex; unsigned int m_skip; int m_devId; int m_width{0}; int m_height{0}; }; #endif