Blame view

src/dvpp/FFReceiver.h 1.56 KB
63e6f7bc   Hu Chunming   完成dvpp。但是nv和gb281...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  #ifndef __FFRECEIVER_H__
  #define __FFRECEIVER_H__
  
  #include "depend_headers.h"
  #include "CircularQueue.hpp"
  
  typedef void(*RECEIVER_FINISHED_CALLBACK)(const void* userPtr);
  
  struct ReceiverConfig{
      const char* uri;
      string dec_name;
      bool force_tcp;
      CircularQueue<AVPacket*> *pktQueueptr;
      RECEIVER_FINISHED_CALLBACK receiver_finished_cbk; // 解码线程结束后的回调接口
  };
  
  class FFReceiver
  {
  public:
      FFReceiver(/* args */);
      ~FFReceiver();
  
      AVCodecContext* init_FFmpeg(ReceiverConfig config);
      void releaseFFmpeg();
      void close();
      bool start();
  
      void pause();
      void resume();
      void setDecKeyframe(bool bKeyframe);
      bool isRunning();
      bool isFinished();
      bool isPausing();
      bool getResolution( int &width, int &height );
      float fps();
  
      void setName(string nm){
          m_dec_name = nm;
      }
  
      void setFinishCbkArg(const void* userPtr);
  
  private:
      void read_thread();
  
  private:
      string m_dec_name;
  
      AVStream* stream;
      int stream_index;
      AVFormatContext *fmt_ctx;
      AVPixelFormat pix_fmt;
      int frame_width{0};
  	int frame_height{0};
  
      pthread_t m_read_thread;
      
      bool m_bRunning;
      bool m_bFinished;
  
      bool m_bPause;
  
      bool m_bReal; // 是否实时流
  
      float m_fps;
  
      FFDecConfig m_cfg;
      bool m_dec_keyframe;
  
      AVCodecContext *avctx{nullptr};
      AVBSFContext * h264bsfc{nullptr};
  
      vector<AVPacket*> m_vec_pkt;
      CircularQueue<AVPacket *> *m_pktQueueptr;
  
      const void * m_finishedReceiveArg;
      RECEIVER_FINISHED_CALLBACK receiver_finished_cbk;
  };
  
  
  #endif