| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #include <iostream>
- #include <string>
- #include <thread>
- #include <vector>
- #include <list>
- #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<char*> vec_src_foldernames;
- std::vector<char*> vec_back_foldernames;
- std::vector<char*> vec_src_date_folder;
- std::vector<char*> vec_back_date_folder;
- std::list<RTPFILEDESC*> list_src_rtpfiles;
- std::list<RTPFILEDESC*> list_backup_rtpfiles;
- void Delete_file(std::string filename);
- BOOL SHDeleteFolder(std::string pstrFolder, BOOL bAllowUndo);
- int Get_Date_List(std::vector<char*>* pVecFolderName, char* folder_name);
- void Get_DateFiles(std::vector<char*>* 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<char*>* vec_foldernames, const char* src_folder);
- int Get_Channel_List(std::vector<char*>* 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<RTPFILEDESC*>* list_rtpfiles, const char* src_folder);
- int Get_Disk_Free(std::string serial);
- };
|