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.

102 lines
4.6 KiB

​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
2 years ago
​
​
​
​
​
​
2 years ago
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
2 years ago
2 years ago
​
​
  1. #ifndef __MOJO_REMOTE_CLIENT_HEADER__
  2. #define __MOJO_REMOTE_CLIENT_HEADER__
  3. #include "../../components/base/basicLogCollection.h"
  4. #include "../../components/base/basicThread.h"
  5. #include "../../data/net/clientPort.h"
  6. #include "../../data/protocol/protocol.h"
  7. #include "../../data/protocol/protocolARGUS_DATA.h"
  8. #include "../common/dataBinder.h"
  9. class mojoKernel;
  10. typedef struct S_RPC_CMD_RECORD{
  11. uint8_t CMD;
  12. size_t DATA_SIZE;
  13. void * DATA;
  14. }RPC_CMD_RECORD;
  15. typedef basicRing<RPC_CMD_RECORD> RPC_CMD_QUEUE;
  16. class mojoVideoTransferHelper{
  17. private:
  18. basicLogCollection * m_pLog;
  19. char m_cCurrentFile[MAX_PATH];
  20. bool m_bVideoExists;
  21. bool m_bVideoOpened;
  22. uint64_t m_nRemoteRefID;
  23. FILE * m_pFD;
  24. ARGUS_DATA_VIDEO_INFO m_sIn;
  25. uint32_t m_nBufferSize;
  26. uint8_t * m_pBuffer;
  27. uint64_t m_nCTSMS; // future use for Target Binding ( history filtering )
  28. public:
  29. explicit mojoVideoTransferHelper( uint32_t buffer_size = ARGUS_RPC_DEFAULT_MEDIA_CHUNK );
  30. ~mojoVideoTransferHelper();
  31. bool init( VIDEO_SEGMENT_INFO *ptr );
  32. uint8_t * getNextChunk( uint32_t req_chunk_size, uint32_t *ack_size );
  33. ARGUS_DATA_VIDEO_INFO * getVideoInfo();
  34. void clear();
  35. void abort();
  36. void registerEventID( uint32_t local, uint64_t remote );
  37. void setRemoteReferenceID( uint64_t rid ){ m_nRemoteRefID = rid; };
  38. };
  39. class mojoRemoteClient: public basicThread, public protocolParser{
  40. private:
  41. basicLogCollection * m_pLog;
  42. mojoKernel * m_pMaster;
  43. bool m_bUseBackupServer;
  44. uint8_t m_bActiveServer;
  45. clientPort * m_pPort;
  46. basicMutex m_mQueryProtector;
  47. basicMutex m_mAutomationStageProtector;
  48. basicMutex m_mAutomationFreezer;
  49. RPC_CMD_QUEUE * m_qCMD;
  50. basicMutex m_mCurrentCMDProtector;
  51. RPC_CMD_RECORD * m_pCurrentCMD;
  52. mojoVideoTransferHelper * m_pVideoHelper;
  53. uint32_t m_nQueryMessage;
  54. uint32_t m_nInbondSerial;
  55. uint32_t m_nOutbondSerial;
  56. uint8_t m_bAutomationStage;
  57. uint8_t m_bTOCounter;
  58. bool m_bShutdownCommunication;
  59. bool m_bCommunicationEstablished;
  60. bool m_bRegisteredWithRemotePeer;
  61. bool peer_send_rpc_pack( RPC_CMD_RECORD *ptr);
  62. void enqueueInfoMsg();
  63. void enqueueStatMsg();
  64. void enqueueTimeReq();
  65. uint8_t getAutomationStage( );
  66. void setAutomationStage( uint8_t stg );
  67. bool validateTransaction();
  68. bool pushNewTransaction( RPC_CMD_RECORD *ptr );
  69. bool fetchNewTransaction();
  70. void finishTransaction();
  71. void flushTransactions();
  72. basicMutex m_mTOProtoctor;
  73. void setTO( uint8_t seconds );
  74. bool decTO();
  75. protected:
  76. virtual int packetChecker( U8 *Buffer, size_t BufferSize);
  77. virtual protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize);
  78. virtual bool packetHandler( protocolPackage *Package );
  79. virtual void m_fThreadProc( void );
  80. public:
  81. explicit mojoRemoteClient( mojoKernel *ptr );
  82. ~mojoRemoteClient();
  83. virtual bool create();
  84. //bool createVideoTransferTask( ARGUS_DATA_VIDEO_SEGMENT *ptr );
  85. bool validate();
  86. bool addEvent( EVENT_CONTAINER *ptr );
  87. bool addVideo( VIDEO_SEGMENT_INFO *ptr );
  88. };
  89. #endif