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