123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- #pragma once
- #include "SIPPhone_server_g.h"
- #include "SIPPhone_msg_g.h"
- using namespace SIPPhone;
- #include "SpBase.h"
- #include "SpIni.h"
- #include "endpoint.h"
- #if defined(RVC_OS_WIN)
- #include "volumekeeper.h"
- #include "iaudiomgrinterface.h"
- #else
- #include "video_render.h"
- #include "Event.h"
- #include "EventCode.h"
- #endif //RVC_OS_WIN
- #include "SelfChecker_client_g.h"
- #include "SelfChecker_def_g.h"
- using namespace SelfChecker;
- #include "mod_assistantchannel/chan_protocol.h"
- #include "mod_assistantchannel/AssistantChannel_client_g.h"
- using namespace AssistantChannel;
- #include "iaudiomgrinterface.h"
- #ifndef RVC_DEFAULT_STUNSERVER
- #define RVC_DEFAULT_STUNSERVER "rvcpad.cmbchina.com"
- #endif
- #ifndef RVC_DEFAULT_STUNPORT
- #define RVC_DEFAULT_STUNPORT "3478"
- #endif
- #ifndef RVC_STUN_TIMEOUT
- #define RVC_STUN_TIMEOUT 5000
- #endif
- #ifndef MAX_LOG_LEN
- #define MAX_LOG_LEN 512
- #endif
- #ifndef RVC_START_TIME
- #define RVC_START_TIME "00:00:00"
- #endif // !RVC_START_TIME
- #ifndef RVC_END_TIME
- #define RVC_END_TIME "08:00:00"
- #endif // !RVC_END_TIME
- #ifndef RVC_INTERVAL_TIME
- #define RVC_INTERVAL_TIME 3*60
- #endif // ! RVC_INTERVAL_TIME
- 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
- };
- enum eVideoRenderType{
- eGDI,
- eSDL
- };
- static const char* VideoRender_Type_Table[] = {
- "eGDI",
- "eSDL"
- };
- 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<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);
- virtual void Handle_GetHandfreeOutVolume(SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req, PhoneService_GetHandfreeOutVolume_Ans>::Pointer ctx);
- virtual void Handle_SetHandfreeOutVolume(SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req, PhoneService_SetHandfreeOutVolume_Ans>::Pointer ctx);
- virtual void Handle_GetPickupOutVolume(SpReqAnsContext<PhoneService_GetPickupOutVolume_Req, PhoneService_GetPickupOutVolume_Ans>::Pointer ctx);
- virtual void Handle_SetPickupOutVolume(SpReqAnsContext<PhoneService_SetPickupOutVolume_Req, PhoneService_SetPickupOutVolume_Ans>::Pointer ctx);
- virtual void Handle_StartVideoRender(SpOnewayCallContext<PhoneService_StartVideoRender_Info>::Pointer ctx);
- virtual void Handle_StopVideoRender(SpOnewayCallContext<PhoneService_StopVideoRender_Info>::Pointer ctx);
- virtual void Handle_GetHandfreeInVolume(SpReqAnsContext<PhoneService_GetHandfreeInVolume_Req, PhoneService_GetHandfreeInVolume_Ans>::Pointer ctx);
- virtual void Handle_SetHandfreeInVolume(SpReqAnsContext<PhoneService_SetHandfreeInVolume_Req, PhoneService_SetHandfreeInVolume_Ans>::Pointer ctx);
- virtual void Handle_SetPickupInVolume(SpReqAnsContext<PhoneService_SetPickupInVolume_Req, PhoneService_SetPickupInVolume_Ans>::Pointer ctx);
- virtual void Handle_GetPickupInVolume(SpReqAnsContext<PhoneService_GetPickupInVolume_Req, PhoneService_GetPickupInVolume_Ans>::Pointer ctx);
- virtual void Handle_GetAudioDevices(SpReqAnsContext<PhoneService_GetAudioDevices_Req, PhoneService_GetAudioDevices_Ans>::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);
- int on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom);
- #if defined(RVC_OS_WIN)
- ErrorCodeEnum get_nat_mapped_info(char* strmapip, size_t ulen, int* ivideo_map_port, int* iaudio_map_port, int ivideo_port, int iaudio_port);
- #else
- void video_render(VideoRenderCommand_t* pCmd);
- int start_video_render(rvc_video_render_params_t* render_param, bool bremote);
- int stop_video_render();
- #endif //RVC_OS_WIN
- public:
- int m_iLastState;
- private:
- SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer m_spCallbackContext;
- endpoint_call_t *m_pCall;
- CSIPEntity *m_pEntity;
- #if defined(RVC_OS_WIN)
- int m_IsLocalPlay;
- eShowVideoWindowType m_VideoWindowPlayType;
- video_session_callback_t m_cb_video_box_move;
- #endif //RVC_OS_WIN
- };
- 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, const linkContext& pLinkInfo);
- 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();
- #if defined(RVC_OS_WIN)
- ErrorCodeEnum LoadStunConfig();
- ErrorCodeEnum StartVideoRender();
- ErrorCodeEnum StopVideoRender();
- BOOL GetStunFlag();
- void SetStunFlag(BOOL bFlag);
- int GetIpByDomain(char* poutput, size_t ulen, const char* pinput);
- #endif //RVC_OS_WIN
- //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<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);
- #if defined(RVC_OS_WIN)
- eVideoRenderType GetMediaConfig();
- void UpdateAudioConfig();
- void HandleAudioDeviceErrorEvent();
- ErrorCodeEnum AutoCorrectAudioConfig();
- //载入运行时配置
- ErrorCodeEnum LoadRestartRunConfig(unsigned int& utime);
- //保存运行时
- ErrorCodeEnum SaveRestartRunConfig(unsigned int utime);
- #else
- void InitFreshTimeConfig();
- void HideLocalVideo();
- void ShowLocalVideo();
- void HideBothVideo();
- void ShowBothVideo();
- #endif //RVC_OS_WIN
- ErrorCodeEnum AudioDspFlagsUseCentersetting(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();
- //eVideoRenderType GetMediaConfig();
- ErrorCodeEnum LoadEntityConfig();
- ErrorCodeEnum ConnectAssistChannel();
- bool IsPostAudioConfigInfo();
- public:
- int m_kept_volume_in[2];
- int m_kept_volume_out[2];
- IAudioMgr* m_pAudioMgr;
- #ifdef RVC_OS_WIN
- void* m_pKeeperIn[2];
- void* m_pKeeperOut[2];
- eVideoRenderType m_eVideoRenderType;
- CSimpleStringA m_strStunServer;
- CSimpleStringA m_strStunPort;
- int m_iStunTimeOut;
- BOOL m_bStunFlag;
- BOOL m_bAudioMgrInited;
- int m_AudioStopType;
- int m_iCapType;
- CSimpleStringA m_strHandfreeIn;
- CSimpleStringA m_strHandfreeOut;
- CSimpleStringA m_strPickUpIn;
- CSimpleStringA m_strPickUpOut;
- CSimpleStringA m_strStartTime;
- CSimpleStringA m_strEndTime;
- int m_itervalTime;
- BOOL m_bStopAutoRestart;
- int m_iAudioDspUseCenter;
- #else
- int m_ilocalvideo_freshtime;
- int m_iremotevideo_freshtime;
- rvc_video_render_t* m_render;
- int m_iAudioDspUseCenter;
- #endif
-
- 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;
- private:
- CServerSessionBase *m_pCurrentSession;
- int m_state;
- CAutoArray<CUUID> m_arrListener;
- ChannelSipphoneClient*m_pSipphoneChannel;
- SelfChekerClient*m_pSelfcheckClient;
- BOOL m_bConnectedAssist;
- #if defined(RVC_OS_WIN)
- int m_iAudioInCount;
- int m_iAudioOutCount;
- CSimpleStringA m_strAudioIn;
- CSimpleStringA m_strAudioOut;
- #endif //RVC_OS_WIN
- };
|