#pragma once #include "SIPPhone_server_g.h" #include "SIPPhone_msg_g.h" using namespace SIPPhone; #include "SpBase.h" #include "SpIni.h" #include "video_render.h" #include "../mod_selfchecker/SelfChecker_client_g.h" #include "../mod_selfchecker/SelfChecker_def_g.h" using namespace SelfChecker; #include "Event.h" #include "EventCode.h" #include "../mod_assistantchannel/chan_protocol.h" #include "../mod_assistantchannel/AssistantChannel_client_g.h" #include "../../Other/libaudiomgr/iaudiomgrinterface.h" using namespace AssistantChannel; class CSIPEntity; class CSIPPhoneSession; struct CVolumnValue { int nValue; void Serialize(SpBuffer &Buf) { Buf & nValue; } }; struct CFpsValue { int nValue; void Serialize(SpBuffer &Buf) { Buf & nValue; } }; struct stVideoParam { int nWindowState; //视频窗口显示状态,0:正常大小显示,1:放大一倍显示,2:隐藏全部窗口,3:从隐藏状态恢复为全部显示,4:显示远程窗口,隐藏本地窗口, 5:缩放显示 int bShowActiveImg; //活体检测显示图片 int bActiveInspect; //是否启动活体检测 int iActiveCamera; // set by facetracking int iCameraSwitch; // set by agent and camerastate int nUpDynamicFps; // 当前视频上行的帧频,由后端通知前端更改频率,只有移动版才使用 int iCameraState; // set by agent and camerastate int bShowPersonArea; //是否显示人形框 int bShowRecordArea; //是否显示录像人形轮廓 }; //record video echo location typedef struct record_echo_location_s{ int x; int y; int width; int height; }record_echo_location_t; enum ePickupMicrophoneState { ePickupMicrophoneState_On, ePickupMicrophoneState_Off, }; /* 0:online local and remote video window, 1:only local video window, 2:both local and remote window */ //enum eShowVideoWindowType{ // eOnline_Mode_Video, // eOnly_Local_Video, // eBoth_Local_Remote_Video //}; typedef struct MakeCallCommand_s{ CSIPPhoneSession *pSIPPhoneSession; CSimpleStringA toUri; CSimpleStringA fromUri; CSimpleStringA callId; CSimpleStringA strlocalip; CSimpleStringA strmappedip; int iaudio_port; int imapped_audio_port; int ivideo_port; int imapped_video_port; }MakeCallCommand_t; struct ControlVideoCommand{ CSIPPhoneSession *pSIPPhoneSession; int start; unsigned long local_ip; int local_port; unsigned long remote_ip; int remote_port; 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; int remote_width; int remote_height; int local_hwd_move; int remote_hwd_move; int local_fresh_time; int remote_fresh_time; }; typedef struct VideoRenderCommand_s { CSIPPhoneSession* pSIPPhoneSession; bool bstart; 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; int local_hwd_move; int remote_hwd_move; int local_fresh_time; int remote_fresh_time; }VideoRenderCommand_t; struct HangupCallCommand{ CSIPPhoneSession *pSIPPhoneSession; CSimpleStringA strSession_num; CSimpleStringA strBranch_server_ip; int iBranch_server_port; }; struct ChangeDevCommand{ CSIPEntity *pEntity; int dev_type; }; class SelfChekerClient:public SelfCheckerService_ClientBase { public: SelfChekerClient(CSIPEntity*pEntity); }; class ChannelSipphoneClient : public ChannelService_ClientBase { public: ChannelSipphoneClient(CSIPEntity *pEntity); virtual void OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer pData); virtual void OnMessage(ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer pData); }; class CSIPPhoneSession : public PhoneService_ServerSessionBase { public: CSIPPhoneSession(CSIPEntity *pEntity); virtual void Handle_MakeCall(SpReqAnsContext::Pointer ctx); virtual void Handle_HangupCall(SpReqAnsContext::Pointer ctx); virtual void Handle_StartVideo(SpOnewayCallContext::Pointer ctx); virtual void Handle_StopVideo(SpOnewayCallContext::Pointer ctx); virtual void Handle_BeginState(SpSubscribeContext::Pointer ctx); virtual void Handle_EndState(SpOnewayCallContext::Pointer ctx); virtual void Handle_ReleaseCall(SpReqAnsContext::Pointer ctx); virtual void Handle_RealErrorCheck(SpOnewayCallContext::Pointer ctx); virtual void Handle_SetCallingParam(SpOnewayCallContext::Pointer ctx); virtual void OnClose(ErrorCodeEnum eErrorCode); virtual void Handle_GetHandfreeOutVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_SetHandfreeOutVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_GetPickupOutVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_SetPickupOutVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_StartVideoRender(SpOnewayCallContext::Pointer ctx); virtual void Handle_StopVideoRender(SpOnewayCallContext::Pointer ctx); virtual void Handle_GetHandfreeInVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_SetHandfreeInVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_SetPickupInVolume(SpReqAnsContext::Pointer ctx); virtual void Handle_GetPickupInVolume(SpReqAnsContext::Pointer ctx); public: void on_call_state(int state, const char *state_desc, const char *phrase); int make_call(MakeCallCommand_t *pCmd); void hangup_call(HangupCallCommand *pCmd); void release_call(); void control_video(ControlVideoCommand *pCmd); void video_render(VideoRenderCommand_t* pCmd); int on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom); int start_video_render(rvc_video_render_params_t* render_param, bool bremote); int stop_video_render(); public: int m_iLastState; private: SpSubscribeContext::Pointer m_spCallbackContext; endpoint_call_t *m_pCall; CSIPEntity *m_pEntity; }; class CSIPEntity : public CEntityBase, public ILogListener, public ISysVarListener,public ITimerListener { public: CSIPEntity(); virtual ~CSIPEntity() {} virtual const char *GetEntityName() const { return "SIPPhone"; } 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, const linkContext& pLinkInfo); virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName); virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer pTransactionContext); virtual void OnPreStart(CAutoArray strArgs,CSmartPointer pTransactionContext); virtual void OnStarted(); ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError); void OnReceivePkt(int type, int sub_type, const char *buffer, int size); ErrorCodeEnum GetLocalIP(); //send DynamicFps void SendDynamicFps(int nFps); //send audio device volume void SendAudioDeviceVolumn(int nDevice); ErrorCodeEnum SetHandfreeOutVolume(int iVolume); ErrorCodeEnum SetPickupOutVolume(int iVolume); ErrorCodeEnum SetHandfreeInVolume(int iVolume); ErrorCodeEnum SetPickupInVolume(int iVolume); virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer pTransactionContext); ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError); virtual void OnPaused(); virtual void OnContinued(); virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/); virtual bool IsService()const{return true;} virtual void OnTimeout(DWORD dwTimerID); bool IsCurrentSession(CServerSessionBase * pSession) { return m_pCurrentSession == pSession; } endpoint_t *GetEndpoint() { return m_pEndpoint; } ErrorCodeEnum InitEndpoint(); void change_dev(int dev_type); void SwitchHandFree(); void SwitchPickup(); void SetState(int state); ErrorCodeEnum RealSelfCheck(); CSimpleStringA MakeUri(const char *terminal_id); void Handle_RecordVideoLocation_Info(const char* pszMessage); void Handle_AdjustVideoEchoEvent(const char* pszMessage); private: ErrorCodeEnum LoadConfig(endpoint_conf_t *conf); void InitFreshTimeConfig(); //载入运行时配置 ErrorCodeEnum LoadAudioRunConfig(int&nHandfreeout,int&nPickupout,int&nHandfreein,int&nPickupin); //保存运行时 ErrorCodeEnum SaveAudioRunConfig(int nHandfreeout,int nPickupout,int nHandfreein,int nPickupin); // we use root.ini Video section config to decide camera count ErrorCodeEnum DecideCameraCount(int &nCount); ErrorCodeEnum DecideScreenCount(int &nCount); DeviceTypeEnum RvcGetDeviceType(); ErrorCodeEnum RvcGetAudioDeviceInfo(); ErrorCodeEnum RvcSetSaveAudioVolume(); //eVideoRenderType GetMediaConfig(); ErrorCodeEnum LoadEntityConfig(); ErrorCodeEnum ConnectAssistChannel(); void HideLocalVideo(); void ShowLocalVideo(); void HideBothVideo(); void ShowBothVideo(); ErrorCodeEnum AudioDspFlagsUseCentersetting(endpoint_conf_t* conf); bool IsPostAudioConfigInfo(); public: int m_kept_volume_in[2]; int m_kept_volume_out[2]; #ifdef RVC_OS_WIN void* m_pKeeperIn[2]; void* m_pKeeperOut[2]; #else IAudioMgr* m_pAudioMgr; #endif //int m_nDownDynamicFps; //当前视频下行的帧频,由前端通知后端更改频率,只有移动版才使用 CSystemStaticInfo staticInfo; char m_localip[RVC_MAX_IP_LEN]; //本地ip endpoint_conf_t conf; endpoint_t *m_pEndpoint; int m_iPickupPhoneState; ErrorCodeEnum m_SipErrorCode; DeviceTypeEnum m_eDeviceType; CallingTypeEnum m_nCallType; //呼叫模式,0:可视柜台正常呼叫,1:PAD主动外呼,2:PAD被动呼叫,来源PAD,3:PAD被动呼叫,来源手机端 int m_nSysCallType;//0:普通模式,1:p2p模式 volatile stVideoParam m_stVideoParam; volatile int m_bIsSalesRecord; record_echo_location_t m_RecordVideoLocation; int m_ilocalvideo_freshtime; int m_iremotevideo_freshtime; rvc_video_render_t* m_render; int m_iAudioDspUseCenter; private: CServerSessionBase *m_pCurrentSession; int m_state; CAutoArray m_arrListener; ChannelSipphoneClient*m_pSipphoneChannel; SelfChekerClient*m_pSelfcheckClient; BOOL m_bConnectedAssist; };