FFNvDecoder.h 1.17 KB
#include<string>
#include <pthread.h>

#include "FrameQueue.h"

#include "AbstractDecoder.h"

using namespace std;

class FFNvDecoder : public AbstractDecoder{
public:
    FFNvDecoder();
    ~FFNvDecoder();
    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 isSurport(FFDecConfig& cfg);

    int getCachedQueueLength();

    float fps();

    DECODER_TYPE getDecoderType(){ return DECODER_TYPE_FFMPEG; }

public:
    AVPixelFormat getHwPixFmt();

private:
    void decode_thread();
    void post_decode_thread();
    bool init(const char* uri, const char* gpuid, bool force_tcp);
    void decode_finished();

private:
    AVStream* stream;
    AVCodecContext *avctx;
    int stream_index;
    AVFormatContext *fmt_ctx;
    AVPixelFormat hw_pix_fmt;

    pthread_t m_decode_thread;
    pthread_t m_post_decode_thread;
    
    bool m_bRunning;
    bool m_bFinished;

    bool m_bPause;
    FrameQueue mFrameQueue;

    bool m_bReal; // 是否实时流

    float m_fps;
};