Cleaner.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include <iostream>
  3. #include <map>
  4. #include <time.h>
  5. #include <dirent.h>
  6. #include <time.h>
  7. #include <cstdlib>
  8. #include <dirent.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <unistd.h>
  12. #include "Util/logger.h"
  13. #include "Util/NoticeCenter.h"
  14. #include "Poller/EventPoller.h"
  15. #include "Player/PlayerProxy.h"
  16. #include "Rtmp/RtmpPusher.h"
  17. #include "Common/config.h"
  18. #include "Pusher/MediaPusher.h"
  19. #include "Extension/Frame.h"
  20. #include "Util/SqlPool.h"
  21. #include "Network/TcpClient.h"
  22. #include "Poller/Timer.h"
  23. // opencv
  24. #include <opencv2/core.hpp>
  25. #include <opencv2/videoio.hpp>
  26. #include <opencv2/highgui.hpp>
  27. #include <opencv2/imgproc.hpp>
  28. #include <opencv2/imgproc/types_c.h>
  29. #include "Util/logger.h"
  30. #include <cstdlib>
  31. #include "recorder.h"
  32. using namespace toolkit;
  33. using namespace std;
  34. namespace MIVA
  35. {
  36. class Cleaner
  37. {
  38. public:
  39. using Ptr = std::shared_ptr<Cleaner>;
  40. int ClearType = 1; // 清理类型 0 - 不清除记录
  41. // 1 - 超过设定阈值就删除第一个,保持不超过阈值
  42. // 2 - 超过设定阈值,直接删除全部记录
  43. // 3 - 设定时间,如只保留前多少小时的数据
  44. int recordMax = 100;
  45. int validTime = 1; // 有效时间 时间单位 天
  46. public:
  47. Cleaner();
  48. ~Cleaner();
  49. /**
  50. * @description: 单例
  51. * @param {*}
  52. * @return {*}
  53. */
  54. static std::shared_ptr<Cleaner> CreateNew();
  55. /**
  56. * @description: 清除历史记录
  57. * @param {*}
  58. * @return {*}
  59. */
  60. int32_t ClearHistory();
  61. protected:
  62. int rmDir(std::string file_name);
  63. };
  64. } // namespace MIVA