depend_headers.h
1.83 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
72
73
74
75
76
77
78
79
80
81
82
#ifndef __DEPEND_HEADERS_H__
#define __DEPEND_HEADERS_H__
#include <iostream>
#include <utility>
#include <chrono>
#include <thread>
#include <functional>
#include <atomic>
#include <fstream>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <set>
#include <mutex>
#include <vector>
#include <condition_variable>
/*
* 依赖模块外部的代码或库
* 不要在此处添加模块内部的头文件
*/
// ffmpeg 是c库 所以编译的时候要加入从 extern导入的C 来声明否则连接失败
extern "C" {
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavutil/opt.h"
#include "libavutil/timestamp.h"
#include "libswscale/swscale.h"
}
#include "../interface/logger.hpp"
#include "../interface/DeviceMemory.hpp"
#include "../interface/interface_headers.h"
#include "../interface/utiltools.hpp"
struct DataPacket {
uint8_t *pkt_data{nullptr};
int pkt_size{0};
unsigned long long frame_nb{0};
bool isKeyFrame{false};
DataPacket(uint8_t *data, int size, unsigned long long frameNb, bool isKey) {
pkt_data = (uint8_t*) malloc(size);
memcpy(pkt_data, data, size);
pkt_size = size;
frame_nb = frameNb;
isKeyFrame = isKey;
}
~DataPacket(){
if(pkt_data != nullptr) {
// LOG_INFO("free frame_nb:{}", frame_nb);
free(pkt_data);
pkt_data = nullptr;
}
pkt_size = 0;
frame_nb = 0;
isKeyFrame = false;
}
};
struct DataFrame {
AVFrame* frame {nullptr};
unsigned long long frame_nb{0};
bool isKeyFrame{false};
~DataFrame(){
if(frame != nullptr) {
av_frame_free(&frame);
frame = nullptr;
}
}
};
#endif