mod_counterconnector.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /////////////////////////////////
  2. ///// Á¬Ïß·þÎñ
  3. /////////////////////////////////
  4. #ifndef __MOD_COUNTERCONNECTOR_H
  5. #define __MOD_COUNTERCONNECTOR_H
  6. #pragma once
  7. #include "stdafx.h"
  8. #include "SpBase.h"
  9. #include "SpIni.h"
  10. #include "ConnectorFSM.h"
  11. #include "ListEntry.h"
  12. #include "SpHelper.h"
  13. #include "Event.h"
  14. #include "CounterConnector_msg_g.h"
  15. #include "../mod_assistantchannel/chan_protocol.h"
  16. #include "../mod_livenessdetection/LivenessDetection_msg_g.h"
  17. #include "CounterConnector_server_g.h"
  18. #include "modVer.h"
  19. class CCounterConnectorEntity ;
  20. class CCounterConnectorSession : public ConnectService_ServerSessionBase
  21. {
  22. public:
  23. CCounterConnectorSession(CCounterConnectorEntity *pEntity) : m_pEntity(pEntity)
  24. {
  25. }
  26. virtual void Handle_StartCall(SpReqAnsContext<ConnectService_StartCall_Req, ConnectService_StartCall_Ans>::Pointer ctx);
  27. virtual void Handle_StartCallExternal(SpReqAnsContext<ConnectService_StartCallExternal_Req, ConnectService_StartCallExternal_Ans>::Pointer ctx);
  28. virtual void Handle_StopCall(SpReqAnsContext<ConnectService_StopCall_Req, ConnectService_StopCall_Ans>::Pointer ctx);
  29. virtual void OnClose(ErrorCodeEnum eErrorCode);
  30. private:
  31. CCounterConnectorEntity *m_pEntity;
  32. };
  33. class ChannelCounterConnectorClient : public ChannelService_ClientBase
  34. {
  35. public:
  36. ChannelCounterConnectorClient(CCounterConnectorEntity *pEntity);
  37. virtual void OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData);
  38. virtual void OnMessage(ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData);
  39. };
  40. class CCounterConnectorEntity : public CEntityBase, public ILogListener, public IBroadcastListener
  41. {
  42. public:
  43. CCounterConnectorEntity() : m_fsm() {}
  44. virtual ~CCounterConnectorEntity() {}
  45. virtual const char *GetEntityName() const { return "CounterConnector"; }
  46. const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
  47. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext);
  48. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext);
  49. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext) ;
  50. virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/);
  51. ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError);
  52. ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError);
  53. virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  54. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  55. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage);
  56. //change audio device message
  57. void OnReceivePkt(int type, int sub_type, const char *buffer, int size);
  58. //send cur audio device to agent
  59. void SendCurAudioDevice();
  60. CSimpleStringA BuildVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy);
  61. void SetCallType(CallingTypeEnum eType);
  62. CSimpleStringA BuildDoubleVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy, int remote_view_x, int remote_view_y, int remote_view_cx, int remote_view_cy);
  63. CSimpleStringA ConstructVideoParam(CSimpleStringA strMsg, bool bDoubleVideo);
  64. void Handle_StartRecord(const char* pszMessage);
  65. void Handle_StartRemoteRecord(const char* pszMessage);
  66. void StopRemoteRecordSpeakerAudioCapture();
  67. void Handle_StartRecordPreview(const char* pszMessage);
  68. virtual bool IsService()const;
  69. ACMCallFSM m_fsm;
  70. BOOL m_bIsSalesRecord;
  71. BOOL m_bIsRemoteRecord; //add by clp 20191112
  72. BOOL m_bIsRemoteRecordBroadCast; //add by clp 20200324
  73. BOOL m_bIsRemoteRecordStopSpeakerCapture; //add by clp 20200324
  74. CServerSessionBase *m_pCurrentSession;
  75. SP_BEGIN_MSG_DISPATCH_MAP(CCounterConnectorEntity)
  76. SP_BEGIN_ENTITY_MSG("LivenessDetection")
  77. #ifdef RVC_OS_WIN
  78. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStarted, OnLivenessDetectionStarted)
  79. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStopped, OnLivenessDetectionStopped)
  80. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionDone, OnActiveDetectionDone)
  81. SP_MSG_HANDLE_NS(LivenessDetection, AutoSnapshotRemind, OnAutoSnapshotRemind)
  82. SP_MSG_HANDLE_NS(LivenessDetection, LivenessDetectionHeartBeat, OnLivenessDetectionHeartBeat)
  83. SP_MSG_HANDLE_NS(LivenessDetection, DetectionStopUnExpected, OnDetectionStopUnExpected)
  84. #else
  85. case eMsg_ActiveDetectionStarted:\
  86. if (eMsgSig_ActiveDetectionStarted == dwMessageSignature) {\
  87. LivenessDetection::ActiveDetectionStarted t;\
  88. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t);\
  89. if (Error == Error_Succeed)\
  90. OnLivenessDetectionStarted(pszEntityName, dwMessageId, dwMessageSignature, t);\
  91. }\
  92. else {\
  93. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStarted");\
  94. }\
  95. break;
  96. case eMsg_ActiveDetectionStopped:\
  97. if (eMsgSig_ActiveDetectionStopped == dwMessageSignature) {\
  98. LivenessDetection::ActiveDetectionStopped t; \
  99. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  100. if (Error == Error_Succeed)\
  101. OnLivenessDetectionStopped(pszEntityName, dwMessageId, dwMessageSignature, t); \
  102. }\
  103. else {\
  104. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStopped"); \
  105. }\
  106. break;
  107. case eMsg_ActiveDetectionDone:\
  108. if (eMsgSig_ActiveDetectionDone == dwMessageSignature) {\
  109. LivenessDetection::ActiveDetectionDone t; \
  110. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  111. if (Error == Error_Succeed)\
  112. OnActiveDetectionDone(pszEntityName, dwMessageId, dwMessageSignature, t); \
  113. }\
  114. else {\
  115. LOG_TRACE("%s signature mismatched!", "ActiveDetectionDone"); \
  116. }\
  117. break;
  118. case eMsg_AutoSnapshotRemind:\
  119. if (eMsgSig_AutoSnapshotRemind == dwMessageSignature) {\
  120. LivenessDetection::AutoSnapshotRemind t; \
  121. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  122. if (Error == Error_Succeed)\
  123. OnAutoSnapshotRemind(pszEntityName, dwMessageId, dwMessageSignature, t); \
  124. }\
  125. else {\
  126. LOG_TRACE("%s signature mismatched!", "AutoSnapshotRemind"); \
  127. }\
  128. break;
  129. case eMsg_LivenessDetectionHeartBeat:\
  130. if (eMsgSig_LivenessDetectionHeartBeat == dwMessageSignature) { \
  131. LivenessDetection::LivenessDetectionHeartBeat t; \
  132. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  133. if (Error == Error_Succeed)\
  134. OnLivenessDetectionHeartBeat(pszEntityName, dwMessageId, dwMessageSignature, t); \
  135. }\
  136. else {\
  137. LOG_TRACE("%s signature mismatched!", "LivenessDetectionHeartBeat"); \
  138. }\
  139. break;
  140. case eMsg_DetectionStopUnExpected:\
  141. if (eMsgSig_DetectionStopUnExpected == dwMessageSignature) {\
  142. LivenessDetection::DetectionStopUnExpected t; \
  143. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  144. if (Error == Error_Succeed)\
  145. OnDetectionStopUnExpected(pszEntityName, dwMessageId, dwMessageSignature, t); \
  146. }\
  147. else {\
  148. LOG_TRACE("%s signature mismatched!", "DetectionStopUnExpected"); \
  149. }\
  150. break;
  151. #endif // _WIN32
  152. SP_END_ENTITY_MSG()
  153. SP_END_MSG_DISPATCH_MAP()
  154. private:
  155. void OnLivenessDetectionStarted(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStarted &evt);
  156. void OnLivenessDetectionStopped(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStopped &evt);
  157. void OnActiveDetectionDone(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionDone &evt);
  158. void OnAutoSnapshotRemind(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::AutoSnapshotRemind &evt);
  159. void OnLivenessDetectionHeartBeat(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::LivenessDetectionHeartBeat &evt);
  160. void OnDetectionStopUnExpected(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::DetectionStopUnExpected &evt);
  161. BOOL m_bIsPadType;
  162. BOOL m_IsStand2SType;
  163. ChannelCounterConnectorClient*m_pCounterConnectorChannel;
  164. CAutoArray<CUUID> m_arrListener;
  165. CUUID m_uidlivenessListener;
  166. };
  167. #endif