#ifndef _GB28181_DECODER_H_ #define _GB28181_DECODER_H_ #include #include #include "RTPReceiver.h" #include "../dvpp/DvppStreamDecoder.h" #include "common_header.h" #include "../interface/AbstractDecoder.h" struct AVFormatContext; struct AVCodecContext; struct AVCodec; struct AVFrame; struct AVDictionary; struct AVPacket; using namespace std; class DvppGB28181Decoder: public AbstractDecoder { public: DvppGB28181Decoder(); ~DvppGB28181Decoder(); bool init(FFDecConfig& cfg); void close(); bool start(); void pause(); void resume(); void setDecKeyframe(bool bKeyframe); bool isRunning(); bool isFinished(); bool isPausing(); bool getResolution( int &width, int &height ); bool getOutResolution( int &width, int &height ); bool isSurport(FFDecConfig& cfg); int getCachedQueueLength(); float fps(); DECODER_TYPE getDecoderType(){ return DECODER_TYPE_DVPP_GB28181; } DeviceMemory* snapshot(); void setName(string nm){ m_dec_name = nm; } string getName(){ return m_dec_name; } void setPostDecArg(const void* postDecArg); void setFinishedDecArg(const void* finishedDecArg); void doRecode(RecoderInfo& recoderInfo); void set_mq_callback(std::function mq_publish); public: void stream_callback(int videoType, char* data, int len, int isKey, uint64_t pts, uint64_t localPts); void stream_end_callback(); void display_thread(); private: int ff_decode(int videoType, AVPacket* pkt); private: string m_dec_name; // 必须为28181编码 FFDecConfig m_cfg; RTPReceiver* m_rtpPtr {nullptr}; uint64_t m_startPts {}; uint64_t m_lastPts {}; //上一次pts的值 uint64_t m_curPts {}; //当前的pts值 uint64_t m_diffPts {}; uint32_t frameW {}, frameH {}; float m_fps {}; int m_frameSkip {}; int log_count {}; std::atomic_int m_status {}; pthread_t m_post_decode_thread; const void * m_postDecArg; POST_DECODE_CALLBACK post_decoded_cbk; // 解码数据回调接口 const void * m_finishedDecArg; DECODE_FINISHED_CALLBACK decode_finished_cbk; queue mFrameQueue; mutex m_queue_mutex; mutex m_snapshot_mutex; bool m_dec_keyframe; DvppStreamDecoder streamDecoder; int m_gpuid {0}; }; #endif // _GB28181_DECODER_H_