Blame view

src/decoder/gb28181/DvppGB28181Decoder2.h 2.21 KB
c027963f   Hu Chunming   ffmpeg6.1.1版本的接收rtp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  #ifndef _GB28181_DECODER_H_

  #define _GB28181_DECODER_H_

  

  #include <atomic>

  #include <mutex>

  

  #include "./rtp2/RTPReceiver2.h"

  #include "../dvpp/DvppRtpDecoder.h"

  

  #include "common_header.h"

  #include "../interface/AbstractDecoder.h"

  

  using namespace std;

  

  class DvppGB28181Decoder2: public AbstractDecoder

  {

  public:

  	DvppGB28181Decoder2();

  	~DvppGB28181Decoder2();

  

      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);

  

  	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<bool(const char *msg)> mq_publish);

  

  public:

      void stream_callback(uint8_t* buf, int buf_size, uint64_t pts);

  	void stream_end_callback();

      void display_thread();

      

  private:

      string m_dec_name;      // 必须为28181编码

      FFDecConfig m_cfg;

  

  	RTPReceiver2* 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<AVFrame*> mFrameQueue;

      mutex m_queue_mutex;

      mutex m_snapshot_mutex;

  

      bool m_dec_keyframe;

  

      DvppRtpDecoder rtpDecoder;

  

      int m_gpuid {0};

  };

  

  #endif // _GB28181_DECODER_H_