|
|
@@ -11,7 +11,7 @@
|
|
|
#include "RtpFast.h"
|
|
|
|
|
|
|
|
|
-//#define _DEBUG1 0
|
|
|
+#define _DEBUG1 0
|
|
|
//#include "CRtpFrame.h"
|
|
|
|
|
|
void rtpcallback_timeinfo(char* frame_data, int frame_size, \
|
|
|
@@ -174,10 +174,14 @@ int rtp_proc(RTPFILEDESC* rtp_filedesc, Buffer_t* mem_buffer, CRtpFrame* rtp_fra
|
|
|
if (fatal_error) {
|
|
|
|
|
|
framedata_cb(NULL, -1, 0, 0, false, user_data);
|
|
|
- BLOG_ERROR(fmt::format("[F] {} process error: {}", rtp_filedesc->file_name, (fatal_error == -1 ? "corrupt header." : "partially flush content.")));
|
|
|
//CONSOLELOG(ERROR) << "[" << rtp_filedesc->file_name << "] process error: " << (fatal_error == -1 ? "corrupt header." : "partially flush content.");
|
|
|
-
|
|
|
- return -1;
|
|
|
+ if (rtp_filedesc->start_timesec != 0 && rtp_filedesc->end_timesec != 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BLOG_ERROR(fmt::format("[F] {} process error: {}", rtp_filedesc->file_name, (fatal_error == -1 ? "corrupt header." : "partially flush content.")));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
assert(!frame_cachesize);
|
|
|
@@ -324,29 +328,21 @@ int ClearRtpFiles::Get_Date_List(std::vector<char*>* pVecFolderName, char* folde
|
|
|
|
|
|
void ClearRtpFiles::Get_DateFiles(std::vector<char*>* vec_foldernames, const char* src_folder)
|
|
|
{
|
|
|
- //char* curr_folder = new char[256];
|
|
|
- //memset(curr_folder, 0, 256);
|
|
|
- //sprintf(curr_folder, "%s", src_folder);
|
|
|
Get_Date_List(vec_foldernames, (char*)src_folder);
|
|
|
}
|
|
|
|
|
|
void ClearRtpFiles::Get_Folder(std::vector<char*>* vec_foldernames,const char* src_folder)
|
|
|
{
|
|
|
- //char* curr_folder = new char[256];
|
|
|
- //memset(curr_folder,0,256);
|
|
|
- //sprintf(curr_folder, "%s", src_folder);
|
|
|
Get_Folder_List(vec_foldernames, (char*)src_folder);
|
|
|
}
|
|
|
|
|
|
-int ClearRtpFiles::rtp_listfile(std::list<RTPFILEDESC*>* list_rtpfiles, const char* src_folder)
|
|
|
+int ClearRtpFiles::Rtp_Listfile(std::list<RTPFILEDESC*>* list_rtpfiles, const char* src_folder)
|
|
|
{
|
|
|
std::vector<char*> vec_foldernames;
|
|
|
|
|
|
char* curr_folder = new char[256];
|
|
|
if (!curr_folder) {
|
|
|
-
|
|
|
//CONSOLELOG(ERROR) << "mem is not enough to process folder: " << src_folder;
|
|
|
-
|
|
|
return -1;
|
|
|
}
|
|
|
sprintf(curr_folder, "%s", src_folder);
|
|
|
@@ -398,7 +394,7 @@ int ClearRtpFiles::rtp_listfile(std::list<RTPFILEDESC*>* list_rtpfiles, const ch
|
|
|
}
|
|
|
memcpy(rtp_filedesc->name, data.c_str(), data.size());
|
|
|
//add file Serial number
|
|
|
- std::string tmpdata = get_filename_time(rtp_filedesc->name);
|
|
|
+ std::string tmpdata = Get_Filename_Time(rtp_filedesc->name);
|
|
|
rtp_filedesc->file_number = std::stol(tmpdata);
|
|
|
char fold[100] = "";
|
|
|
memcpy(fold, srcdata.c_str(), srcdata.find(data) - 1);
|
|
|
@@ -487,7 +483,7 @@ std::string get_Item(std::string src)
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
-std::string ClearRtpFiles::get_filename_time(std::string src)
|
|
|
+std::string ClearRtpFiles::Get_Filename_Time(std::string src)
|
|
|
{
|
|
|
std::string data = src;
|
|
|
data = data.substr(data.find("-") + 1);
|
|
|
@@ -651,6 +647,19 @@ void ClearRtpFiles::Folder_Sort(std::vector<char*>* src_folder, std::vector<char
|
|
|
}
|
|
|
(*src_folder).clear();
|
|
|
}
|
|
|
+int ClearRtpFiles::Get_MaxSize_File(std::list<RTPFILEDESC*>* list_rtpfiles)
|
|
|
+{
|
|
|
+ int max_filesize = 0;
|
|
|
+ std::list<RTPFILEDESC*>::iterator it;
|
|
|
+ it = (*list_rtpfiles).begin();
|
|
|
+ do {
|
|
|
+ if ((*list_rtpfiles).size() == 0)
|
|
|
+ break;
|
|
|
+ RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
+ max_filesize = max_filesize > rtp_filedesc->file_size ? max_filesize : rtp_filedesc->file_size;
|
|
|
+ } while (it != (*list_rtpfiles).end());
|
|
|
+ return max_filesize;
|
|
|
+}
|
|
|
void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
{
|
|
|
std::string last_day;
|
|
|
@@ -674,6 +683,12 @@ void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
for (it_char = backup_day_name.begin(); it_char != backup_day_name.end(); it_char++) {
|
|
|
//Whether the same date exists
|
|
|
std::string bak_day = get_Item(*it_char);
|
|
|
+ if (std::stoi(std::string(bak_day)) >= 20231108) {
|
|
|
+ BLOG_DEBUG(fmt::format("don't delete 11month"));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查找是否存在主目录的同一天
|
|
|
for (auto s : src_day_name) {
|
|
|
src_tmp = std::string(s);
|
|
|
get_Item_ex(src_tmp, head_, src_day);
|
|
|
@@ -697,34 +712,25 @@ void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
ishave = false;
|
|
|
|
|
|
std::list<RTPFILEDESC*> list_tmp_rtpfiles;
|
|
|
- rtp_listfile(&list_tmp_rtpfiles, *it_char);
|
|
|
+ Rtp_Listfile(&list_tmp_rtpfiles, *it_char);
|
|
|
File_Sort(&list_tmp_rtpfiles, &list_backup_rtpfiles);
|
|
|
BLOG_DEBUG(fmt::format("list_backup_rtpfiles backup_folder{}, size {}", *it_char, list_backup_rtpfiles.size()));
|
|
|
- std::list<RTPFILEDESC*>::iterator it;
|
|
|
- //for (it = list_backup_rtpfiles.begin(); it != list_backup_rtpfiles.end(); it++) {
|
|
|
- // BLOG_DEBUG(fmt::format("{}", (*it)->file_name));
|
|
|
- //}
|
|
|
+
|
|
|
//获取当天内rtp最大的文件大小
|
|
|
- int max_filesize = 0;
|
|
|
- it = list_backup_rtpfiles.begin();
|
|
|
- do {
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- max_filesize = max_filesize > rtp_filedesc->file_size ? max_filesize : rtp_filedesc->file_size;
|
|
|
- } while (it != list_backup_rtpfiles.end());
|
|
|
+ int max_filesize = Get_MaxSize_File(&list_backup_rtpfiles);
|
|
|
|
|
|
Buffer_t mem_buffer;
|
|
|
memset(&mem_buffer, 0, sizeof(mem_buffer));
|
|
|
-
|
|
|
mem_buffer.BufSize = ((max_filesize + 64 - 1) / 64) * 64;
|
|
|
mem_buffer.pData = new char[mem_buffer.BufSize + (1024 * 1024 * 30)];
|
|
|
memset(mem_buffer.pData, 0, mem_buffer.BufSize + (1024 * 1024 * 30));
|
|
|
|
|
|
+ std::list<RTPFILEDESC*>::iterator it;
|
|
|
it = list_backup_rtpfiles.begin();
|
|
|
std::list<RTPFILEDESC*>::iterator it_erase;
|
|
|
do {
|
|
|
- //char time_[256] = "";
|
|
|
- //CTimeHelper::GetCurrLocalTimeString(time_);
|
|
|
- //BLOG_DEBUG(fmt::format("local time is {}", time_));
|
|
|
+ if (list_backup_rtpfiles.size() == 0)
|
|
|
+ break;
|
|
|
it_erase = it;
|
|
|
RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
// read in time informatiion
|
|
|
@@ -737,56 +743,61 @@ void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
else {
|
|
|
//获取到rtp时间
|
|
|
//开始对比单个文件是否存在主目录内
|
|
|
- if (last_src_tmp != src_tmp) {
|
|
|
- std::list<RTPFILEDESC*>::iterator iter;
|
|
|
- for (iter = list_lastDay_rtpfiles.begin(); iter != list_lastDay_rtpfiles.end();) {
|
|
|
- delete (*iter);
|
|
|
- *iter = NULL;
|
|
|
- iter = list_lastDay_rtpfiles.erase(iter);
|
|
|
+ if (rtp_filedesc->start_timesec == rtp_filedesc->end_timesec) {
|
|
|
+ //测试出现过start_timesec和end_timesec相同的情况
|
|
|
+ BLOG_ERROR(fmt::format("Time is same,Delete fiel:{},time:{}~{}", rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+#ifdef _DEBUG1
|
|
|
+ if (std::stoi(std::string(rtp_filedesc->folder)) < 20231108)
|
|
|
+ Delete_file(rtp_filedesc->file_name);
|
|
|
+#endif
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (last_src_tmp != src_tmp) {
|
|
|
+ std::list<RTPFILEDESC*>::iterator iter;
|
|
|
+ for (iter = list_lastDay_rtpfiles.begin(); iter != list_lastDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_lastDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_lastDay_rtpfiles.clear();
|
|
|
+
|
|
|
+ for (iter = list_nextDay_rtpfiles.begin(); iter != list_nextDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_nextDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_nextDay_rtpfiles.clear();
|
|
|
+
|
|
|
+ for (iter = list_localDay_rtpfiles.begin(); iter != list_localDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_localDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_localDay_rtpfiles.clear();
|
|
|
+
|
|
|
+ Rtp_Listfile(&list_tmp_rtpfiles, last_day.c_str());
|
|
|
+ File_Sort(&list_tmp_rtpfiles, &list_lastDay_rtpfiles);
|
|
|
+
|
|
|
+ Rtp_Listfile(&list_tmp_rtpfiles, next_day.c_str());
|
|
|
+ File_Sort(&list_tmp_rtpfiles, &list_nextDay_rtpfiles);
|
|
|
+
|
|
|
+ Rtp_Listfile(&list_tmp_rtpfiles, src_tmp.c_str());
|
|
|
+ File_Sort(&list_tmp_rtpfiles, &list_localDay_rtpfiles);
|
|
|
+ BLOG_DEBUG("new list_localDay_rtpfiles");
|
|
|
}
|
|
|
- list_lastDay_rtpfiles.clear();
|
|
|
-
|
|
|
- for (iter = list_nextDay_rtpfiles.begin(); iter != list_nextDay_rtpfiles.end();) {
|
|
|
- delete (*iter);
|
|
|
- *iter = NULL;
|
|
|
- iter = list_nextDay_rtpfiles.erase(iter);
|
|
|
+ last_src_tmp = src_tmp;
|
|
|
+ bool check_last = false;
|
|
|
+ bool check_next = false;
|
|
|
+ //BLOG_DEBUG(fmt::format("bakcup:{},time:{}~{}", rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ Is_Same_Times(&list_localDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec, check_last, check_next);
|
|
|
+ if (check_last) {
|
|
|
+ BLOG_DEBUG("Is_LastSame_Times");
|
|
|
+ Is_LastSame_Times(&list_lastDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec);
|
|
|
}
|
|
|
- list_nextDay_rtpfiles.clear();
|
|
|
-
|
|
|
- for (iter = list_localDay_rtpfiles.begin(); iter != list_localDay_rtpfiles.end();) {
|
|
|
- delete (*iter);
|
|
|
- *iter = NULL;
|
|
|
- iter = list_localDay_rtpfiles.erase(iter);
|
|
|
+ else if (check_next) {
|
|
|
+ BLOG_DEBUG("Is_NextSame_Times");
|
|
|
+ Is_NextSame_Times(&list_nextDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec);
|
|
|
}
|
|
|
- list_localDay_rtpfiles.clear();
|
|
|
-
|
|
|
- rtp_listfile(&list_tmp_rtpfiles, last_day.c_str());
|
|
|
- File_Sort(&list_tmp_rtpfiles, &list_lastDay_rtpfiles);
|
|
|
-
|
|
|
- rtp_listfile(&list_tmp_rtpfiles, next_day.c_str());
|
|
|
- File_Sort(&list_tmp_rtpfiles, &list_nextDay_rtpfiles);
|
|
|
-
|
|
|
- rtp_listfile(&list_tmp_rtpfiles, src_tmp.c_str());
|
|
|
- File_Sort(&list_tmp_rtpfiles, &list_localDay_rtpfiles);
|
|
|
- //{
|
|
|
- // std::list<RTPFILEDESC*>::iterator it;
|
|
|
- // for (it = list_localDay_rtpfiles.begin(); it != list_localDay_rtpfiles.end(); it++) {
|
|
|
- // BLOG_DEBUG(fmt::format("list_localDay_rtpfiles {}", (*it)->file_name));
|
|
|
- // }
|
|
|
- //}
|
|
|
- BLOG_DEBUG("new list_localDay_rtpfiles");
|
|
|
- }
|
|
|
- last_src_tmp = src_tmp;
|
|
|
- bool check_last = false;
|
|
|
- bool check_next = false;
|
|
|
- Is_Same_Times(&list_localDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec, check_last, check_next);
|
|
|
- if (check_last) {
|
|
|
- BLOG_DEBUG("Is_LastSame_Times");
|
|
|
- Is_LastSame_Times(&list_lastDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec);
|
|
|
- }
|
|
|
- else if (check_next) {
|
|
|
- BLOG_DEBUG("Is_NextSame_Times");
|
|
|
- Is_NextSame_Times(&list_nextDay_rtpfiles, rtp_filedesc, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec);
|
|
|
}
|
|
|
}
|
|
|
memset(mem_buffer.pData, 0, mem_buffer.BufSize + (1024 * 1024 * 30));
|
|
|
@@ -794,21 +805,8 @@ void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
delete[] mem_buffer.pData;
|
|
|
mem_buffer.pData = NULL;
|
|
|
//删除备份的空目录
|
|
|
- std::wstring stemp = s2ws(*it_char);
|
|
|
- LPCWSTR result = stemp.c_str();
|
|
|
- BOOL ret = PathIsDirectoryEmpty(result);
|
|
|
- if (ret) {
|
|
|
- BLOG_DEBUG(fmt::format("Delete BACKUP Folder {}", *it_char));
|
|
|
-#ifdef _DEBUG1
|
|
|
- SHDeleteFolder(bak, false);
|
|
|
-#endif
|
|
|
- }
|
|
|
- for (it = list_backup_rtpfiles.begin(); it != list_backup_rtpfiles.end();) {
|
|
|
- delete (*it);
|
|
|
- *it = NULL;
|
|
|
- it = list_backup_rtpfiles.erase(it);
|
|
|
- }
|
|
|
- list_backup_rtpfiles.clear();
|
|
|
+ Clear_EmptyDirectory(it_char);
|
|
|
+ Free_Rtpfiles();
|
|
|
}
|
|
|
for (it_char = src_day_name.begin(); it_char != src_day_name.end();) {
|
|
|
delete[](*it_char);
|
|
|
@@ -823,6 +821,51 @@ void ClearRtpFiles::Check_Channels(std::string src, std::string backup)
|
|
|
}
|
|
|
backup_day_name.clear();
|
|
|
}
|
|
|
+void ClearRtpFiles::Free_Rtpfiles()
|
|
|
+{
|
|
|
+ std::list<RTPFILEDESC*>::iterator it;
|
|
|
+ it = list_backup_rtpfiles.begin();
|
|
|
+ for (it = list_backup_rtpfiles.begin(); it != list_backup_rtpfiles.end();) {
|
|
|
+ delete (*it);
|
|
|
+ *it = NULL;
|
|
|
+ it = list_backup_rtpfiles.erase(it);
|
|
|
+ }
|
|
|
+ list_backup_rtpfiles.clear();
|
|
|
+
|
|
|
+ std::list<RTPFILEDESC*>::iterator iter;
|
|
|
+ for (iter = list_lastDay_rtpfiles.begin(); iter != list_lastDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_lastDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_lastDay_rtpfiles.clear();
|
|
|
+
|
|
|
+ for (iter = list_nextDay_rtpfiles.begin(); iter != list_nextDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_nextDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_nextDay_rtpfiles.clear();
|
|
|
+
|
|
|
+ for (iter = list_localDay_rtpfiles.begin(); iter != list_localDay_rtpfiles.end();) {
|
|
|
+ delete (*iter);
|
|
|
+ *iter = NULL;
|
|
|
+ iter = list_localDay_rtpfiles.erase(iter);
|
|
|
+ }
|
|
|
+ list_localDay_rtpfiles.clear();
|
|
|
+}
|
|
|
+void ClearRtpFiles::Clear_EmptyDirectory(std::vector<char*>::iterator it_char)
|
|
|
+{
|
|
|
+ std::wstring stemp = s2ws(*it_char);
|
|
|
+ LPCWSTR result = stemp.c_str();
|
|
|
+ BOOL ret = PathIsDirectoryEmpty(result);
|
|
|
+ if (ret) {
|
|
|
+ BLOG_DEBUG(fmt::format("Delete BACKUP Folder {}", *it_char));
|
|
|
+#ifdef _DEBUG1
|
|
|
+ SHDeleteFolder(*it_char, false);
|
|
|
+#endif
|
|
|
+ }
|
|
|
+}
|
|
|
void ClearRtpFiles::Get_Channels(const char* backup_folder, const char* src_folder)
|
|
|
{
|
|
|
Get_Folder(&vec_src_foldernames, src_folder);
|
|
|
@@ -849,6 +892,7 @@ void ClearRtpFiles::Get_Channels(const char* backup_folder, const char* src_fold
|
|
|
}
|
|
|
}
|
|
|
//剩余空间小于要求值,删除主存储
|
|
|
+ std::vector<char*> src_daytmp_name;
|
|
|
std::string serial = std::string(vec_src_foldernames.front());
|
|
|
serial = serial.substr(0, serial.find("\\"));
|
|
|
int gb_data = Get_Disk_Free(serial);
|
|
|
@@ -857,7 +901,8 @@ void ClearRtpFiles::Get_Channels(const char* backup_folder, const char* src_fold
|
|
|
int i = 0;
|
|
|
if (remaining_memory >= gb_data) {
|
|
|
for (auto s : vec_src_foldernames) {
|
|
|
- Get_DateFiles(&vec_src_date_folder, s);
|
|
|
+ Get_DateFiles(&src_daytmp_name, s);
|
|
|
+ Folder_Sort(&src_daytmp_name, &vec_src_date_folder);
|
|
|
if (vec_src_date_folder.size() >= retension_day) {
|
|
|
index = vec_src_date_folder.size() - retension_day;
|
|
|
for (auto d : vec_src_date_folder) {
|
|
|
@@ -865,7 +910,7 @@ void ClearRtpFiles::Get_Channels(const char* backup_folder, const char* src_fold
|
|
|
break;
|
|
|
BLOG_DEBUG(fmt::format("Delete SRC Folder {}", d));
|
|
|
#ifdef _DEBUG1
|
|
|
- SHDeleteFolder(d, false);
|
|
|
+ //SHDeleteFolder(d, false);
|
|
|
#endif
|
|
|
i++;
|
|
|
}
|
|
|
@@ -933,27 +978,31 @@ void ClearRtpFiles::Is_NextSame_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RT
|
|
|
//continue;
|
|
|
}
|
|
|
else {
|
|
|
+ int day_ = std::stoi(std::string(paramer->folder));
|
|
|
if (starttime >= rtp_filedesc->start_timesec && endtime <= rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
else if (starttime < rtp_filedesc->start_timesec && endtime > rtp_filedesc->start_timesec && endtime < rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
else if (starttime >= rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
@@ -1015,26 +1064,29 @@ void ClearRtpFiles::Is_LastSame_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RT
|
|
|
}
|
|
|
else {
|
|
|
if (starttime <= rtp_filedesc->end_timesec && endtime >= rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
else if (starttime >= rtp_filedesc->start_timesec && starttime <= rtp_filedesc->end_timesec && endtime > rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
else if (endtime <= rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_LastSame_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
@@ -1079,6 +1131,7 @@ void ClearRtpFiles::Is_Same_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RTPFIL
|
|
|
bool last_flag = false;
|
|
|
bool next_flag = false;
|
|
|
bool isbreak = false;
|
|
|
+ bool is_first_file = true;
|
|
|
do {
|
|
|
it_erase = it;
|
|
|
RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
@@ -1090,21 +1143,23 @@ void ClearRtpFiles::Is_Same_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RTPFIL
|
|
|
(*list_rtpfiles).erase(it_erase);
|
|
|
}
|
|
|
else {
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times src:{},time:{}~{}", rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ int day_ = std::stoi(std::string(paramer->folder));
|
|
|
//Home directory contains all have
|
|
|
if (!flag && starttime >= rtp_filedesc->start_timesec && endtime <= rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec,rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
//right intersect
|
|
|
else if (!flag && starttime >= rtp_filedesc->start_timesec && starttime <= rtp_filedesc->end_timesec && endtime > rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
@@ -1115,31 +1170,28 @@ void ClearRtpFiles::Is_Same_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RTPFIL
|
|
|
next_flag = true;
|
|
|
}
|
|
|
}
|
|
|
-// else if (flag && !last_flag && endtime <= rtp_filedesc->end_timesec) {
|
|
|
-// BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
-// paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
-//#ifdef _DEBUG1
|
|
|
-// Delete_file(paramer->file_name);
|
|
|
-//#endif
|
|
|
-// flag = false;
|
|
|
-// next_flag = false;
|
|
|
-// isbreak = true;
|
|
|
-// }
|
|
|
//left intersect
|
|
|
else if (!flag && starttime < rtp_filedesc->start_timesec && endtime >= rtp_filedesc->start_timesec && endtime < rtp_filedesc->end_timesec) {
|
|
|
- BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
- paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
+ //BLOG_DEBUG(fmt::format("Is_Same_Times Delete_file {},time:{}~{},src:{},time:{}~{}", paramer->file_name, paramer->start_timesec,
|
|
|
+ // paramer->end_timesec, rtp_filedesc->file_name, rtp_filedesc->start_timesec, rtp_filedesc->end_timesec));
|
|
|
#ifdef _DEBUG1
|
|
|
- Delete_file(paramer->file_name);
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
#endif
|
|
|
isbreak = true;
|
|
|
}
|
|
|
//left需要检查上一天末尾几个的rtp文件时间
|
|
|
- else if (!flag && endtime < rtp_filedesc->start_timesec) {
|
|
|
+ else if (!flag && endtime < rtp_filedesc->start_timesec && is_first_file) {
|
|
|
flag = true;
|
|
|
last_flag = true;
|
|
|
}
|
|
|
-
|
|
|
+ else if (!flag && endtime < rtp_filedesc->start_timesec && !is_first_file) {
|
|
|
+#ifdef _DEBUG1
|
|
|
+ if (std::stoi(std::string(paramer->folder)) < 20231108)
|
|
|
+ Delete_file(paramer->file_name);
|
|
|
+#endif
|
|
|
+ isbreak = true;
|
|
|
+ }
|
|
|
if (isbreak) {
|
|
|
delete (*it_erase);
|
|
|
*it_erase = NULL;
|
|
|
@@ -1147,6 +1199,7 @@ void ClearRtpFiles::Is_Same_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RTPFIL
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ is_first_file = false;
|
|
|
memset(mem_buffer.pData, 0, mem_buffer.BufSize + (1024 * 1024 * 30));
|
|
|
if (last_flag)
|
|
|
break;
|
|
|
@@ -1160,107 +1213,6 @@ void ClearRtpFiles::Is_Same_Times(std::list<RTPFILEDESC*>* list_rtpfiles, RTPFIL
|
|
|
check_next = next_flag;
|
|
|
}
|
|
|
|
|
|
-void ClearRtpFiles::Get_Rtp_Times(std::list<RTPFILEDESC*>* list_rtpfiles, TIME_SPAN& time_span)
|
|
|
-{
|
|
|
-#if 1
|
|
|
- //获取所有文件大小里的最大值
|
|
|
- int max_filesize = 0;
|
|
|
- std::list<RTPFILEDESC*>::iterator it = (*list_rtpfiles).begin();
|
|
|
- do {
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- max_filesize = max_filesize > rtp_filedesc->file_size ? max_filesize : rtp_filedesc->file_size;
|
|
|
- } while (it != (*list_rtpfiles).end());
|
|
|
-
|
|
|
- //文件时间信息
|
|
|
- Buffer_t mem_buffer;
|
|
|
- memset(&mem_buffer, 0, sizeof(mem_buffer));
|
|
|
-
|
|
|
- mem_buffer.BufSize = ((max_filesize + 64 - 1) / 64) * 64;
|
|
|
- //mem_buffer.pData = new char[mem_buffer.BufSize + FRAME_CACHESIZE];
|
|
|
-
|
|
|
- it = (*list_rtpfiles).begin();
|
|
|
- std::list<RTPFILEDESC*>::iterator it_erase;
|
|
|
- unsigned int max_times = 0;
|
|
|
- unsigned int min_times = 0;
|
|
|
- do {
|
|
|
- /*mem_buffer.pData = new char[max_filesize + 1024*1024*50];*/
|
|
|
- mem_buffer.pData = new char[mem_buffer.BufSize + (1024 * 1024 * 30)];
|
|
|
- it_erase = it;
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- // read in time informatiion
|
|
|
- if (rtp_proc(rtp_filedesc, &mem_buffer, NULL, rtpcallback_timeinfo, rtp_filedesc)) {
|
|
|
- if (rtp_filedesc != (*list_rtpfiles).back())
|
|
|
- BLOG_ERROR(fmt::format("[F] {} is corrupt. ... skip the file ...", rtp_filedesc->file_name));
|
|
|
-
|
|
|
- delete (*it_erase);
|
|
|
- *it_erase = NULL;
|
|
|
- (*list_rtpfiles).erase(it_erase);
|
|
|
- continue;
|
|
|
- }
|
|
|
- max_times = max_times > rtp_filedesc->end_timesec ? max_times : rtp_filedesc->end_timesec;
|
|
|
- if (min_times == 0) {
|
|
|
- min_times = rtp_filedesc->start_timesec;
|
|
|
- }
|
|
|
- else {
|
|
|
- min_times = min_times < rtp_filedesc->start_timesec ? min_times : rtp_filedesc->start_timesec;
|
|
|
- }
|
|
|
- delete[] mem_buffer.pData;
|
|
|
- mem_buffer.pData = NULL;
|
|
|
- } while (it != (*list_rtpfiles).end());
|
|
|
- //获取时间跨度
|
|
|
- time_span.start_timesec = min_times;
|
|
|
- time_span.end_timesec = max_times;
|
|
|
-#else
|
|
|
- //获取所有文件大小里的最大值
|
|
|
- int max_filesize = 0;
|
|
|
- std::list<RTPFILEDESC*>::iterator it = (*list_rtpfiles).begin();
|
|
|
- do {
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- max_filesize = max_filesize > rtp_filedesc->file_size ? max_filesize : rtp_filedesc->file_size;
|
|
|
- } while (it != (*list_rtpfiles).end());
|
|
|
-
|
|
|
- //文件时间信息
|
|
|
- Buffer_t mem_buffer;
|
|
|
- memset(&mem_buffer, 0, sizeof(mem_buffer));
|
|
|
-
|
|
|
- mem_buffer.BufSize = ((max_filesize + 64 - 1) / 64) * 64;
|
|
|
- //mem_buffer.pData = new char[mem_buffer.BufSize + FRAME_CACHESIZE];
|
|
|
-
|
|
|
- it = (*list_rtpfiles).begin();
|
|
|
- std::list<RTPFILEDESC*>::iterator it_erase;
|
|
|
- do {
|
|
|
- /*mem_buffer.pData = new char[max_filesize + 1024*1024*50];*/
|
|
|
- mem_buffer.pData = new char[mem_buffer.BufSize + (1024 * 1024* 30)];
|
|
|
- it_erase = it;
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- // read in time informatiion
|
|
|
- if (rtp_proc(rtp_filedesc, &mem_buffer, NULL, rtpcallback_timeinfo, rtp_filedesc)) {
|
|
|
- if (rtp_filedesc != (*list_rtpfiles).back())
|
|
|
- BLOG_ERROR(fmt::format("[F] {} is corrupt. ... skip the file ...", rtp_filedesc->file_name));
|
|
|
-
|
|
|
- delete (*it_erase);
|
|
|
- *it_erase = NULL;
|
|
|
- (*list_rtpfiles).erase(it_erase);
|
|
|
- continue;
|
|
|
- }
|
|
|
- delete[] mem_buffer.pData;
|
|
|
- mem_buffer.pData = NULL;
|
|
|
- } while (it != (*list_rtpfiles).end());
|
|
|
-
|
|
|
- //获取时间跨度
|
|
|
- it = (*list_rtpfiles).begin();
|
|
|
- unsigned int max_times = 0;
|
|
|
- unsigned int min_times = (*it)->start_timesec;
|
|
|
- do {
|
|
|
- RTPFILEDESC* rtp_filedesc = *it++;
|
|
|
- max_times = max_times > rtp_filedesc->end_timesec ? max_times : rtp_filedesc->end_timesec;
|
|
|
- min_times = min_times < rtp_filedesc->start_timesec ? min_times : rtp_filedesc->start_timesec;
|
|
|
- } while (it != (*list_rtpfiles).end());
|
|
|
- time_span.start_timesec = min_times;
|
|
|
- time_span.end_timesec = max_times;
|
|
|
-#endif
|
|
|
-}
|
|
|
-
|
|
|
int ClearRtpFiles::Get_Disk_Free(std::string serial)
|
|
|
{
|
|
|
int pSize = MultiByteToWideChar(CP_OEMCP, 0, serial.c_str(), serial.size() + 1, NULL, 0);
|
|
|
@@ -1292,8 +1244,6 @@ void ClearRtpFiles::Action()
|
|
|
{
|
|
|
while (!IsAborted()) {
|
|
|
Get_Channels(backup_path.c_str(), src_path.c_str());
|
|
|
- /*Get_List_File(backup_path.c_str(), src_path.c_str());*/
|
|
|
- /*Identical_file_check();*/
|
|
|
std::this_thread::sleep_for(std::chrono::minutes(checktime));
|
|
|
}
|
|
|
}
|