mod_counterconnector.h 7.9 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. private:
  40. int m_eLastState;
  41. unsigned int m_uConnectTime;
  42. };
  43. class CCounterConnectorEntity : public CEntityBase, public ILogListener, public IBroadcastListener, public ISysVarListener
  44. {
  45. public:
  46. CCounterConnectorEntity() : m_fsm() {}
  47. virtual ~CCounterConnectorEntity() {}
  48. virtual const char *GetEntityName() const { return "CounterConnector"; }
  49. const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
  50. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext);
  51. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext);
  52. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext) ;
  53. virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/);
  54. ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError);
  55. ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError);
  56. virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  57. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  58. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo);
  59. virtual void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName);
  60. //change audio device message
  61. void OnReceivePkt(int type, int sub_type, const char *buffer, int size);
  62. //send cur audio device to agent
  63. void SendCurAudioDevice();
  64. void SetCallType(CallingTypeEnum eType);
  65. void Handle_StartRecord(const char* pszMessage);
  66. void Handle_StartRemoteRecord(const char* pszMessage);
  67. void StopRemoteRecordSpeakerAudioCapture();
  68. void Handle_StartRecordPreview(const char* pszMessage);
  69. virtual bool IsService()const;
  70. ACMCallFSM m_fsm;
  71. BOOL m_bIsSalesRecord;
  72. BOOL m_bIsRemoteRecord; //add by clp 20191112
  73. BOOL m_bIsRemoteRecordStopSpeakerCapture; //add by clp 20200324
  74. BOOL m_bHasLaunched;
  75. CServerSessionBase *m_pCurrentSession;
  76. SP_BEGIN_MSG_DISPATCH_MAP(CCounterConnectorEntity)
  77. SP_BEGIN_ENTITY_MSG("LivenessDetection")
  78. #ifdef RVC_OS_WIN
  79. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStarted, OnLivenessDetectionStarted)
  80. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStopped, OnLivenessDetectionStopped)
  81. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionDone, OnActiveDetectionDone)
  82. SP_MSG_HANDLE_NS(LivenessDetection, AutoSnapshotRemind, OnAutoSnapshotRemind)
  83. SP_MSG_HANDLE_NS(LivenessDetection, LivenessDetectionHeartBeat, OnLivenessDetectionHeartBeat)
  84. SP_MSG_HANDLE_NS(LivenessDetection, DetectionStopUnExpected, OnDetectionStopUnExpected)
  85. #else
  86. case eMsg_ActiveDetectionStarted:\
  87. if (eMsgSig_ActiveDetectionStarted == dwMessageSignature) {\
  88. LivenessDetection::ActiveDetectionStarted t;\
  89. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t);\
  90. if (Error == Error_Succeed)\
  91. OnLivenessDetectionStarted(pszEntityName, dwMessageId, dwMessageSignature, t);\
  92. }\
  93. else {\
  94. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStarted");\
  95. }\
  96. break;
  97. case eMsg_ActiveDetectionStopped:\
  98. if (eMsgSig_ActiveDetectionStopped == dwMessageSignature) {\
  99. LivenessDetection::ActiveDetectionStopped t; \
  100. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  101. if (Error == Error_Succeed)\
  102. OnLivenessDetectionStopped(pszEntityName, dwMessageId, dwMessageSignature, t); \
  103. }\
  104. else {\
  105. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStopped"); \
  106. }\
  107. break;
  108. case eMsg_ActiveDetectionDone:\
  109. if (eMsgSig_ActiveDetectionDone == dwMessageSignature) {\
  110. LivenessDetection::ActiveDetectionDone t; \
  111. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  112. if (Error == Error_Succeed)\
  113. OnActiveDetectionDone(pszEntityName, dwMessageId, dwMessageSignature, t); \
  114. }\
  115. else {\
  116. LOG_TRACE("%s signature mismatched!", "ActiveDetectionDone"); \
  117. }\
  118. break;
  119. case eMsg_AutoSnapshotRemind:\
  120. if (eMsgSig_AutoSnapshotRemind == dwMessageSignature) {\
  121. LivenessDetection::AutoSnapshotRemind t; \
  122. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  123. if (Error == Error_Succeed)\
  124. OnAutoSnapshotRemind(pszEntityName, dwMessageId, dwMessageSignature, t); \
  125. }\
  126. else {\
  127. LOG_TRACE("%s signature mismatched!", "AutoSnapshotRemind"); \
  128. }\
  129. break;
  130. case eMsg_LivenessDetectionHeartBeat:\
  131. if (eMsgSig_LivenessDetectionHeartBeat == dwMessageSignature) { \
  132. LivenessDetection::LivenessDetectionHeartBeat t; \
  133. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  134. if (Error == Error_Succeed)\
  135. OnLivenessDetectionHeartBeat(pszEntityName, dwMessageId, dwMessageSignature, t); \
  136. }\
  137. else {\
  138. LOG_TRACE("%s signature mismatched!", "LivenessDetectionHeartBeat"); \
  139. }\
  140. break;
  141. case eMsg_DetectionStopUnExpected:\
  142. if (eMsgSig_DetectionStopUnExpected == dwMessageSignature) {\
  143. LivenessDetection::DetectionStopUnExpected t; \
  144. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  145. if (Error == Error_Succeed)\
  146. OnDetectionStopUnExpected(pszEntityName, dwMessageId, dwMessageSignature, t); \
  147. }\
  148. else {\
  149. LOG_TRACE("%s signature mismatched!", "DetectionStopUnExpected"); \
  150. }\
  151. break;
  152. #endif // _WIN32
  153. SP_END_ENTITY_MSG()
  154. SP_END_MSG_DISPATCH_MAP()
  155. private:
  156. void OnLivenessDetectionStarted(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStarted &evt);
  157. void OnLivenessDetectionStopped(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStopped &evt);
  158. void OnActiveDetectionDone(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionDone &evt);
  159. void OnAutoSnapshotRemind(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::AutoSnapshotRemind &evt);
  160. void OnLivenessDetectionHeartBeat(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::LivenessDetectionHeartBeat &evt);
  161. void OnDetectionStopUnExpected(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::DetectionStopUnExpected &evt);
  162. BOOL m_bIsPadType;
  163. BOOL m_IsStand2SType;
  164. ChannelCounterConnectorClient*m_pCounterConnectorChannel;
  165. CAutoArray<CUUID> m_arrListener;
  166. CUUID m_uidlivenessListener;
  167. };
  168. #endif