From 6de0bbb3eb860934bbe1c5e53a7ff02b8c0844f5 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期六, 19 十月 2019 10:44:37 +0800 Subject: [PATCH] udpate --- csrc/buz/recorder.hpp | 39 ++++++++++++++++++++++++++------------- 1 files changed, 26 insertions(+), 13 deletions(-) diff --git a/csrc/buz/recorder.hpp b/csrc/buz/recorder.hpp index ba9cea4..9c88bbb 100644 --- a/csrc/buz/recorder.hpp +++ b/csrc/buz/recorder.hpp @@ -13,19 +13,17 @@ #include "../common/callback.hpp" +#include "../common.hpp" + +struct AVPacket; + namespace ffwrapper{ class FormatIn; class FormatOut; - - class CodedData; } namespace cffmpeg_wrap{ namespace buz{ - struct avpacket{ - std::shared_ptr<ffwrapper::CodedData> data; - int64_t id; - }; class Recorder{ public: @@ -33,8 +31,9 @@ ~Recorder(); public: - int Run(const char* output, const int mind, const int maxd); - int CachePacket(const avpacket &pkt); + 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 FireRecorder(const int64_t &id); void SetCallback(FUNC_REC_INFO cb){ @@ -42,15 +41,24 @@ } const bool ErrorOcurred(){return error_occured_;} + const std::string& RecID()const{return id_;} private: void run_thread(); - int init_writer(); - void start_writer(); - int write_correctly(const avpacket &pkt); + int init_writer(const bool audio); + int write_correctly(const CPacket &pkt); 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_; @@ -59,8 +67,9 @@ int minduration; int end_frame; int cur_frame; + int cur_frame_a; - std::list<avpacket> list_pkt_; + std::list<CPacket> list_pkt_; std::atomic_bool stop_recorder_; std::mutex mutex_pkt_; @@ -72,11 +81,15 @@ std::string id_; int64_t id_frame_; - int file_frame_index_; + int id_frame_in_file_; std::string file_path_; FUNC_REC_INFO func_rec_info_; bool error_occured_; + + bool audio_; + + FILE *fp_; }; } } -- Gitblit v1.8.0