mod_counterconnector.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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
  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);
  59. //change audio device message
  60. void OnReceivePkt(int type, int sub_type, const char *buffer, int size);
  61. //send cur audio device to agent
  62. void SendCurAudioDevice();
  63. CSimpleStringA BuildVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy);
  64. void SetCallType(CallingTypeEnum eType);
  65. 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);
  66. CSimpleStringA ConstructVideoParam(CSimpleStringA strMsg, bool bDoubleVideo);
  67. void Handle_StartRecord(const char* pszMessage);
  68. void Handle_StartRemoteRecord(const char* pszMessage);
  69. void StopRemoteRecordSpeakerAudioCapture();
  70. void Handle_StartRecordPreview(const char* pszMessage);
  71. virtual bool IsService()const;
  72. ACMCallFSM m_fsm;
  73. BOOL m_bIsSalesRecord;
  74. BOOL m_bIsRemoteRecord; //add by clp 20191112
  75. BOOL m_bIsRemoteRecordBroadCast; //add by clp 20200324
  76. BOOL m_bIsRemoteRecordStopSpeakerCapture; //add by clp 20200324
  77. CServerSessionBase *m_pCurrentSession;
  78. SP_BEGIN_MSG_DISPATCH_MAP(CCounterConnectorEntity)
  79. SP_BEGIN_ENTITY_MSG("LivenessDetection")
  80. #ifdef RVC_OS_WIN
  81. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStarted, OnLivenessDetectionStarted)
  82. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStopped, OnLivenessDetectionStopped)
  83. SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionDone, OnActiveDetectionDone)
  84. SP_MSG_HANDLE_NS(LivenessDetection, AutoSnapshotRemind, OnAutoSnapshotRemind)
  85. SP_MSG_HANDLE_NS(LivenessDetection, LivenessDetectionHeartBeat, OnLivenessDetectionHeartBeat)
  86. SP_MSG_HANDLE_NS(LivenessDetection, DetectionStopUnExpected, OnDetectionStopUnExpected)
  87. #else
  88. case eMsg_ActiveDetectionStarted:\
  89. if (eMsgSig_ActiveDetectionStarted == dwMessageSignature) {\
  90. LivenessDetection::ActiveDetectionStarted t;\
  91. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t);\
  92. if (Error == Error_Succeed)\
  93. OnLivenessDetectionStarted(pszEntityName, dwMessageId, dwMessageSignature, t);\
  94. }\
  95. else {\
  96. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStarted");\
  97. }\
  98. break;
  99. case eMsg_ActiveDetectionStopped:\
  100. if (eMsgSig_ActiveDetectionStopped == dwMessageSignature) {\
  101. LivenessDetection::ActiveDetectionStopped t; \
  102. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  103. if (Error == Error_Succeed)\
  104. OnLivenessDetectionStopped(pszEntityName, dwMessageId, dwMessageSignature, t); \
  105. }\
  106. else {\
  107. LOG_TRACE("%s signature mismatched!", "ActiveDetectionStopped"); \
  108. }\
  109. break;
  110. case eMsg_ActiveDetectionDone:\
  111. if (eMsgSig_ActiveDetectionDone == dwMessageSignature) {\
  112. LivenessDetection::ActiveDetectionDone t; \
  113. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  114. if (Error == Error_Succeed)\
  115. OnActiveDetectionDone(pszEntityName, dwMessageId, dwMessageSignature, t); \
  116. }\
  117. else {\
  118. LOG_TRACE("%s signature mismatched!", "ActiveDetectionDone"); \
  119. }\
  120. break;
  121. case eMsg_AutoSnapshotRemind:\
  122. if (eMsgSig_AutoSnapshotRemind == dwMessageSignature) {\
  123. LivenessDetection::AutoSnapshotRemind t; \
  124. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  125. if (Error == Error_Succeed)\
  126. OnAutoSnapshotRemind(pszEntityName, dwMessageId, dwMessageSignature, t); \
  127. }\
  128. else {\
  129. LOG_TRACE("%s signature mismatched!", "AutoSnapshotRemind"); \
  130. }\
  131. break;
  132. case eMsg_LivenessDetectionHeartBeat:\
  133. if (eMsgSig_LivenessDetectionHeartBeat == dwMessageSignature) { \
  134. LivenessDetection::LivenessDetectionHeartBeat t; \
  135. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  136. if (Error == Error_Succeed)\
  137. OnLivenessDetectionHeartBeat(pszEntityName, dwMessageId, dwMessageSignature, t); \
  138. }\
  139. else {\
  140. LOG_TRACE("%s signature mismatched!", "LivenessDetectionHeartBeat"); \
  141. }\
  142. break;
  143. case eMsg_DetectionStopUnExpected:\
  144. if (eMsgSig_DetectionStopUnExpected == dwMessageSignature) {\
  145. LivenessDetection::DetectionStopUnExpected t; \
  146. ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \
  147. if (Error == Error_Succeed)\
  148. OnDetectionStopUnExpected(pszEntityName, dwMessageId, dwMessageSignature, t); \
  149. }\
  150. else {\
  151. LOG_TRACE("%s signature mismatched!", "DetectionStopUnExpected"); \
  152. }\
  153. break;
  154. #endif // _WIN32
  155. SP_END_ENTITY_MSG()
  156. SP_END_MSG_DISPATCH_MAP()
  157. private:
  158. void OnLivenessDetectionStarted(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStarted &evt);
  159. void OnLivenessDetectionStopped(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStopped &evt);
  160. void OnActiveDetectionDone(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionDone &evt);
  161. void OnAutoSnapshotRemind(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::AutoSnapshotRemind &evt);
  162. void OnLivenessDetectionHeartBeat(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::LivenessDetectionHeartBeat &evt);
  163. void OnDetectionStopUnExpected(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::DetectionStopUnExpected &evt);
  164. BOOL m_bIsPadType;
  165. BOOL m_IsStand2SType;
  166. ChannelCounterConnectorClient*m_pCounterConnectorChannel;
  167. CAutoArray<CUUID> m_arrListener;
  168. CUUID m_uidlivenessListener;
  169. };
  170. #endif