#ifndef __DEPEND_HEADERS_H__ #define __DEPEND_HEADERS_H__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * 依赖模块外部的代码或库 * 不要在此处添加模块内部的头文件 */ // 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