| | |
| | | |
| | | namespace cffmpeg_wrap{ |
| | | namespace buz{ |
| | | struct avpacket{ |
| | | // 缓存的视频帧,等待fire触发开始录像 |
| | | typedef struct _cache_pkt{ |
| | | std::shared_ptr<ffwrapper::CodedData> data; |
| | | int64_t id; |
| | | }; |
| | | }CPacket; |
| | | |
| | | |
| | | class Recorder{ |
| | | public: |
| | |
| | | |
| | | public: |
| | | int Run(const char* output, const int mind, const int maxd); |
| | | int CachePacket(const avpacket &pkt); |
| | | int PushPacket(const CPacket &pkt); |
| | | int PushPackets(std::list<CPacket> &lst); |
| | | int FireRecorder(const int64_t &id); |
| | | |
| | | void SetCallback(FUNC_REC_INFO cb){ |
| | |
| | | } |
| | | |
| | | 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 write_correctly(const CPacket &pkt); |
| | | void end_writer(); |
| | | |
| | | void maybe_dump_gop(); |
| | |
| | | int end_frame; |
| | | int cur_frame; |
| | | |
| | | std::list<avpacket> list_pkt_; |
| | | std::list<CPacket> list_pkt_; |
| | | |
| | | std::atomic_bool stop_recorder_; |
| | | std::mutex mutex_pkt_; |
| | |
| | | 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_; |
| | | |