FFRecoderTaskManager.h
1.5 KB
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
#include "FFRecoder.h"
#include "FFRecoder2.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;
};
typedef std::function<bool(const char *msg)> mq_callback_t;
class FFRecoderTaskManager {
public:
FFRecoderTaskManager();
virtual ~FFRecoderTaskManager();
void cache_pkt(AVPacket* pkt, long long frame_nb);
bool init(AVStream* stream, AVCodecContext* avctx);
bool init2(int w, int h, int fps, int bit_rate);
void create_recode_task(RecoderInfo& recoderInfo);
void close();
void set_mq_callback(mq_callback_t cb);
public:
void recode_thread();
void recode_thread2();
private:
void save_intask_recoderinfo(RecoderInfo info);
list<DataPacket*>::iterator getStartIterator(unsigned long long frame_nb);
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;
std::list<RecoderInfo> m_recoderinfo_list;
mutex m_recoderinfo_list_mtx;
bool m_bExit{false};
AVRational m_time_base;
AVCodecContext* m_avctx;
AVStream* m_inStream;
thread* m_recoder_thread{nullptr};
mq_callback_t mq_publish_func;
// FFRecoder2
int m_width;
int m_height;
int m_fps;
int m_bit_rate;
};