#include #include #include #include #include #include "CDiscHelper.h" #include "TSysThread.h" #include "CAppLife.h" #include "CTimer.h" #include "AnyCleaner.h" #define FRAME_CACHESIZE (3840*2160*16) #define GB(x) ((x.HighPart << 2) + (x.LowPart >> 20) / 1024.0) // 转换为GB单位显示 typedef struct tagRTPFILEDESC { char file_name[256]; int file_size; std::string name; char folder[256]; unsigned int start_timesec; // recording time_sec unsigned int start_timeusec; unsigned int end_timesec; unsigned int end_timeusec; unsigned int duration_sec; } RTPFILEDESC; class CAppLifeThread : public TSysThreadImpl { public: CAppLifeThread() : m_AppLife(nullptr) {} ~CAppLifeThread() { Stop(); if (m_AppLife) { delete m_AppLife; m_AppLife = nullptr; } } void PostQuit() { if (m_AppLife) m_AppLife->PostQuit(); } void Action() { m_AppLife = new CAppLife(); //注意NVS_WATCHDOG_EVENT,NVS_EXIT_EVENT需要和软件狗里的cfg文件里的值相同 #define NVS_INSTANCE_MUTEX "E3F9C076-84E6-4AF7-996A-1A0486BEBD79" #define NVS_WATCHDOG_EVENT "E3F9C076-84E6-4AF7-996A-1A0486BEBD79-heart" #define NVS_EXIT_EVENT "E3F9C076-84E6-4AF7-996A-1A0486BEBD79-quit" //"385222EF-7909-4D58-83B0-2FB8E5EA0960" if (m_AppLife->Begin((char*)NVS_INSTANCE_MUTEX, (char*)NVS_WATCHDOG_EVENT, (char*)NVS_EXIT_EVENT)) { //LOG4CXX_ERROR(app_logger, "failed to initialize life events."); return; } m_AppLife->WaitForQuit(); OutputDebugStringA("Close m_AppLife"); } private: CAppLife* m_AppLife; }; class ClearRtpFiles : public TSysThreadImpl { public: ClearRtpFiles(); ~ClearRtpFiles(); void Action(); CAppLifeThread* life_worker; int retension_day; int checktime;//最小单位min int remaining_memory;//最小单位GB字节 std::string src_path; std::string backup_path; std::vector vec_src_foldernames; std::vector vec_back_foldernames; std::vector vec_src_date_folder; std::vector vec_back_date_folder; std::list list_src_rtpfiles; std::list list_backup_rtpfiles; void Delete_file(std::string filename); BOOL SHDeleteFolder(std::string pstrFolder, BOOL bAllowUndo); int Get_Date_List(std::vector* pVecFolderName, char* folder_name); void Get_DateFiles(std::vector* vec_foldernames, const char* src_folder); int Identical_file_check(); bool LoadDeviceInfo(); void Get_Channels(const char* backup_folder, const char* src_folder); void Get_Channel(std::vector* vec_foldernames, const char* src_folder); int Get_Channel_List(std::vector* pVecFolderName, char* folder_name); void init(); // find src_folder all *.rtp within [start_time, end_time] to dst_folder with the same file structure int Get_List_File(const char* backup_folder, const char* src_folder); // int rtp_proc(RTPFILEDESC* rtp_filedesc, Buffer_t* mem_buffer, CRtpFrame* rtp_frame, FRAMEDATACALLBACK framedata_cb, void* user_data); int rtp_listfile(std::list* list_rtpfiles, const char* src_folder); int Get_Disk_Free(std::string serial); };