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.

99 lines
4.4 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
​
​
  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. char m_cCurrentFile[MAX_PATH];
  19. bool m_bVideoExists;
  20. bool m_bVideoOpened;
  21. uint64_t m_nRemoteRefID;
  22. FILE * m_pFD;
  23. ARGUS_DATA_VIDEO_INFO m_sIn;
  24. uint32_t m_nBufferSize;
  25. uint8_t * m_pBuffer;
  26. uint64_t m_nCTSMS; // future use for Target Binding ( history filtering )
  27. public:
  28. explicit mojoVideoTransferHelper( uint32_t buffer_size = ARGUS_RPC_DEFAULT_MEDIA_CHUNK );
  29. ~mojoVideoTransferHelper();
  30. bool init( VIDEO_SEGMENT_INFO *ptr );
  31. uint8_t * getNextChunk( uint32_t req_chunk_size, uint32_t *ack_size );
  32. ARGUS_DATA_VIDEO_INFO * getVideoInfo();
  33. void clear();
  34. void abort();
  35. void registerEventID( uint32_t local, uint64_t remote );
  36. void setRemoteReferenceID( uint64_t rid ){ m_nRemoteRefID = rid; };
  37. };
  38. class mojoRemoteClient: public basicThread, public protocolParser{
  39. private:
  40. basicLogCollection * m_pLog;
  41. mojoKernel * m_pMaster;
  42. clientPort * m_pPort;
  43. basicMutex m_mQueryProtector;
  44. basicMutex m_mAutomationStageProtector;
  45. basicMutex m_mAutomationFreezer;
  46. RPC_CMD_QUEUE * m_qCMD;
  47. basicMutex m_mCurrentCMDProtector;
  48. RPC_CMD_RECORD * m_pCurrentCMD;
  49. mojoVideoTransferHelper * m_pVideoHelper;
  50. uint32_t m_nQueryMessage;
  51. uint32_t m_nInbondSerial;
  52. uint32_t m_nOutbondSerial;
  53. uint8_t m_bAutomationStage;
  54. uint8_t m_bTOCounter;
  55. bool m_bShutdownCommunication;
  56. bool m_bCommunicationEstablished;
  57. bool m_bRegisteredWithRemotePeer;
  58. bool peer_send_rpc_pack( RPC_CMD_RECORD *ptr);
  59. void enqueueInfoMsg();
  60. void enqueueStatMsg();
  61. void enqueueTimeReq();
  62. uint8_t getAutomationStage( );
  63. void setAutomationStage( uint8_t stg );
  64. bool validateTransaction();
  65. bool pushNewTransaction( RPC_CMD_RECORD *ptr );
  66. bool fetchNewTransaction();
  67. void finishTransaction();
  68. void flushTransactions();
  69. basicMutex m_mTOProtoctor;
  70. void setTO( uint8_t seconds );
  71. bool decTO();
  72. protected:
  73. virtual int packetChecker( U8 *Buffer, size_t BufferSize);
  74. virtual protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize);
  75. virtual bool packetHandler( protocolPackage *Package );
  76. virtual void m_fThreadProc( void );
  77. public:
  78. explicit mojoRemoteClient( mojoKernel *ptr );
  79. ~mojoRemoteClient();
  80. virtual bool create();
  81. //bool createVideoTransferTask( ARGUS_DATA_VIDEO_SEGMENT *ptr );
  82. bool validate();
  83. bool addEvent( EVENT_CONTAINER *ptr );
  84. bool addVideo( VIDEO_SEGMENT_INFO *ptr );
  85. };
  86. #endif