///////////////////////////////// ///// 连线服务 ///////////////////////////////// #ifndef __MOD_COUNTERCONNECTOR_H #define __MOD_COUNTERCONNECTOR_H #pragma once #include "stdafx.h" #include "SpBase.h" #include "SpIni.h" #include "ConnectorFSM.h" #include "ListEntry.h" #include "SpHelper.h" #include "Event.h" #include "CounterConnector_msg_g.h" #include "../mod_assistantchannel/chan_protocol.h" #include "../mod_livenessdetection/LivenessDetection_msg_g.h" #include "CounterConnector_server_g.h" #include "modVer.h" class CCounterConnectorEntity ; class CCounterConnectorSession : public ConnectService_ServerSessionBase { public: CCounterConnectorSession(CCounterConnectorEntity *pEntity) : m_pEntity(pEntity) { } virtual void Handle_StartCall(SpReqAnsContext::Pointer ctx); virtual void Handle_StartCallExternal(SpReqAnsContext::Pointer ctx); virtual void Handle_StopCall(SpReqAnsContext::Pointer ctx); virtual void OnClose(ErrorCodeEnum eErrorCode); private: CCounterConnectorEntity *m_pEntity; }; class ChannelCounterConnectorClient : public ChannelService_ClientBase { public: ChannelCounterConnectorClient(CCounterConnectorEntity *pEntity); virtual void OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer pData); virtual void OnMessage(ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer pData); private: int m_eLastState; unsigned int m_uConnectTime; }; class CCounterConnectorEntity : public CEntityBase, public ILogListener, public IBroadcastListener { public: CCounterConnectorEntity() : m_fsm() {} virtual ~CCounterConnectorEntity() {} virtual const char *GetEntityName() const { return "CounterConnector"; } const char* GetEntityVersion() const { return MODULE_VERSION_FULL; } virtual void OnPreStart(CAutoArray strArgs,CSmartPointer pTransactionContext); virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer pTransactionContext); virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer pTransactionContext) ; virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/); ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError); ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError); virtual void OnLog(const CAutoArray &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel, const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, const CAutoArray &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage); //change audio device message void OnReceivePkt(int type, int sub_type, const char *buffer, int size); //send cur audio device to agent void SendCurAudioDevice(); CSimpleStringA BuildVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy); void SetCallType(CallingTypeEnum eType); 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); CSimpleStringA ConstructVideoParam(CSimpleStringA strMsg, bool bDoubleVideo); void Handle_StartRecord(const char* pszMessage); void Handle_StartRemoteRecord(const char* pszMessage); void StopRemoteRecordSpeakerAudioCapture(); void Handle_StartRecordPreview(const char* pszMessage); virtual bool IsService()const; ACMCallFSM m_fsm; BOOL m_bIsSalesRecord; BOOL m_bIsRemoteRecord; //add by clp 20191112 BOOL m_bIsRemoteRecordBroadCast; //add by clp 20200324 BOOL m_bIsRemoteRecordStopSpeakerCapture; //add by clp 20200324 CServerSessionBase *m_pCurrentSession; SP_BEGIN_MSG_DISPATCH_MAP(CCounterConnectorEntity) SP_BEGIN_ENTITY_MSG("LivenessDetection") #ifdef RVC_OS_WIN SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStarted, OnLivenessDetectionStarted) SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionStopped, OnLivenessDetectionStopped) SP_MSG_HANDLE_NS(LivenessDetection, ActiveDetectionDone, OnActiveDetectionDone) SP_MSG_HANDLE_NS(LivenessDetection, AutoSnapshotRemind, OnAutoSnapshotRemind) SP_MSG_HANDLE_NS(LivenessDetection, LivenessDetectionHeartBeat, OnLivenessDetectionHeartBeat) SP_MSG_HANDLE_NS(LivenessDetection, DetectionStopUnExpected, OnDetectionStopUnExpected) #else case eMsg_ActiveDetectionStarted:\ if (eMsgSig_ActiveDetectionStarted == dwMessageSignature) {\ LivenessDetection::ActiveDetectionStarted t;\ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t);\ if (Error == Error_Succeed)\ OnLivenessDetectionStarted(pszEntityName, dwMessageId, dwMessageSignature, t);\ }\ else {\ LOG_TRACE("%s signature mismatched!", "ActiveDetectionStarted");\ }\ break; case eMsg_ActiveDetectionStopped:\ if (eMsgSig_ActiveDetectionStopped == dwMessageSignature) {\ LivenessDetection::ActiveDetectionStopped t; \ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \ if (Error == Error_Succeed)\ OnLivenessDetectionStopped(pszEntityName, dwMessageId, dwMessageSignature, t); \ }\ else {\ LOG_TRACE("%s signature mismatched!", "ActiveDetectionStopped"); \ }\ break; case eMsg_ActiveDetectionDone:\ if (eMsgSig_ActiveDetectionDone == dwMessageSignature) {\ LivenessDetection::ActiveDetectionDone t; \ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \ if (Error == Error_Succeed)\ OnActiveDetectionDone(pszEntityName, dwMessageId, dwMessageSignature, t); \ }\ else {\ LOG_TRACE("%s signature mismatched!", "ActiveDetectionDone"); \ }\ break; case eMsg_AutoSnapshotRemind:\ if (eMsgSig_AutoSnapshotRemind == dwMessageSignature) {\ LivenessDetection::AutoSnapshotRemind t; \ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \ if (Error == Error_Succeed)\ OnAutoSnapshotRemind(pszEntityName, dwMessageId, dwMessageSignature, t); \ }\ else {\ LOG_TRACE("%s signature mismatched!", "AutoSnapshotRemind"); \ }\ break; case eMsg_LivenessDetectionHeartBeat:\ if (eMsgSig_LivenessDetectionHeartBeat == dwMessageSignature) { \ LivenessDetection::LivenessDetectionHeartBeat t; \ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \ if (Error == Error_Succeed)\ OnLivenessDetectionHeartBeat(pszEntityName, dwMessageId, dwMessageSignature, t); \ }\ else {\ LOG_TRACE("%s signature mismatched!", "LivenessDetectionHeartBeat"); \ }\ break; case eMsg_DetectionStopUnExpected:\ if (eMsgSig_DetectionStopUnExpected == dwMessageSignature) {\ LivenessDetection::DetectionStopUnExpected t; \ ErrorCodeEnum Error = SpBuffer2Object(Buffer, t); \ if (Error == Error_Succeed)\ OnDetectionStopUnExpected(pszEntityName, dwMessageId, dwMessageSignature, t); \ }\ else {\ LOG_TRACE("%s signature mismatched!", "DetectionStopUnExpected"); \ }\ break; #endif // _WIN32 SP_END_ENTITY_MSG() SP_END_MSG_DISPATCH_MAP() private: void OnLivenessDetectionStarted(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStarted &evt); void OnLivenessDetectionStopped(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionStopped &evt); void OnActiveDetectionDone(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::ActiveDetectionDone &evt); void OnAutoSnapshotRemind(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::AutoSnapshotRemind &evt); void OnLivenessDetectionHeartBeat(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::LivenessDetectionHeartBeat &evt); void OnDetectionStopUnExpected(const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, LivenessDetection::DetectionStopUnExpected &evt); BOOL m_bIsPadType; BOOL m_IsStand2SType; ChannelCounterConnectorClient*m_pCounterConnectorChannel; CAutoArray m_arrListener; CUUID m_uidlivenessListener; }; #endif