Blame view

src/decoder/dvpp/FFRecoderTaskManager.h 1.55 KB
746db74c   Hu Chunming   实现recode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #include "FFRecoder.h"
  
  #include "../../ai_platform/common_header.h"
  #include "depend_headers.h"
  
  #include <list>
  #include <queue>
  #include <map>
  #include <string>
  #include <thread>
  #include <mutex>
  
  using namespace std;
  
  struct RecodeParam {
      AVRational time_base;
      RecoderInfo recoderInfo;
      AVCodecContext* avctx;
  };
  
d9fc3e82   Hu Chunming   recode添加colse功能和mq功能
21
22
  typedef std::function<bool(const char *msg)> mq_callback_t;
  
746db74c   Hu Chunming   实现recode
23
24
25
26
27
28
  class FFRecoderTaskManager {
  public:
      FFRecoderTaskManager();
  	virtual ~FFRecoderTaskManager();
  
      void cache_pkt(AVPacket* pkt, long long frame_nb);
746db74c   Hu Chunming   实现recode
29
  
bf661eb0   Hu Chunming   录像文件保存优化
30
      bool init(AVStream* stream, AVCodecContext* avctx);
40ac568f   Hu Chunming   修改AVPacket复制方式,避免...
31
      void create_recode_task(RecoderInfo& recoderInfo);
746db74c   Hu Chunming   实现recode
32
  
d9fc3e82   Hu Chunming   recode添加colse功能和mq功能
33
34
35
36
      void close();
  
      void set_mq_callback(mq_callback_t cb);
  
746db74c   Hu Chunming   实现recode
37
  public:
40ac568f   Hu Chunming   修改AVPacket复制方式,避免...
38
      void recode_thread();
746db74c   Hu Chunming   实现recode
39
40
  
  private:
746db74c   Hu Chunming   实现recode
41
      void save_intask_recoderinfo(RecoderInfo info);
40ac568f   Hu Chunming   修改AVPacket复制方式,避免...
42
      list<DataPacket*>::iterator getStartIterator(unsigned long long frame_nb);
746db74c   Hu Chunming   实现recode
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
      
  private:
      std::queue<int> m_key_frame_interval;
      std::list<unsigned long long> m_keyframe_nb_list;
      std::list<DataPacket*> m_pkt_list;
      mutex m_pkt_list_mtx; 
      unsigned long long m_last_key_frame_nb;
  
      std::list<unsigned long long> m_intask_frame_nb_list;
  
      std::list<RecoderInfo> m_recoderinfo_list;
      mutex m_recoderinfo_list_mtx;
  
      bool m_bExit{false};
  
      map<string, thread*> m_id_recoderTask;
      mutex m_task_creat_mtx; 
  
      AVRational m_time_base;
      AVCodecContext* m_avctx;
bf661eb0   Hu Chunming   录像文件保存优化
63
      AVStream* m_inStream;
746db74c   Hu Chunming   实现recode
64
  
d9fc3e82   Hu Chunming   recode添加colse功能和mq功能
65
66
67
      thread* m_recoder_thread{nullptr};
  
      mq_callback_t mq_publish_func;
bf661eb0   Hu Chunming   录像文件保存优化
68
69
70
  
      std::list<DataFrame*> m_frame_list;
      mutex m_frame_list_mtx; 
746db74c   Hu Chunming   实现recode
71
  };