gsd_MonitorPlugin.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * @Author: error: git config user.name && git config user.email & please set dead value or install git
  3. * @Date: 2022-07-10 17:23:57
  4. * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
  5. * @LastEditTime: 2022-07-10 17:35:56
  6. * @FilePath: /gsd/plugins/gsd_MonitorPlugin.h
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. /**
  10. *
  11. * gsd_MonitorPlugin.h
  12. *
  13. */
  14. #pragma once
  15. #include <drogon/plugins/Plugin.h>
  16. #include "config.hpp"
  17. #include "dataTypeList.h"
  18. #include "monitor.h"
  19. #include "gsd_TcpPlugin.h"
  20. namespace gsd
  21. {
  22. class MonitorPlugin : public drogon::Plugin<MonitorPlugin>
  23. {
  24. public:
  25. MonitorPlugin() {}
  26. /// This method must be called by drogon to initialize and start the plugin.
  27. /// It must be implemented by the user.
  28. virtual void initAndStart(const Json::Value &config) override;
  29. /// This method must be called by drogon to shutdown the plugin.
  30. /// It must be implemented by the user.
  31. virtual void shutdown() override;
  32. /**
  33. * @description: 初始化
  34. * @return {*}
  35. */
  36. int8_t Init();
  37. /**
  38. * @description: 启动任务
  39. * @return {*}
  40. */
  41. void StartTask();
  42. /**
  43. * @description: 处理数据的进程
  44. * @return {*}
  45. */
  46. void MonitorProThrd();
  47. /**
  48. * @description: 消费数据
  49. * @param {Ptr&} result
  50. * @return {*}
  51. */
  52. bool ConsumeData(FrameInferData::Ptr& result);
  53. /**
  54. * @description: 保存视频记录
  55. * @param {HistoryVideo&} historyVideo
  56. * @return {*}
  57. */
  58. bool SaveVideoRecord(HistoryVideo& historyVideo);
  59. /**
  60. * @description: 发送请求
  61. * @param {CNStreamInferData Ptr} data
  62. * @return {*}
  63. */
  64. bool sendRequest(CNStreamInferData::Ptr data);
  65. private:
  66. std::shared_ptr<Monitor> monitor = nullptr;
  67. std::shared_ptr<ThreadPool> pool = nullptr;
  68. bool stop_ = false;
  69. };
  70. }