| | |
| | | |
| | | #include <stdint.h> |
| | | #include <memory> |
| | | #include <deque> |
| | | #include "PsToEs.hpp" |
| | | |
| | | struct AVFormatContext; |
| | |
| | | struct AVFrame; |
| | | struct AVCodec; |
| | | struct AVIOContext; |
| | | struct AVCodecParserContext; |
| | | |
| | | typedef int(* read_packet)(void *opaque,uint8_t *buf, int buf_size); |
| | | |
| | | namespace ffwrapper{ |
| | | |
| | | class VideoProp; |
| | | class CodedData; |
| | | class FrameData; |
| | | |
| | | class FormatIn |
| | | { |
| | | public: |
| | | explicit FormatIn(bool hw=true); |
| | | ~FormatIn(); |
| | | explicit FormatIn(const VideoProp &prop, bool hw=true); |
| | | virtual ~FormatIn(); |
| | | |
| | | public: |
| | | |
| | | virtual int open(const char *filename, AVDictionary **options); |
| | | virtual const bool IsHEVC()const; |
| | | virtual const bool IsAVC1()const; |
| | | virtual int readPacket(AVPacket *pkt_out); |
| | | virtual bool isVideoPkt(AVPacket *pkt); |
| | | virtual bool isAudioPkt(AVPacket *pkt); |
| | | bool notVideoAudio(AVPacket *pkt); |
| | | |
| | | int openWithCustomIO(void *opaque, read_packet fn, AVDictionary **options=NULL); |
| | | int openGb28181(const char *filename, AVDictionary **options); |
| | | bool openCodec(AVDictionary **options); |
| | | int decode(AVFrame* frame, AVPacket *pkt); |
| | | |
| | | int open(const char *filename, AVDictionary **options); |
| | | bool findStreamInfo(AVDictionary **options); |
| | | |
| | | bool openCodec(const int type, AVDictionary **options); |
| | | |
| | | bool readPacket(AVPacket &pkt_out, int stream_index = 0); |
| | | bool readPacket(std::shared_ptr<CodedData> &data, int stream_index = 0); |
| | | |
| | | int decode(AVFrame* &frame, AVPacket &pkt); |
| | | int decode(std::shared_ptr<FrameData> &frame_data, |
| | | std::shared_ptr<CodedData> &data); |
| | | |
| | | int readFrame(AVFrame* &frame); |
| | | int readFrame(std::shared_ptr<FrameData> &frame_data); |
| | | |
| | | private: |
| | | protected: |
| | | bool allocCodec(AVCodec *dec, AVStream *s, AVDictionary **options); |
| | | public: |
| | | AVStream *getStream(int type = 0); |
| | | AVStream *getStream(int type = -1); |
| | | AVCodecContext *getCodecContext(int type = 0); |
| | | private: |
| | | AVFormatContext *getFromatContext(){return ctx_;} |
| | | const double getFPS()const{return fps_;} |
| | | protected: |
| | | AVFormatContext *ctx_; |
| | | AVCodecContext *dec_ctx_; |
| | | int vs_idx_; |
| | | int as_idx_; |
| | | |
| | | bool hw_accl_; |
| | | |
| | | VideoProp *prop_; |
| | | int fps_; |
| | | private: |
| | | AVIOContext *io_ctx_; |
| | | uint8_t *read_io_buff_; |
| | | const int read_io_buff_size_; |
| | | GB28181API handle_gb28181; |
| | | }; |
| | | |
| | | class FormatInGB : public FormatIn{ |
| | | public: |
| | | FormatInGB(); |
| | | explicit FormatInGB(const VideoProp &prop); |
| | | ~FormatInGB(); |
| | | |
| | | virtual int open(const char *filename, AVDictionary **options) override; |
| | | virtual const bool IsHEVC()const override; |
| | | virtual const bool IsAVC1()const override; |
| | | virtual int readPacket(AVPacket *pkt_out) override; |
| | | |
| | | virtual bool isVideoPkt(AVPacket *pkt) override; |
| | | virtual bool isAudioPkt(AVPacket *pkt) override; |
| | | |
| | | private: |
| | | GB28181API* gb28181_; |
| | | AVCodecParserContext* parser_ctx_; |
| | | unsigned char* buffer_; |
| | | int buffer_size_; |
| | | |
| | | std::deque<AVPacket*> q_pkt_; |
| | | }; |
| | | } |
| | | |