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.

100 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. 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. clientPort * m_pPort;
  44. basicMutex m_mQueryProtector;
  45. basicMutex m_mAutomationStageProtector;
  46. basicMutex m_mAutomationFreezer;
  47. RPC_CMD_QUEUE * m_qCMD;
  48. basicMutex m_mCurrentCMDProtector;
  49. RPC_CMD_RECORD * m_pCurrentCMD;
  50. mojoVideoTransferHelper * m_pVideoHelper;
  51. uint32_t m_nQueryMessage;
  52. uint32_t m_nInbondSerial;
  53. uint32_t m_nOutbondSerial;
  54. uint8_t m_bAutomationStage;
  55. uint8_t m_bTOCounter;
  56. bool m_bShutdownCommunication;
  57. bool m_bCommunicationEstablished;
  58. bool m_bRegisteredWithRemotePeer;
  59. bool peer_send_rpc_pack( RPC_CMD_RECORD *ptr);
  60. void enqueueInfoMsg();
  61. void enqueueStatMsg();
  62. void enqueueTimeReq();
  63. uint8_t getAutomationStage( );
  64. void setAutomationStage( uint8_t stg );
  65. bool validateTransaction();
  66. bool pushNewTransaction( RPC_CMD_RECORD *ptr );
  67. bool fetchNewTransaction();
  68. void finishTransaction();
  69. void flushTransactions();
  70. basicMutex m_mTOProtoctor;
  71. void setTO( uint8_t seconds );
  72. bool decTO();
  73. protected:
  74. virtual int packetChecker( U8 *Buffer, size_t BufferSize);
  75. virtual protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize);
  76. virtual bool packetHandler( protocolPackage *Package );
  77. virtual void m_fThreadProc( void );
  78. public:
  79. explicit mojoRemoteClient( mojoKernel *ptr );
  80. ~mojoRemoteClient();
  81. virtual bool create();
  82. //bool createVideoTransferTask( ARGUS_DATA_VIDEO_SEGMENT *ptr );
  83. bool validate();
  84. bool addEvent( EVENT_CONTAINER *ptr );
  85. bool addVideo( VIDEO_SEGMENT_INFO *ptr );
  86. };
  87. #endif