You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __KERNEL_HELPER_MEDIA_MTX_HEADER__
  2. #define __KERNEL_HELPER_MEDIA_MTX_HEADER__
  3. #ifndef LRF_PROXY_ONLY
  4. #include "dataBinder.h"
  5. #include "../../components/base/basicThread.h"
  6. #include <sys/types.h>
  7. #include <sys/stat.h>
  8. #include <unistd.h>
  9. #include <vector>
  10. #define mtx_scratch_path "/dev/shm/argus/video_scratch"
  11. typedef struct S_StreamDescRecord{
  12. uint32_t cam_id;
  13. uint64_t node_id;
  14. uint32_t stream_id;
  15. uint8_t status;
  16. bool valid;
  17. char source_uri[512];
  18. }StreamDescRecord;
  19. typedef std::vector<StreamDescRecord *> V_StreamDescRecords;
  20. #define KH_STATUS_MTX_NA 0
  21. #define KH_STATUS_MTX_INIT 1
  22. #define KH_STATUS_MTX_AOK 2
  23. #define KH_STATUS_MTX_ERR 255
  24. #define KH_MTX_STREAM_LOADDED 0
  25. #define KH_MTX_STREAM_REGISTERED 1
  26. #define KH_MTX_STREAM_ONLINE 2
  27. #define KH_MTX_STREAM_OFFLINE 3
  28. #define KH_MTX_STREAM_ERROR 255
  29. typedef struct S_StreamSegmentRecord{
  30. bool keep;
  31. VIDEO_SEGMENT_INFO SI;
  32. }StreamSegmentRecord;
  33. typedef std::map<uint64_t, StreamSegmentRecord *> M_StreamMap; // inodes -> info
  34. typedef std::map<uint64_t, M_StreamMap *> M_VideoSegmentInfo; // stream_id -> map
  35. class kernelHelperMediaMTX: public basicThread {
  36. private:
  37. basicLogCollection * m_pLog;
  38. dataBinder * m_pDBC;
  39. V_StreamDescRecords m_vStreamRecords;
  40. M_VideoSegmentInfo m_mVideoSegments;
  41. uint8_t m_bStatus;
  42. char m_sWorkDir[512];
  43. char m_sAppLogFile[512];
  44. char m_sAppConfigFile[512];
  45. char m_sRecordsBase[MAX_PATH_LEN];
  46. off_t m_nLastLogSize;
  47. bool m_bRecordMode;
  48. bool loadConfig();
  49. bool loadStreams();
  50. StreamSegmentRecord * createSSR( uint32_t stream_id, uint32_t streamTSS, uint32_t streamTMS, CSTR path );
  51. void deleteSSR( StreamSegmentRecord *ptr );
  52. void validateSSR( StreamSegmentRecord *ptr );
  53. protected:
  54. virtual void m_fThreadProc(void);
  55. public:
  56. kernelHelperMediaMTX();
  57. virtual ~kernelHelperMediaMTX();
  58. bool create();
  59. bool validateConfig();
  60. bool assignStream( uint32_t stream_id );
  61. bool updateConfig();
  62. bool restart();
  63. bool validateService();
  64. uint8_t getStatus(){ return m_bStatus; };
  65. };
  66. #endif // ! LRF_PROXY_ONLY
  67. #endif