video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2020-10-09 a8b447be656145c9ba2a2d8319a10ae8f726de1f
csrc/ffmpeg/format/FormatIn.hpp
@@ -13,19 +13,19 @@
struct AVFrame;
struct AVCodec;
struct AVIOContext;
struct AVBSFContext;
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);
      explicit FormatIn(const VideoProp &prop, bool hw=true);
      ~FormatIn();
      
   public:
@@ -35,35 +35,40 @@
      int open(const char *filename, AVDictionary **options);
      bool findStreamInfo(AVDictionary **options);
      bool openCodec(const int type, AVDictionary **options);
      bool openCodec(AVDictionary **options);
      
      bool readPacket(AVPacket &pkt_out, int stream_index = 0);
      bool readPacket(std::shared_ptr<CodedData> &data, int stream_index = 0);
      int readPacket(AVPacket *pkt_out);
      int decode(AVFrame* &frame, AVPacket &pkt);
      int decode(std::shared_ptr<FrameData> &frame_data,
               std::shared_ptr<CodedData> &data);
      int decode(AVFrame* frame, AVPacket *pkt);
      
      int readFrame(AVFrame* &frame);
      int readFrame(std::shared_ptr<FrameData> &frame_data);
      bool isVideoPkt(AVPacket *pkt);
      bool isAudioPkt(AVPacket *pkt);
      bool notVideoAudio(AVPacket *pkt);
   private:
      bool allocCodec(AVCodec *dec, AVStream *s, AVDictionary **options);
   public:
      AVStream *getStream(int type = 0);
      AVStream *getStream(int type = -1);
      AVCodecContext *getCodecContext(int type = 0);
      AVFormatContext *getFromatContext(){return ctx_;}
      const double getFPS()const{return fps_;}
      const bool IsHEVC()const;
      const bool isAVC1()const;
   private:
       AVFormatContext    *ctx_;
       AVCodecContext       *dec_ctx_;
       int             vs_idx_;
      int             as_idx_;
        AVBSFContext         *bsf_h264, *bsf_hevc;
      VideoProp          *prop_;
       bool             hw_accl_;
      double             fps_;
   private:
      AVIOContext         *io_ctx_;
      uint8_t          *read_io_buff_;
      const int          read_io_buff_size_;
      GB28181API         handle_gb28181;
      GB28181API         *handle_gb28181;
   };
}