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.

116 lines
5.3 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. uint64_t getRemoteReferenceID(){ return m_nRemoteRefID; };
  39. };
  40. typedef struct S_VTR_HELPER{
  41. mojoVideoTransferHelper * ptr;
  42. uint8_t state;
  43. uint32_t ts;
  44. }VTR_HELPER;
  45. typedef std::vector <VTR_HELPER *> V_VIDEO_TRANSFER_HELPERS;
  46. typedef std::queue <mojoVideoTransferHelper *> Q_VIDEO_TRANSFER_HELPERS;
  47. class mojoRemoteClient: public basicThread, public protocolParser{
  48. private:
  49. basicLogCollection * m_pLog;
  50. mojoKernel * m_pMaster;
  51. ARGUS_DATA_MOJO_INFO m_sINFO;
  52. bool m_bUseBackupServer;
  53. uint8_t m_bActiveServer;
  54. uint8_t m_bCloseCommunicationReason;
  55. clientPort * m_pPort;
  56. basicMutex m_mQueryProtector;
  57. basicMutex m_mAutomationStageProtector;
  58. basicMutex m_mAutomationFreezer;
  59. RPC_CMD_QUEUE * m_qCMD;
  60. basicMutex m_mCurrentCMDProtector;
  61. RPC_CMD_RECORD * m_pCurrentCMD;
  62. basicMutex m_mCurrentVTRProtector;
  63. V_VIDEO_TRANSFER_HELPERS m_vVTRHelpers;
  64. //mojoVideoTransferHelper * m_pVideoHelper;
  65. uint32_t m_nQueryMessage;
  66. uint32_t m_nInbondSerial;
  67. uint32_t m_nOutbondSerial;
  68. uint8_t m_bAutomationStage;
  69. uint8_t m_bTOCounter;
  70. bool m_bShutdownCommunication;
  71. bool m_bCommunicationEstablished;
  72. bool m_bRegisteredWithRemotePeer;
  73. bool peer_send_rpc_pack( RPC_CMD_RECORD *ptr);
  74. void enqueueInfoMsg();
  75. void enqueueStatMsg();
  76. void enqueueTimeReq();
  77. void enqueueDisconnect( uint8_t reason = 0 );
  78. uint8_t getAutomationStage( );
  79. void setAutomationStage( uint8_t stg );
  80. bool validateTransaction();
  81. bool pushNewTransaction( RPC_CMD_RECORD *ptr );
  82. bool fetchNewTransaction();
  83. void finishTransaction();
  84. void flushTransactions();
  85. basicMutex m_mTOProtoctor;
  86. void setTO( uint8_t seconds );
  87. bool decTO();
  88. VTR_HELPER * getHelperByDBID( uint64_t dbid );
  89. protected:
  90. virtual int packetChecker( U8 *Buffer, size_t BufferSize);
  91. virtual protocolPackage * packetExtractor( U8 *Buffer, size_t BufferSize);
  92. virtual bool packetHandler( protocolPackage *Package );
  93. virtual void m_fThreadProc( void );
  94. public:
  95. explicit mojoRemoteClient( mojoKernel *ptr );
  96. ~mojoRemoteClient();
  97. virtual bool create();
  98. //bool createVideoTransferTask( ARGUS_DATA_VIDEO_SEGMENT *ptr );
  99. bool validate();
  100. bool addEvent( EVENT_CONTAINER *ptr );
  101. bool addVideo( VIDEO_SEGMENT_INFO *ptr );
  102. };
  103. #endif