From f93ee1a42e8c47e472332287b7350b66a6b0fa11 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 24 七月 2020 18:28:57 +0800 Subject: [PATCH] 保存触发id之后的视频作为触发视频 --- csrc/buz/recorder.hpp | 54 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 23 deletions(-) diff --git a/csrc/buz/recorder.hpp b/csrc/buz/recorder.hpp index f044907..9cb557a 100644 --- a/csrc/buz/recorder.hpp +++ b/csrc/buz/recorder.hpp @@ -13,21 +13,17 @@ #include "../common/callback.hpp" +#include "../common.hpp" + +struct AVPacket; + namespace ffwrapper{ class FormatIn; class FormatOut; - - class CodedData; } namespace cffmpeg_wrap{ namespace buz{ - // 缂撳瓨鐨勮棰戝抚,绛夊緟fire瑙﹀彂寮�濮嬪綍鍍� - typedef struct _cache_pkt{ - std::shared_ptr<ffwrapper::CodedData> data; - int64_t id; - }CPacket; - class Recorder{ public: @@ -36,8 +32,8 @@ public: int Run(const char* output, const int mind, const int maxd, const bool audio); - int PushPacket(const CPacket &pkt); - int PushPackets(std::list<CPacket> &lst); + int PushPacket(std::list<CPacket> &lst); + int StartWritePacket(std::list<CPacket> &lst, const int64_t &id, const int start, const int end); int FireRecorder(const int64_t &id); void SetCallback(FUNC_REC_INFO cb){ @@ -54,34 +50,46 @@ void end_writer(); void maybe_dump_gop(); + + int init_write_h264(const bool audio); + int write_h264(const CPacket &pkt); + int end_write_h264(); + + int init_write_hevc(const bool audio); + int write_hevc(const CPacket &pkt); + int end_write_hevc(); + int mux_hevc(FILE *fp, const char *outfile); private: ffwrapper::FormatIn *in_; ffwrapper::FormatOut *out_; - int maxduration; - int minduration; - int end_frame; - int cur_frame; - - std::list<CPacket> list_pkt_; - + std::list<CPacket> list_pkt_; std::atomic_bool stop_recorder_; std::mutex mutex_pkt_; std::condition_variable cv_; - - std::unique_ptr<std::thread> thrd_; - std::string dir_; std::string id_; - int64_t id_frame_; int id_frame_in_file_; + std::string file_path_; FUNC_REC_INFO func_rec_info_; + FILE *fp_; + bool audio_; + + std::unique_ptr<std::thread> thrd_; + + + int end_frame_; + int v_cur_frame_; + int a_cur_frame_; + + int64_t last_rec_id_; + + int maxduration; + int minduration; bool error_occured_; - - bool audio_; }; } } -- Gitblit v1.8.0