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
29
30
|
class FFRecoderTaskManager {
public:
FFRecoderTaskManager();
virtual ~FFRecoderTaskManager();
void cache_pkt(AVPacket* pkt, long long frame_nb);
void create_recode_task(AVRational time_base, AVCodecContext* avctx, RecoderInfo& recoderInfo);
|
bf661eb0
Hu Chunming
录像文件保存优化
|
31
|
bool init(AVStream* stream, AVCodecContext* avctx);
|
746db74c
Hu Chunming
实现recode
|
32
33
|
void create_recode_task2(RecoderInfo& recoderInfo);
|
d9fc3e82
Hu Chunming
recode添加colse功能和mq功能
|
34
35
36
37
|
void close();
void set_mq_callback(mq_callback_t cb);
|
bf661eb0
Hu Chunming
录像文件保存优化
|
38
39
40
|
bool init3(AVRational time_base, AVCodecContext* avctx);
void cache_frame(AVFrame* frame, long long frame_nb);
|
746db74c
Hu Chunming
实现recode
|
41
42
43
|
public:
void recode_thread(RecodeParam param);
list<DataPacket*>::iterator getStartIterator(unsigned long long frame_nb);
|
bf661eb0
Hu Chunming
录像文件保存优化
|
44
|
list<DataPacket*>::iterator getEndIterator(unsigned long long frame_nb);
|
746db74c
Hu Chunming
实现recode
|
45
46
|
void recode_thread2();
|
bf661eb0
Hu Chunming
录像文件保存优化
|
47
48
49
50
|
void recode_thread4();
list<DataFrame*>::iterator getStartIterator3(unsigned long long frame_nb);
void recode_thread3();
|
746db74c
Hu Chunming
实现recode
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
private:
void save_intask_frame_nb(unsigned long long frame_nb);
void save_intask_recoderinfo(RecoderInfo info);
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
录像文件保存优化
|
75
|
AVStream* m_inStream;
|
746db74c
Hu Chunming
实现recode
|
76
|
|
d9fc3e82
Hu Chunming
recode添加colse功能和mq功能
|
77
78
79
|
thread* m_recoder_thread{nullptr};
mq_callback_t mq_publish_func;
|
bf661eb0
Hu Chunming
录像文件保存优化
|
80
81
82
|
std::list<DataFrame*> m_frame_list;
mutex m_frame_list_mtx;
|
746db74c
Hu Chunming
实现recode
|
83
|
};
|