|
|
@@ -0,0 +1,274 @@
|
|
|
+#pragma once
|
|
|
+
|
|
|
+#include "SIPPhone_server_g.h"
|
|
|
+#include "SIPPhone_msg_g.h"
|
|
|
+using namespace SIPPhone;
|
|
|
+
|
|
|
+#include "SpBase.h"
|
|
|
+#include "SpIni.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 "audio_manager.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
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+struct MakeCallCommand
|
|
|
+{
|
|
|
+ CSIPPhoneSession *pSIPPhoneSession;
|
|
|
+ CSimpleStringA strUri;
|
|
|
+};
|
|
|
+
|
|
|
+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;
|
|
|
+};
|
|
|
+
|
|
|
+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<IReleasable> pData);
|
|
|
+ virtual void OnMessage(ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData);
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+class CSIPPhoneSession : public PhoneService_ServerSessionBase
|
|
|
+{
|
|
|
+public:
|
|
|
+ CSIPPhoneSession(CSIPEntity *pEntity);
|
|
|
+ virtual void Handle_MakeCall(SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx);
|
|
|
+ virtual void Handle_HangupCall(SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx);
|
|
|
+ virtual void Handle_StartVideo(SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx);
|
|
|
+ virtual void Handle_StopVideo(SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx);
|
|
|
+ virtual void Handle_BeginState(SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx);
|
|
|
+ virtual void Handle_EndState(SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx);
|
|
|
+ virtual void Handle_ReleaseCall(SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx);
|
|
|
+ virtual void Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx);
|
|
|
+ virtual void Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx);
|
|
|
+ virtual void OnClose(ErrorCodeEnum eErrorCode);
|
|
|
+
|
|
|
+public:
|
|
|
+ void on_call_state(int state, const char *state_desc, const char *phrase);
|
|
|
+ int make_call(const char* remote_uri);
|
|
|
+ void hangup_call(/*HangupCallCommand *pCmd*/);
|
|
|
+ void release_call();
|
|
|
+ void control_video(ControlVideoCommand *pCmd);
|
|
|
+ int on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom);
|
|
|
+
|
|
|
+
|
|
|
+public:
|
|
|
+ int m_iLastState;
|
|
|
+
|
|
|
+private:
|
|
|
+ SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer m_spCallbackContext;
|
|
|
+ endpoint_call_t *m_pCall;
|
|
|
+ CSIPEntity *m_pEntity;
|
|
|
+ int m_IsLocalPlay;
|
|
|
+ eShowVideoWindowType m_VideoWindowPlayType; /*add by clp 20190903 0:only remote video window, 1:only local video window, 2:both local and remote window */
|
|
|
+ video_session_callback_t m_cb_video_box_move;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+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<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
|
|
|
+ const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
+ const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage);
|
|
|
+
|
|
|
+ virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName);
|
|
|
+ virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext);
|
|
|
+ virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> 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);
|
|
|
+
|
|
|
+ virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> 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);
|
|
|
+ //载入运行时配置
|
|
|
+ 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();
|
|
|
+
|
|
|
+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
|
|
|
+ CAudioManager* m_pAudioMgr;
|
|
|
+#endif
|
|
|
+ //int m_nDownDynamicFps; //当前视频下行的帧频,由前端通知后端更改频率,只有移动版才使用
|
|
|
+ CSystemStaticInfo staticInfo;
|
|
|
+ char m_localip[256]; //本地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; //视频参数,add by ch@20190424
|
|
|
+ volatile int m_bIsSalesRecord; //add by ly@20180725
|
|
|
+ volatile int m_bEwsRecord; //add by ly@2019/04/18
|
|
|
+ record_echo_location_t m_RecordVideoLocation;
|
|
|
+
|
|
|
+private:
|
|
|
+ CServerSessionBase *m_pCurrentSession;
|
|
|
+ int m_state;
|
|
|
+ CAutoArray<CUUID> m_arrListener;
|
|
|
+ ChannelSipphoneClient*m_pSipphoneChannel;
|
|
|
+ SelfChekerClient*m_pSelfcheckClient;
|
|
|
+};
|
|
|
+
|
|
|
+
|