123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406 |
- #include "stdafx.h"
- #include "SpBase.h"
- #include "SpIni.h"
- #include "endpoint.h"
- #include "SIPPhone_server_g.h"
- #include "SIPPhone_msg_g.h"
- #include "../mod_agentip/sysvar.h"
- #include "../mod_facetracking/sysvar.h"
- #include "sockutil.h"
- #include "rec_common.h"
- #include "audio_session.h"
- #include "video_session.h"
- #include "volumekeeper.h"
- #include "Event.h"
- #include "EventCode.h"
- #include "../mod_assistantchannel/AssistantChannel_client_g.h"
- using namespace AssistantChannel;
- #include "../mod_assistantchannel/chan_protocol.h"
- #include "../mod_selfchecker/SelfChecker_client_g.h"
- #include "../mod_selfchecker/SelfChecker_def_g.h"
- using namespace SelfChecker;
- #define EVT_CONVERTER "EventConverter"
- #define DEVICE_HANDFREE_OUT 0
- #define DEVICE_PICKUP_OUT 1
- #define DEVICE_HANDFREE_IN 2
- #define DEVICE_PICKUP_IN 3
- 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 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;
- #ifndef DEFAULT_RECORD_VIDEO_WIDTH
- #define DEFAULT_RECORD_VIDEO_WIDTH 1056
- #endif
- #ifndef DEFAULT_RECORD_VIDEO_HEIGHT
- #define DEFAULT_RECORD_VIDEO_HEIGHT 595
- #endif
- #ifndef SMALL_RECORD_VIDEO_WIDTH
- #define SMALL_RECORD_VIDEO_WIDTH 244
- #endif
- #ifndef SMALL_RECORD_VIDEO_HEIGHT
- #define SMALL_RECORD_VIDEO_HEIGHT 138
- #endif
- /////////////////////////////////////////////
- // future roadmap
- // 1. 使用session timer
- // 2. 增强稳定性
- // 3. 健康检查里面触发 主备服务器切换(switch between freeswitchs) 定时发送options ping switch server
- /////////////////////////////////////////////
- extern BOOL g_IsExternalTerminalted;
- extern BOOL g_bIsSalesRecord;
- extern BOOL g_bEwsRecord;
- using namespace SIPPhone;
- class CSIPEntity;
- 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) : m_pEntity(pEntity), m_pCall(NULL), m_iLastState(0),m_IsLocalPlay(0),m_VideoWindowPlayType(eOnline_Mode_Video)
- {
- m_cb_video_box_move.on_video_box_move = &__on_video_box_move;
- m_cb_video_box_move.user_data = this;
- }
- 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);
- private:
- 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;
- };
- void on_call_state(int state, const char *state_desc, const char *phrase);
- int make_call(const char *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);
- static void __on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom, void *user_data)
- {
- CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
- pThis->on_video_box_move(imessagetype, ivideotype, ileft, ibottom);
- }
- static void __on_call_state(int state, const char *state_desc, const char *phrase, void *user_data)
- {
- LOG_FUNCTION();
- CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
- if (pThis->m_iLastState != state) {
- pThis->m_iLastState = state;
- pThis->on_call_state(state, state_desc, phrase);
- }
- }
- static int __make_call(void *user_data)
- {
- MakeCallCommand *cmd = (MakeCallCommand*)user_data;
- int rc = cmd->pSIPPhoneSession->make_call(cmd->strUri);
- delete cmd;
- return rc;
- }
- static int __hangup_call(void *user_data)
- {
- HangupCallCommand *cmd = (HangupCallCommand*)(user_data);
- cmd->pSIPPhoneSession->hangup_call(cmd);
- delete cmd;
- return 0;
- }
- static int __control_video(void *arg)
- {
- ControlVideoCommand *pCmd = (ControlVideoCommand*)(arg);
- pCmd->pSIPPhoneSession->control_video(pCmd);
- delete pCmd;
- return 0;
- }
- static int __release_call(void *user_data)
- {
- CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
- pThis->release_call();
- pThis->on_call_state(TERMINATED,"STATE:terminated","byebye");
- return 0;
- }
- private:
- SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer m_spCallbackContext;
- endpoint_call_t *m_pCall;
- CSIPEntity *m_pEntity;
- int m_iLastState;
- 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() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhoneState(ePickupMicrophoneState_Off)
- {
- m_kept_volume_in[0] = m_kept_volume_in[1] = 0;
- m_kept_volume_out[0] = m_kept_volume_out[1] = 0;
- m_pKeeperIn[0] = m_pKeeperIn[1] = NULL;
- m_pKeeperOut[0] = m_pKeeperOut[1] = NULL;
- m_SipErrorCode = Error_Succeed;
- memset((void*)&m_stVideoParam,0,sizeof(stVideoParam));
- }
- 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)
- {
- LOG_TRACE("user_code = %08x", dwUserCode);
- switch (dwUserCode)
- {
- case LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE:
- {
- Dbg("recv LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE");
- if (m_pSipphoneChannel != NULL)
- {
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- Dbg("Close AssistChannel Session ");
- }
- ErrorCodeEnum Error;
- if (m_pSipphoneChannel == NULL)
- {
- Dbg("ReConnection AssistChannel Session");
- m_pSipphoneChannel = new ChannelSipphoneClient(this);
- Error = m_pSipphoneChannel->Connect();
- if (Error != Error_Succeed)
- {
- m_pSipphoneChannel->SafeDelete();
- Dbg("ChannelSipphoneClient connect fail!");
- }
- if (Error == Error_Succeed)
- {
- ChannelService_BeginState_Sub Sub;
- Error = m_pSipphoneChannel->BeginState(Sub);
- if (Error != Error_Succeed)
- {
- LOG_TRACE("BeginState biz channel failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- }
- }
- if (Error == Error_Succeed)
- {
- ChannelService_BeginRecv_Sub Sub;
- Sub.type = ACM_TYPE_DEVICE;
- Error = m_pSipphoneChannel->BeginRecv(Sub);
- if (Error != Error_Succeed)
- {
- Dbg("Begin BeginRecv ACM_TYPE_DEVICE failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- }
- }
- }
- }
- break;
- case EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP:
- case EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP:
- case EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE:
- case EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE:
- case EVENT_MOD_CONNECT_PICKUP_CALL:
- case EVENT_MOD_CONNECT_SLV_HANDFREECALL:
- case EVENT_MOD_CONNECT_SLV_PICKUPCALL:
- case LOG_EVT_HANDFREE_MODE_REMOTE_CALL:
- case LOG_EVT_PICKUP_MODE_REMOTE_CALL:
- {
- int old_state = m_iPickupPhoneState;
- if (dwUserCode == EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP) { // 免提->提机
- m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP) { //坐席控制免提->提机
- m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE) { //坐席控制提机->免提
- m_iPickupPhoneState = ePickupMicrophoneState_Off;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE)
- { // // 提机->免提
- m_iPickupPhoneState = ePickupMicrophoneState_Off;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_PICKUP_CALL)
- { // 提机拨号
- m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_SLV_HANDFREECALL)
- { // 免提拨号
- m_iPickupPhoneState = ePickupMicrophoneState_Off;
- }
- else if (dwUserCode == EVENT_MOD_CONNECT_SLV_PICKUPCALL)
- {
- // 通过界面拨号,但话筒未挂,进入提机拨号
- m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- else if (dwUserCode == LOG_EVT_HANDFREE_MODE_REMOTE_CALL)
- { // 免提模式开始远程双录连线
- m_iPickupPhoneState = ePickupMicrophoneState_Off;
- }
- else if (dwUserCode == LOG_EVT_PICKUP_MODE_REMOTE_CALL)
- {
- // 话筒模式开始远程双录连线
- m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- LOG_TRACE("dwUserCode = 0x%08x,m_iPickupPhoneState %d", dwUserCode, m_iPickupPhoneState);
- Dbg("dwUserCode = 0x%08x,old_PhoneState = %d,PickupPhoneState = %d", dwUserCode,old_state, m_iPickupPhoneState);
- if (old_state != m_iPickupPhoneState)
- {
- if (m_iPickupPhoneState == ePickupMicrophoneState_On)
- {
- SwitchPickup();
- }
- else
- {
- SwitchHandFree();
- }
- }
- }
- break;
- case LOG_EVT_ENTER_ACM_FLOW:
- {
- Dbg("LOG_EVT_ENTER_ACM_FLOW");
- m_stVideoParam.nWindowState = 1;
- }
- break;
- case LOG_EVT_EXIT_ACM_FLOW:
- {
- Dbg("LOG_EVT_EXIT_ACM_FLOW");
- if(m_stVideoParam.nWindowState == 1)
- {
- m_stVideoParam.nWindowState = 0;
- }
- }
- break;
- case LOG_EVT_STARTLIVEDETECTDISPLAY:
- {
- Dbg("start livedetection display");
- m_stVideoParam.bActiveInspect = 1;
- }
- break;
- case LOG_EVT_STOPLIVEDETECTDISPLAY:
- {
- Dbg("stop livedetection display and show livedetection photo %s",pszMessage);
- }
- break;
- case LOG_EVT_CHANGELIVEDETECTIONCAM:
- {
- if (pszMessage && strlen(pszMessage) > 0)
- {
- int i = atoi(pszMessage);
- Dbg("change active display camera to %d",i);
- m_stVideoParam.iCameraSwitch = i;
- }
- else
- {
- Dbg("change active display camera param error");
- }
- }
- break;
- case LOG_EVT_RELEASELIVEDETECTION:
- {
- Dbg("release show active image");
- m_stVideoParam.bActiveInspect = 0;
- m_stVideoParam.bShowActiveImg = 0;
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
- }
- break;
- case LOG_EVT_UI_HIDEONLINEVIDEO:
- {
- Dbg("Receive UI hide online video evt!");
- m_stVideoParam.nWindowState = 2;
- }
- break;
- case LOG_EVT_UI_SHOWONLINEVIDEO:
- {
- Dbg("Receive UI show online video evt!");
- if (m_stVideoParam.nWindowState == 2)
- {
- m_stVideoParam.nWindowState = 3;
- }
- }
- break;
- case LOG_EVT_UI_STARTRECORD:
- case LOG_EVT_UI_STARTREMOTERECORD:
- {
- Dbg("start sales record video.");
- m_bIsSalesRecord = TRUE;
- g_bIsSalesRecord = m_bIsSalesRecord;
- m_bEwsRecord = FALSE;
- if (strlen(pszMessage)>=4&&!strnicmp(pszMessage,"ews|",4)){
- m_bEwsRecord = TRUE;
- }
- g_bEwsRecord = m_bEwsRecord;
- }
- break;
- case LOG_EVT_UI_STARTRECORDPREVIEW:
- {
- Dbg("start sales record preview.");
- m_stVideoParam.bShowRecordArea = 1;
- Handle_RecordVideoLocation_Info(pszMessage);
- }
- break;
- case LOG_EVT_UI_STOPRECORD:
- case LOG_EVT_UI_STOPREMOTERECORD:
- {
- Dbg("stop sales record video.");
- m_bIsSalesRecord = FALSE;
- g_bIsSalesRecord = m_bIsSalesRecord;
- m_bEwsRecord = FALSE; //add by ly@2019/04/18
- g_bEwsRecord = m_bEwsRecord; //add by ly@2019/04/18
- if (m_stVideoParam.bShowRecordArea){
- Dbg("stop sales record and stop preview.");
- m_stVideoParam.bShowRecordArea = 0;
- }
- }
- break;
- case LOG_EVT_UI_STOPRECORDPREVIEW:
- {
- Dbg("stop sales record preview.");
- m_stVideoParam.bShowRecordArea = 0;
- }
- break;
- case LOG_EVT_UI_RETURNMENU:
- {
- Dbg("return menu");
- m_bIsSalesRecord = FALSE;
- g_bIsSalesRecord = m_bIsSalesRecord;
- m_bEwsRecord = FALSE; //add by ly@2019/04/18
- g_bEwsRecord = m_bEwsRecord; //add by ly@2019/04/18
- }
- break;
- case LOG_EVT_UI_SHOWLOCALVIDEO:
- {
- Dbg("Receive UI show all video evt!");
- if (m_stVideoParam.nWindowState == 4)
- {
- m_stVideoParam.nWindowState = 3;
- }
- }
- break;
- case LOG_EVT_UI_HIDELOCALVIDEO:
- {
- Dbg("Receive UI hide local video evt!");
- m_stVideoParam.nWindowState = 4;
- }
- break;
- case LOG_EVT_UI_HIDEPERSONAREA:
- {
- Dbg("Receive UI hide person area!");
- m_stVideoParam.bShowPersonArea = 0;
- }
- break;
- case LOG_EVT_UI_SHOWPERSONAREA:
- {
- Dbg("Receive UI show person area!");
- m_stVideoParam.bShowPersonArea = 1;
- }
- break;
- case EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST:
- {
- Dbg("stop remote record audio broadcast.");
- }
- break;
- case EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL:
- {
- Dbg("begin double record call.");
- }
- break;
- case LOG_EVT_UI_ADJUSTVIDEOECHOSIZE:
- {
- Dbg("adjust video echo size %s.", pszMessage);
- Handle_AdjustVideoEchoEvent(pszMessage);
- }
- break;
- default:
- {
- Dbg("unknown dwUserCode = %x.",dwUserCode);
- }
- break;
- }
- }
- virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName)
- {
- if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 0)
- {
- Dbg("camera state from : %c to %c", pszOldValue[0], pszValue[0]);
- if (pszValue[0] == 'E')
- {
- m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
- }
- else if (pszValue[0] == 'O')
- {
- m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
- }
- else if(pszValue[0] == 'B') ///////显示贴图
- {
- /////////////////////////此处显示贴图//////////////////////////////////
- //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
- m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
- }
- else if (pszValue[0] == 'N')
- {
- m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
- //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- }
- }
- else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
- {
- Dbg("active camera from : %c to %c", pszOldValue[0], pszValue[0]);
- if (pszValue[0] == 'E')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if (pszValue[0] == 'O')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
- }
- else
- {
- Dbg("warning: unknown ActiveTrackingCamera value!");
- }
- }
- else if (_stricmp(pszKey, SYSVAR_AGENTCAMERASWITCH) == 0)
- {
- Dbg("agent camera switch from : %c to %c", pszOldValue[0], pszValue[0]);
- if((pszValue[0] == 'E')/*&&((m_iCameraState==CAMERA_TYPE_AUTO)||(m_iCameraState==CAMERA_TYPE_ENV))*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
- }
- else if((pszValue[0] == 'O')/*&&((m_iCameraState==CAMERA_TYPE_AUTO)||(m_iCameraState==CAMERA_TYPE_OPT))*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
- }
- else if((pszValue[0] == 'A')/*&&(m_iCameraState==CAMERA_TYPE_AUTO)*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- }
- }
- else if (_stricmp(pszKey, SYSVAR_CALLTYPE) == 0)
- {
- Dbg("sys calltype from: %c to %c", pszOldValue[0], pszValue[0]);
- if(pszValue[0] == CALLTYPE_NORMAL)
- {
- m_nSysCallType = 0;
- }
- else if(pszValue[0] == CALLTYPE_MOBILE)
- {
- m_nSysCallType = 1;
- }
- else
- {
- m_nSysCallType =-1;
- }
- }
- }
- virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- if (Test_ShakeHand == eTestType)
- {
- pTransactionContext->SendAnswer(m_SipErrorCode);
- }
- }
- virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- ErrorCodeEnum Error = __OnStart(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- }
- virtual void OnStarted()
- {
- ErrorCodeEnum Error = Error_Succeed;
- m_pSelfcheckClient = new SelfChekerClient(this);
- Error = m_pSelfcheckClient->Connect();
- if (Error != Error_Succeed)
- {
- m_pSelfcheckClient->SafeDelete();
- m_pSelfcheckClient = NULL;
- Dbg("SelfcheckClient connect fail!");
- }
- else
- {
- Dbg("SelfcheckClient connect success!");
- }
- }
- ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
- {
- ErrorCodeEnum Error;
- //MessageBoxA(0,0,0,0);
- m_nCallType = NORMAL_CALLTYPE;
- m_nSysCallType = 0;
- m_pSipphoneChannel = new ChannelSipphoneClient(this);
- memset(m_localip,0,256);
- Error = m_pSipphoneChannel->Connect();
- if (Error != Error_Succeed)
- {
- m_pSipphoneChannel->SafeDelete();
- Dbg("ChannelSipphoneClient connect fail!");
- return Error;
- }
- {
- ChannelService_BeginState_Sub Sub;
- Error = m_pSipphoneChannel->BeginState(Sub);
- if (Error != Error_Succeed)
- {
- LOG_TRACE("BeginState biz channel failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- {
- ChannelService_BeginRecv_Sub Sub;
- Sub.type = ACM_TYPE_DEVICE;
- Error = m_pSipphoneChannel->BeginRecv(Sub);
- if (Error != Error_Succeed)
- {
- Dbg("Begin BeginRecv ACM_TYPE_DEVICE failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- {
- ChannelService_BeginRecv_Sub Sub;
- Sub.type = ACM_TYPE_VIDEOFREQ;
- Error = m_pSipphoneChannel->BeginRecv(Sub);
- if (Error != Error_Succeed)
- {
- Dbg("Begin BeginRecv ACM_TYPE_VIDEOFREQ failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- m_pSipphoneChannel->SafeDelete();
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- {
- m_pSelfcheckClient = new SelfChekerClient(this);
- Error = m_pSelfcheckClient->Connect();
- if (Error != Error_Succeed)
- {
- m_pSelfcheckClient->SafeDelete();
- m_pSelfcheckClient = NULL;
- Dbg("SelfcheckClient connect fail!");
- }
- else
- {
- Dbg("SelfcheckClient connect success!");
- }
- }
-
- m_eDeviceType = RvcGetDeviceType();
- m_stVideoParam.bActiveInspect = 0;
- m_stVideoParam.bShowActiveImg = 0;
- m_bIsSalesRecord = FALSE;
- g_bIsSalesRecord = m_bIsSalesRecord;
- m_bEwsRecord = FALSE;
- g_bEwsRecord = m_bEwsRecord;
- m_stVideoParam.nWindowState = 0;
- m_RecordVideoLocation.x = 0;
- m_RecordVideoLocation.y = 0;
- m_RecordVideoLocation.width = DEFAULT_RECORD_VIDEO_WIDTH;
- m_RecordVideoLocation.height = DEFAULT_RECORD_VIDEO_HEIGHT;
- LOG_FUNCTION();
- video_lib_init();
- audio_lib_init();
- endpoint_init_lib();
- Error = GetLocalIP();
- if (Error != 0)
- {
- LOG_TRACE("get local ip failed!");
- return Error;
- }
- Error = LoadConfig(&conf);
- if (Error != Error_Succeed)
- {
- LOG_TRACE("load config failed!");
- return Error;
- }
- int nhandfreeout = 0;
- int npickupout = 0;
- int nhanfreein = 0;
- int npickupin = 0;
- Error = LoadAudioRunConfig(nhandfreeout,npickupout,nhanfreein,npickupin);
- if (Error == Error_Succeed)
- {
- if (nhandfreeout > 0)
- {
- m_kept_volume_out[DEV_HANDFREE] = nhandfreeout;
- }
- if (npickupout > 0)
- {
- m_kept_volume_out[DEV_PICKUP] = npickupout;
- }
- if (nhanfreein > 0)
- {
- m_kept_volume_in[DEV_HANDFREE] = nhanfreein;
- }
- if (npickupin > 0)
- {
- m_kept_volume_in[DEV_PICKUP] = npickupin;
- }
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- Func->GetSystemStaticInfo(staticInfo);
- }
- CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
- if (strUri.GetLength() > 0)
- {
- strcpy(conf.uri, strUri);
- conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
- conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
- m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
- if (!m_pEndpoint) {
- LOG_TRACE("create endpoint failed!");
- return Error_Unexpect;
- }
- else{
- Dbg("__OnStart call uri is %s, endpoint_create m_pEndpoint addr is %0x.",conf.uri, m_pEndpoint);
- }
- }
- else
- {
- LOG_TRACE("strUri length equals zero!");
- return Error_Unexpect;
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CUUID id;
- int i = 0;
- m_arrListener.Init(32);
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP, EVT_CONVERTER);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE, EVT_CONVERTER);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_CALL, EVT_CONVERTER);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_SLV_HANDFREECALL,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_SLV_PICKUPCALL,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_ENTER_ACM_FLOW,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_EXIT_ACM_FLOW,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_STARTLIVEDETECTDISPLAY,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_STOPLIVEDETECTDISPLAY,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_CHANGELIVEDETECTIONCAM,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_RELEASELIVEDETECTION,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDEONLINEVIDEO,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWONLINEVIDEO,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTRECORD,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPRECORD,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_RETURNMENU,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDELOCALVIDEO,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWLOCALVIDEO,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDEPERSONAREA,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWPERSONAREA,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_HANDFREE_MODE_REMOTE_CALL,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_PICKUP_MODE_REMOTE_CALL,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTRECORDPREVIEW,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPRECORDPREVIEW,NULL,false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_ADJUSTVIDEOECHOSIZE,NULL,false);
- m_arrListener[i++] = id;
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue;
- Func->RegistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA, this);
- Func->GetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, strValue);
- if (strValue[0] == 'E')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if (strValue[0] == 'O')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
- }
- else
- {
- assert(0);
- }
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue;
- Func->RegistSysVarEvent(SYSVAR_CAMERASTATE, this);
- Func->GetSysVar(SYSVAR_CAMERASTATE, strValue);
- if (strValue[0] == 'E')
- {
- m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
- }
- else if (strValue[0] == 'O')
- {
- m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
- }
- else if(strValue[0] == 'B') ///////显示贴图
- {
- /////////////////////////此处显示贴图//////////////////////////////////
- //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
- m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
- }
- else if (strValue[0] == 'N')
- {
- //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
- }
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue;
- Func->RegistSysVarEvent(SYSVAR_AGENTCAMERASWITCH, this);
- Func->GetSysVar(SYSVAR_AGENTCAMERASWITCH, strValue);
- if((strValue[0] == 'E')/*&&((m_iCameraState == CAMERA_TYPE_AUTO)||(m_iCameraState = CAMERA_TYPE_ENV))*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
- }
- else if((strValue[0] == 'O')/*&&((m_iCameraState == CAMERA_TYPE_AUTO)||(m_iCameraState = CAMERA_TYPE_OPT))*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
- }
- else if ((strValue[0] == 'A')/*&&(m_iCameraState == CAMERA_TYPE_AUTO)*/)
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- }
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue;
- Func->RegistSysVarEvent(SYSVAR_CALLTYPE, this);
- Func->GetSysVar(SYSVAR_CALLTYPE, strValue);
- if (strValue[0] == CALLTYPE_NORMAL)
- {
- m_nSysCallType = 0;
- }
- else if (strValue[0] == CALLTYPE_MOBILE)
- {
- m_nSysCallType = 1;
- }
- else
- {
- assert(0);
- }
- }
- #ifdef RVC_OS_WIN
- if (m_kept_volume_in[DEV_HANDFREE])
- {
- m_pKeeperIn[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_in_dev, 1, m_kept_volume_in[DEV_HANDFREE]);
- if (m_pKeeperIn[DEV_HANDFREE])
- {
- Dbg("HANDFREE in volume keeper create ok! %d", m_kept_volume_in[DEV_HANDFREE]);
- }
- else
- {
- Dbg("HANDFREE in volume keeper create failed!");
- }
- }
- if (m_kept_volume_out[DEV_HANDFREE])
- {
- m_pKeeperOut[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_out_dev, 0, m_kept_volume_out[DEV_HANDFREE]);
- if (m_pKeeperOut[DEV_HANDFREE])
- {
- Dbg("HANDFREE out volume keeper create ok! %d", m_kept_volume_out[DEV_HANDFREE]);
- }
- else
- {
- Dbg("HANDFREE out volume keeper create failed!");
- }
- }
- if (m_kept_volume_in[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)) //pad版屏蔽pickup
- {
- m_pKeeperIn[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_in_dev, 1, m_kept_volume_in[DEV_PICKUP]);
- if (m_pKeeperIn[DEV_PICKUP])
- {
- Dbg("PICKUP in volume keeper create ok! %d", m_kept_volume_in[DEV_PICKUP]);
- }
- else
- {
- Dbg("PICKUP in volume keeper create failed!");
- }
- }
- if (m_kept_volume_out[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)) //pad版屏蔽pickup
- {
- m_pKeeperOut[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_out_dev, 0, m_kept_volume_out[DEV_PICKUP]);
- if (m_pKeeperOut[DEV_PICKUP])
- {
- Dbg("PICKUP out volume keeper create ok! %d", m_kept_volume_out[DEV_PICKUP]);
- }
- else
- {
- Dbg("PICKUP out volume keeper create failed!");
- }
- }
- #else
- #endif // RVC_OS_WIN
- return Error_Succeed;
- }
-
- video_session_t *video_session;
- //volumn adjust
- void OnReceivePkt(int type, int sub_type, const char *buffer, int size)
- {
- if (type == ACM_TYPE_DEVICE)
- {
- if (sub_type == ACM_SET_HANDFREE_OUTVOLUMN)
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- Dbg("recv adj handfree out volumn = %d",num.nValue);
- if (m_pKeeperOut[DEV_HANDFREE])
- {
- volume_keeper_change(m_pKeeperOut[DEV_HANDFREE],num.nValue);
- m_kept_volume_out[DEV_HANDFREE] = num.nValue;
- SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
- SaveAudioRunConfig(m_kept_volume_out[DEV_HANDFREE],m_kept_volume_out[DEV_PICKUP],m_kept_volume_in[DEV_HANDFREE],m_kept_volume_in[DEV_PICKUP]);
- }
- else
- {
- Dbg("HANDFREE out volume keeper create failed!");
- }
- }
- else if((sub_type == ACM_SET_PICKUP_OUTVOLUMN)&&(eStand2sType == m_eDeviceType))
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- Dbg("recv adj pickup out volumn = %d",num.nValue);
- if (m_pKeeperOut[DEV_PICKUP])
- {
- if(eStand2sType == m_eDeviceType)
- {
- volume_keeper_change(m_pKeeperOut[DEV_PICKUP],num.nValue);
- m_kept_volume_out[DEV_PICKUP] = num.nValue;
- SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
- SaveAudioRunConfig(m_kept_volume_out[DEV_HANDFREE],m_kept_volume_out[DEV_PICKUP],m_kept_volume_in[DEV_HANDFREE],m_kept_volume_in[DEV_PICKUP]);
- }
- else //pad版屏蔽当前PICKUP音量设置
- {
- Dbg("PAD type, ignore pickupout volume adj");
- }
- }
- else
- {
- Dbg("PICKUP out volume keeper create failed!");
- }
- }
- else if (sub_type == ACM_SET_HANDFREE_INVOLUMN)
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- Dbg("recv adj handfree in volumn = %d",num.nValue);
- if (m_pKeeperIn[DEV_HANDFREE])
- {
- volume_keeper_change(m_pKeeperIn[DEV_HANDFREE],num.nValue);
- m_kept_volume_in[DEV_HANDFREE] = num.nValue;
- SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
- SaveAudioRunConfig(m_kept_volume_out[DEV_HANDFREE],m_kept_volume_out[DEV_PICKUP],m_kept_volume_in[DEV_HANDFREE],m_kept_volume_in[DEV_PICKUP]);
- }
- else
- {
- Dbg("handfree in volume keeper create failed!");
- }
- }
- else if((sub_type == ACM_SET_PICKUP_INVOLUMN)&&(eStand2sType == m_eDeviceType))
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- Dbg("recv adj pickup in volume = %d",num.nValue);
- if (m_pKeeperIn[DEV_PICKUP])
- {
- if(eStand2sType == m_eDeviceType)
- {
- volume_keeper_change(m_pKeeperIn[DEV_PICKUP],num.nValue);
- m_kept_volume_in[DEV_PICKUP] = num.nValue;
- SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
- SaveAudioRunConfig(m_kept_volume_out[DEV_HANDFREE],m_kept_volume_out[DEV_PICKUP],m_kept_volume_in[DEV_HANDFREE],m_kept_volume_in[DEV_PICKUP]);
- }
- else //pad版屏蔽当前PICKUP音量设置
- {
- Dbg("PAD type, ignore pickupin volume adj");
- }
- }
- else
- {
- Dbg("pickup in volume keeper create failed!");
- }
- }
- else if (sub_type == ACM_CONTROL_PERSONAREA) //控制人形框
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- Dbg("recv control personarea subtype = %d",num.nValue);
- if (num.nValue == 0) //隐藏人形框
- {
- //LogEvent(Severity_Middle,LOG_EVT_UI_HIDEPERSONAREA,"Agent send Hide Person area");
- //if((eMobilePadType == m_eDeviceType)||(ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
- //{
- LogEvent(Severity_Middle,LOG_EVT_UI_HIDELOCALVIDEO,"Agent send hide local video");
- LogEvent(Severity_Middle,LOG_EVT_UI_HIDEPERSONAREA,"Agent send Hide Person area");
- //}
- }
- else if (num.nValue == 1) //显示人形框
- {
- //LogEvent(Severity_Middle,LOG_EVT_UI_SHOWPERSONAREA,"Agent send Show Person area");
- //if((eMobilePadType == m_eDeviceType)||(ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
- //{
- LogEvent(Severity_Middle,LOG_EVT_UI_SHOWLOCALVIDEO,"Agent send show local video");
- LogEvent(Severity_Middle,LOG_EVT_UI_SHOWPERSONAREA,"Agent send Show Person area");
- //}
- }
- else
- {
- Dbg("recv control personarea sub_type error!");
- }
- }
- }
- else if (type == ACM_TYPE_VIDEOFREQ)
- {
- if (eMobilePadType == m_eDeviceType)
- {
- CFpsValue nFps;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- nFps.Serialize(buf);
- Dbg("adj up stream fps to %d",nFps.nValue);
- if((m_stVideoParam.nUpDynamicFps == 1)&&(nFps.nValue!=1))
- {
- GetFunction()->KillTimer(1);
- }
- else if (nFps.nValue==1)
- {
- //如果1帧每秒维持20秒,停止视频
- Dbg("start timer for up fps");
- GetFunction()->SetTimer(1, this, 20000);
- }
- m_stVideoParam.nUpDynamicFps = nFps.nValue;
- }
- else
- {
- Dbg("not mobile pad,ignore down message!");
- }
- }
- }
- ErrorCodeEnum GetLocalIP()
- {
- #ifdef RVC_OS_WIN
- char tmp[MAX_PATH] = { 0 };
- gethostname(tmp, sizeof(tmp));
- hostent* ent = gethostbyname(tmp);
- if (ent) {
- for (int i = 0; ent->h_addr_list[i]; ++i) {
- if (ent->h_addrtype == AF_INET) {
- struct in_addr* in = (struct in_addr*)ent->h_addr_list[i];
- char* p = inet_ntoa(*in);
- if (p[0] != '0')
- {
- if (strstr(p, "198.168.") == NULL)
- {
- strcpy(m_localip, p);
- Dbg("local ip == %s", m_localip);
- return Error_Succeed;
- }
- }
- }
- }
- }
- return Error_Unexpect;
- #else
- ErrorCodeEnum error = Error_Unexpect;
- int sockfd = -1;
- struct ifconf ifconf;
- struct ifreq* ifreq = NULL;
- char strbuf[MAX_PATH] = {0};
- ifconf.ifc_len = MAX_PATH;
- ifconf.ifc_buf = strbuf;
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
- Dbg("socket error");
- return error;
- }
- ioctl(sockfd, SIOCGIFCONF, &ifconf); //get all socket info
- ifreq = (struct ifreq*)ifconf.ifc_buf;
- for (int i = (ifconf.ifc_len / sizeof(struct ifreq)); i > 0; i--){
- if (ifreq->ifr_flags == AF_INET) { //for ipv4
- char* strIP = inet_ntoa(((struct sockaddr_in*) & (ifreq->ifr_addr))->sin_addr);
- Dbg("name =[%s], local addr = [%s]", ifreq->ifr_name, strIP);
- ifreq++;
- if (NULL != strIP){
- if (NULL == strstr(strIP, "198.168.") && NULL == strstr(strIP, "127.0.0.1"))
- {
- strcpy(m_localip, strIP);
- Dbg("local ip == %s", m_localip);
- error = Error_Succeed;
- break;
- }
- }
- }
- }
- return error;
- #endif // RVC_OS_WIN
- }
- //send DynamicFps
- void SendDynamicFps(int nFps)
- {
- if (eMobilePadType == m_eDeviceType)
- {
- ChannelService_Send_Info Info;
- Info.compress = false;
- Info.encrypt = false;
- Info.type = ACM_TYPE_VIDEOFREQ;
- Info.id = 0;
- Info.sub_type = ACM_VIDEOFREQ_DOWN;
- Info.data.Alloc(sizeof(int));
- SpBuffer buf;
- buf.OpenWrite();
- buf & nFps;
- Info.data = buf.ToBlob();
- m_pSipphoneChannel->Send(Info);
- Dbg("adj down stream fps to %d",nFps);
- }
- else
- {
- Dbg("not mobile pad,ignore up message!");
- }
-
- }
- //send audio device volume
- void SendAudioDeviceVolumn(int nDevice)
- {
- if (m_nSysCallType == 0)
- {
- ChannelService_Send_Info Info;
- Info.compress = false;
- Info.encrypt = false;
- Info.type = ACM_TYPE_DEVICE;
- Info.id = 0;
- void*keeper = NULL;
- if (nDevice == DEVICE_HANDFREE_OUT)
- {
- Info.sub_type = ACM_HANDFREE_OUTVOLUMN;
- keeper = m_pKeeperOut[DEV_HANDFREE];
- }
- else if(nDevice == DEVICE_PICKUP_OUT)
- {
- if(eStand2sType == m_eDeviceType)
- {
- Info.sub_type = ACM_PICKUP_OUTVOLUMN;
- keeper = m_pKeeperOut[DEV_PICKUP];
- }
- else //pad版屏蔽当前PICKUP音量发送
- {
- return;
- }
- }
- else if(nDevice == DEVICE_HANDFREE_IN)
- {
- Info.sub_type = ACM_HANDFREE_INVOLUMN;
- keeper = m_pKeeperIn[DEV_HANDFREE];
- }
- else if(nDevice == DEVICE_PICKUP_IN)
- {
- if(eStand2sType == m_eDeviceType)
- {
- Info.sub_type = ACM_PICKUP_INVOLUMN;
- keeper = m_pKeeperIn[DEV_PICKUP];
- }
- else //pad版屏蔽当前PICKUP音量发送
- {
- return;
- }
- }
- Info.data.Alloc(sizeof(int));
- SpBuffer buf;
- buf.OpenWrite();
- int nValue = 0;
- bool rslt = false;
- if (keeper)
- {
- rslt = get_audiodevice_volumn(keeper,&nValue);
- }
- if (rslt == true)
- {
- buf & nValue;
- Info.data = buf.ToBlob();
- m_pSipphoneChannel->Send(Info);
- Dbg("send cur Audio device %d,value = %d",nDevice,nValue);
- }
- else
- {
- Dbg("Get cur Audio device %d volume Fail!",nDevice);
- }
- }
- else
- {
- Dbg("cur call type cannot send pkt");
- }
- }
- virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- ErrorCodeEnum Error = __OnClose(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- }
- ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
- {
- LOG_FUNCTION();
- int i;
- if (m_pKeeperIn[DEV_HANDFREE]) {
- volume_keeper_destroy(m_pKeeperIn[DEV_HANDFREE]);
- m_pKeeperIn[DEV_HANDFREE] = NULL;
- }
- if (m_pKeeperOut[DEV_HANDFREE]) {
- volume_keeper_destroy(m_pKeeperOut[DEV_HANDFREE]);
- m_pKeeperOut[DEV_HANDFREE] = NULL;
- }
- if (m_pKeeperIn[DEV_PICKUP]) {
- volume_keeper_destroy(m_pKeeperIn[DEV_PICKUP]);
- m_pKeeperIn[DEV_PICKUP] = NULL;
- }
- if (m_pKeeperOut[DEV_PICKUP]) {
- volume_keeper_destroy(m_pKeeperOut[DEV_PICKUP]);
- m_pKeeperOut[DEV_PICKUP] = NULL;
- }
- CSmartPointer<IEntityFunction> Func = GetFunction();
- Func->UnregistSysVarEvent(SYSVAR_AGENTCAMERASWITCH);
- Func->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
- Func->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
- Func->UnregistSysVarEvent(SYSVAR_CALLTYPE);
-
- for (i = 0; i < m_arrListener.GetCount(); ++i) {
- Func->UnsubscribeLog(m_arrListener[i]);
- }
- m_arrListener.Clear();
- Dbg("__OnClose endpoint_destroy m_pEndpoint addr is %0x.",m_pEndpoint);
- endpoint_destroy(m_pEndpoint);
- m_pEndpoint = NULL;
- video_lib_deinit();
- audio_lib_deinit();
- endpoint_deinit_lib();
- return Error_Succeed;
- }
- /////////////////////////////////////////////////////////////////////
- #if 1
- virtual void OnPaused()
- {
- int rc;
- video_session_conf_t conf = {0};
- conf.bit_rate = 256*1024;
- conf.local_rtp_ip = htonl(INADDR_LOOPBACK);
- conf.local_rtp_port = 3000;
- conf.local_video_view_cx = 320;
- conf.local_video_view_cy = 240;
- conf.local_video_view_x = 0;
- conf.local_video_view_y = 0;
- conf.mtu = 1500;
- conf.remote_rtp_ip = htonl(INADDR_LOOPBACK);
- conf.remote_rtp_port = 3000;
- conf.remote_video_view_cx = 320;
- conf.remote_video_view_cy = 320;
- conf.remote_video_view_x = 0;
- conf.remote_video_view_y = 320;
- conf.video_quant = 3;
- conf.remote_video_width = 320;
- conf.remote_video_height = 320;
- conf.ref_active_camera = &m_stVideoParam.iActiveCamera;
- video_session_create(&conf, &video_session);
- video_session_start(video_session);
- }
- virtual void OnContinued()
- {
- video_session_stop(video_session);
- video_session_destroy(video_session);
- }
- #endif
- /////////////////////////////////////////////////////////////////////
- virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/)
- {
- LOG_FUNCTION();
- m_pCurrentSession = new CSIPPhoneSession(this);
- return m_pCurrentSession;
- }
- virtual bool IsService()const{return true;}
- virtual void OnTimeout(DWORD dwTimerID)
- {
- if (dwTimerID == 1)
- {
- //如果当前动态帧频不等于之前的帧频,发送当前帧频
- //if (g_nDynamicFps != m_nDownDynamicFps)
- //{
- // m_nDownDynamicFps = g_nDynamicFps;
- // SendDynamicFps(g_nDynamicFps);
- //}
- Dbg("stop up stream!");
- GetFunction()->KillTimer(1);
- m_stVideoParam.nUpDynamicFps = -1;
- }
- }
- bool IsCurrentSession(CServerSessionBase * pSession) { return m_pCurrentSession == pSession; }
- endpoint_t *GetEndpoint() { return m_pEndpoint; }
- ErrorCodeEnum InitEndpoint()
- {
- ErrorCodeEnum eCode = Error_Param;
- CSmartPointer<IEntityFunction> Func = GetFunction();
- Func->GetSystemStaticInfo(staticInfo);
-
- CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
- if (strUri.GetLength() > 0)
- {
- strcpy(conf.uri, strUri);
- conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
- conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
- m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
- if (!m_pEndpoint) {
- LOG_TRACE("create endpoint failed!");
- eCode = Error_Unexpect;
- }
- else{
- Dbg("__OnStart endpoint_create m_pEndpoint addr is %0x.", m_pEndpoint);
- eCode = Error_Succeed;
- }
- }
- else
- {
- LOG_TRACE("strUri length equals zero!");
- eCode = Error_Unexpect;
- }
- return eCode;
- }
- struct ChangeDevCommand
- {
- CSIPEntity *pEntity;
- int dev_type;
- };
- void change_dev(int dev_type)
- {
- Dbg("change_dev dev_type:%d", dev_type);
- if (m_pEndpoint) {
- Dbg("begin invoke endpoint change audio device!");
- endpoint_change_audio_dev(m_pEndpoint, dev_type);
- Dbg("end invoke endpoint change audio device!");
- }
- }
- static int __change_dev(void *arg)
- {
- ChangeDevCommand *pCmd = (ChangeDevCommand *)arg;
- pCmd->pEntity->change_dev(pCmd->dev_type);
- delete pCmd;
- return 0;
- }
- void SwitchHandFree()
- {
- LOG_FUNCTION();
- int rc = 0;
- ChangeDevCommand *pCmd = new ChangeDevCommand();
- pCmd->pEntity = this;
- pCmd->dev_type = DEV_HANDFREE;
- if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
- Dbg("endpoint invoke failed!");
- delete pCmd;
- }
- }
- void SwitchPickup()
- {
- LOG_FUNCTION();
- int rc = 0;
- ChangeDevCommand *pCmd = new ChangeDevCommand();
- pCmd->pEntity = this;
- pCmd->dev_type = DEV_PICKUP;
- if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
- Dbg("endpoint invoke failed!");
- delete pCmd;
- }
- }
- void SetState(int state)
- {
- m_state = state;
- }
- ErrorCodeEnum RealSelfCheck()
- {
- ErrorCodeEnum Error = Error_Succeed;
- if (m_pSelfcheckClient)
- {
- SelfCheckerService_RealCheck_Req req;
- req.name = GetEntityName();
- SelfCheckerService_RealCheck_Ans ans;
- DWORD Timeout = 500;
- Error = m_pSelfcheckClient->RealCheck(req,ans,Timeout);
- if (Error!=Error_Succeed)
- {
- Dbg("RealSelfcheck fail!");
- }
- else
- {
- Dbg("RealSelfcheck");
- }
- }
- return Error;
- }
- CSimpleStringA MakeUri(const char *terminal_id)
- {
- CSimpleStringA str;
- str = CSimpleStringA::Format("sip:%s@%s;transport=UDP", terminal_id, m_localip);
- return str;
- }
- void Handle_RecordVideoLocation_Info(const char* pszMessage)
- {
- if (NULL == pszMessage){
- return;
- }
- CSimpleStringA strMsg = pszMessage;
- if (strMsg.IsStartWith("ews|",true)){
- strMsg = strMsg.SubString(4,strMsg.GetLength()-4);
- }
- int lxPos,lyPos,lwidth,lheight;
- CSimpleStringA str;
- sscanf(strMsg.GetData(), "%d@%d@%d@%d@%d@%s", &lxPos, &lyPos, &lwidth, &lheight, &str);
- Dbg("start record preview local video param : (x=%d,y=%d,width=%d,height=%d).",lxPos,lyPos,lwidth,lheight);
- m_RecordVideoLocation.x = lxPos;
- m_RecordVideoLocation.y = lyPos;
- m_RecordVideoLocation.width = lwidth;
- m_RecordVideoLocation.height = lheight;
- }
- void Handle_AdjustVideoEchoEvent(const char* pszMessage)
- {
- if (NULL == pszMessage){
- return;
- }
- CSimpleStringA strMsg = pszMessage;
- if (strMsg.IsStartWith("ews|",true)){
- strMsg = strMsg.SubString(4,strMsg.GetLength()-4);
- }
- int lxPos,lyPos,lwidth,lheight;
- CSimpleStringA str;
- sscanf(strMsg.GetData(), "%d@%d@%d@%d@%d@%s", &lxPos, &lyPos, &lwidth, &lheight, &str);
- Dbg("begin adjust local video param : (x=%d,y=%d,width=%d,height=%d).",lxPos,lyPos,lwidth,lheight);
- if (DEFAULT_RECORD_VIDEO_WIDTH == lwidth && DEFAULT_RECORD_VIDEO_HEIGHT == lheight){
- m_stVideoParam.nWindowState = 0;
- }
- else if(SMALL_RECORD_VIDEO_WIDTH == lwidth && SMALL_RECORD_VIDEO_HEIGHT == lheight){
- m_stVideoParam.nWindowState = 5;
- }
- else{
- Dbg("not support width and height.");
- }
- m_RecordVideoLocation.x = lxPos;
- m_RecordVideoLocation.y = lyPos;
- m_RecordVideoLocation.width = lwidth;
- m_RecordVideoLocation.height = lheight;
- }
- private:
- ErrorCodeEnum LoadConfig(endpoint_conf_t *conf)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spRootConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spRootConfig);
- if (Error == Error_Succeed) {
- CSimpleStringA strHandFreeIn;
- CSimpleStringA strHandFreeOut;
- CSimpleStringA strPickupIn;
- CSimpleStringA strPickupOut;
- SpIniMappingTable table;
- table.AddEntryString("audio", "handfree_in_dev", strHandFreeIn, "$");
- table.AddEntryString("audio", "handfree_out_dev", strHandFreeOut, "$");
- table.AddEntryString("audio", "pickup_in_dev", strPickupIn, "$");
- table.AddEntryString("audio", "pickup_out_dev", strPickupOut, "$");
- table.AddEntryBoolean("audio", "pickup_out_agc", conf->audio_pickup_out_agc, false);
- table.AddEntryBoolean("audio", "pickup_in_agc", conf->audio_pickup_in_agc, false);
- table.AddEntryBoolean("audio", "handfree_in_agc", conf->audio_handfree_in_agc, false);
- table.AddEntryBoolean("audio", "handfree_out_agc", conf->audio_handfree_out_agc, false);
- table.AddEntryBoolean("audio", "pickup_out_ns", conf->audio_pickup_out_ns, false);
- table.AddEntryBoolean("audio", "pickup_in_ns", conf->audio_pickup_in_ns, false);
- table.AddEntryBoolean("audio", "handfree_in_ns", conf->audio_handfree_in_ns, false);
- table.AddEntryBoolean("audio", "handfree_out_ns", conf->audio_handfree_out_ns, false);
- table.AddEntryBoolean("audio", "pickup_aec", conf->audio_pickup_aec, false);
- table.AddEntryBoolean("audio", "handfree_aec", conf->audio_handfree_aec, false);
- table.AddEntryInt("audio", "handfree_in_volume", m_kept_volume_in[DEV_HANDFREE], 0);
- table.AddEntryInt("audio", "handfree_out_volume", m_kept_volume_out[DEV_HANDFREE], 0);
- table.AddEntryInt("audio", "pickup_in_volume", m_kept_volume_in[DEV_PICKUP], 0);
- table.AddEntryInt("audio", "pickup_out_volume", m_kept_volume_out[DEV_PICKUP], 0);
- table.AddEntryInt("video", "quant", conf->quant, 0);
- table.AddEntryInt("video", "mtu", conf->mtu, 0);
- Error = table.Load(spRootConfig);
- if (Error == Error_Succeed) {
- int id;
-
- id = capture_get_audio_device_id(true, strHandFreeIn);
- if (id == -1)
- {
- Dbg("audio device %s does not exist!", (LPCSTR)strHandFreeIn);
- Error = Error_Param;
- }
- strcpy(conf->audio_handfree_in_dev, strHandFreeIn);
-
- id = capture_get_audio_device_id(false, strHandFreeOut);
- if (id == -1)
- {
- Dbg("audio device %s does not exist!", (LPCSTR)strHandFreeOut);
- Error = Error_Param;
- }
- strcpy(conf->audio_handfree_out_dev, strHandFreeOut);
- id = capture_get_audio_device_id(true, strPickupIn);
- if (id == -1) {
- Dbg("audio device %s does not exist!", (LPCSTR)strPickupIn);
- Error = Error_Param;
- }
- strcpy(conf->audio_pickup_in_dev, strPickupIn);
- id = capture_get_audio_device_id(false, strPickupOut);
- if (id == -1) {
- Dbg("audio device %s does not exist!", (LPCSTR)strPickupOut);
- Error = Error_Param;
- }
- strcpy(conf->audio_pickup_out_dev, strPickupOut);
- conf->ref_active_camera = &m_stVideoParam.iActiveCamera;
- conf->ref_camera_switch = &m_stVideoParam.iCameraSwitch;
- conf->ref_window_state = &m_stVideoParam.nWindowState;
- conf->ref_active_img = &m_stVideoParam.bShowActiveImg;
- conf->ref_Is_ActiveInspect = &m_stVideoParam.bActiveInspect;
- conf->ref_camera_state = &m_stVideoParam.iCameraState;
- conf->ref_Is_showPersonArea = &m_stVideoParam.bShowPersonArea;
- conf->ref_Is_showRecordArea = &m_stVideoParam.bShowRecordArea;
- if (eMobilePadType == m_eDeviceType)
- {
- m_stVideoParam.nUpDynamicFps = 3;
- }
- else if ((ePadtype==m_eDeviceType)||(eDesk2SType==m_eDeviceType)||(eDesk1SType==m_eDeviceType)||(eDesk2SIntegratedType==m_eDeviceType))
- {
- m_stVideoParam.nUpDynamicFps = REC_COMMON_VIDEO_FPS_MOBILE;
- }
- else if(eStand2sType == m_eDeviceType)
- {
- m_stVideoParam.nUpDynamicFps = 0;
- }
- Dbg("init up dynamic fps to %d",m_stVideoParam.nUpDynamicFps);
- conf->ref_Up_Fps = &m_stVideoParam.nUpDynamicFps;
- if ((eMobilePadType == m_eDeviceType)||(ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType)||(eDesk1SType==m_eDeviceType)||(eDesk2SIntegratedType==m_eDeviceType))
- {
- conf->camera_count = 1;
- }
- else if(eStand2sType == m_eDeviceType)
- {
- conf->camera_count = 2;
- }
- //DecideCameraCount(conf->camera_count);
- DecideScreenCount(conf->screen_count);
- }
- }
- return Error;
- }
- //载入运行时配置
- ErrorCodeEnum LoadAudioRunConfig(int&nHandfreeout,int&nPickupout,int&nHandfreein,int&nPickupin)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
- if (Error == Error_Succeed)
- {
- SpIniMappingTable table;
- table.AddEntryInt("Audio", "handfree_out_volume", nHandfreeout, 0);
- table.AddEntryInt("Audio", "pickup_out_volume", nPickupout, 0);
- table.AddEntryInt("Audio", "handfree_in_volume", nHandfreein, 0);
- table.AddEntryInt("Audio", "pickup_in_volume", nPickupin, 0);
- Error = table.Load(spConfig);
- if (Error != Error_Succeed)
- {
- LOG_TRACE("[dbg] failed to load run config.");
- }
- }
- else
- {
- LOG_TRACE("[dbg] failed to open run config.");
- }
- return Error;
- }
- //保存运行时
- ErrorCodeEnum SaveAudioRunConfig(int nHandfreeout,int nPickupout,int nHandfreein,int nPickupin)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();;
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
- if (Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "handfree_out_volume", nHandfreeout);
- if(Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "pickup_out_volume", nPickupout);
- }
- else
- {
- Dbg("SaveAudioRunConfig handfree_out_volume fail!");
- return Error;
- }
- if(Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "handfree_in_volume", nHandfreein);
- }
- else
- {
- Dbg("SaveAudioRunConfig pickup_out_volume fail!");
- return Error;
- }
- if(Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "pickup_in_volume", nPickupin);
- }
- else
- {
- Dbg("SaveAudioRunConfig handfree_in_volume fail!");
- return Error;
- }
- if (Error != Error_Succeed)
- {
- Dbg("SaveAudioRunConfig pickup_in_volume fail!");
- return Error;
- }
- }
- else
- {
- Dbg("SaveAudioRunConfig is fail , open sipphone.ini fail!");
- }
- return Error;
- }
- // we use root.ini Video section config to decide camera count
- ErrorCodeEnum DecideCameraCount(int &nCount)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spConfig);
- if (Error == Error_Succeed) {
- CSimpleStringA strVideoEnv;
- CSimpleStringA strVideoOpt;
- SpIniMappingTable table;
- nCount = 0;
- table.AddEntryString("Video", "EnvCamera", strVideoEnv, "$");
- table.AddEntryString("Video", "OptCamera", strVideoOpt, "$");
- Error = table.Load(spConfig);
- if (Error == Error_Succeed) {
- if (strVideoEnv.GetLength() > 1)
- nCount++;
- if (strVideoOpt.GetLength() > 1)
- nCount++;
- }
- }
- return Error;
- }
- ErrorCodeEnum DecideScreenCount(int &nCount)
- {
- CSystemStaticInfo Info;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- ErrorCodeEnum Error = spFunction->GetSystemStaticInfo(Info);
- if (Error == Error_Succeed)
- {
- nCount = (int)Info.eScreen;
- }
- return Error;
- }
- DeviceTypeEnum RvcGetDeviceType()
- {
- DeviceTypeEnum eType = eStand2sType;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSystemStaticInfo stStaticinfo;
- spFunction->GetSystemStaticInfo(stStaticinfo);
- if (stricmp(stStaticinfo.strMachineType, "RVC.PAD") == 0) {
- if (stricmp(stStaticinfo.strSite, "CMB.FLB") == 0) {
- eType = eMobilePadType;
- }
- else {
- eType = ePadtype;
- }
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk2S") == 0) {
- eType = eDesk2SType;
- WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
- WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
- Dbg("MachineVersion is %d.%d", nMajor, nMinor);
- if (2 == nMajor) {
- eType = eDesk2SIntegratedType;
- }
- }
- else if (stricmp(stStaticinfo.strMachineType, "RPM.Stand1S") == 0) {
- eType = eRpm1sType;
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk1S") == 0) {
- eType = eDesk1SType;
- }
- else {
- eType = eStand2sType;
- }
- if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
- LOG_TRACE("device type is %s.", Device_Type_Table[eType]);
- }
- return eType;
- }
- public:
- int m_kept_volume_in[2];
- int m_kept_volume_out[2];
- void *m_pKeeperIn[2];
- void *m_pKeeperOut[2];
- //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;
- };
- //
- // CSIPPhoneSession
- //
- void CSIPPhoneSession::OnClose( ErrorCodeEnum eErrorCode )
- {
- LOG_FUNCTION();
- }
- void CSIPPhoneSession::Handle_MakeCall( SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx )
- {
- LOG_FUNCTION();
- LOG_TRACE("make call [%s]", (LPCSTR)ctx->Req.call_uri);
- int rc;
- MakeCallCommand *cmd = new MakeCallCommand();
- cmd->pSIPPhoneSession = this;
- cmd->strUri = ctx->Req.call_uri;
- ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
- if (m_pEntity->m_pEndpoint)
- {
- Dbg("Handle_MakeCall endpoint_destroy m_pEndpoint addr is %0x.",m_pEntity->m_pEndpoint);
- endpoint_destroy(m_pEntity->m_pEndpoint);
- m_pEntity->m_pEndpoint = NULL;
- }
- CSimpleStringA strUri = m_pEntity->MakeUri(m_pEntity->staticInfo.strTerminalID);
- if (strUri.GetLength() > 0)
- {
- strcpy(m_pEntity->conf.uri, strUri);
- m_pEntity->conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
- m_pEntity->conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
- m_pEntity->m_pEndpoint = endpoint_create(m_pEntity, &m_pEntity->conf,m_pEntity->m_iPickupPhoneState);
- if (!m_pEntity->m_pEndpoint)
- {
- LOG_TRACE("create endpoint failed!");
- }
- else{
- Dbg("Handle_MakeCall endpoint_create m_pEndpoint addr is %0x.", m_pEntity->m_pEndpoint);
- }
- }
- else
- {
- LOG_TRACE("strUri length equals zero!");
- }
- ErrorCodeEnum Error = m_pEntity->GetLocalIP();
- if (Error != 0)
- {
- LOG_TRACE("get local ip failed!");
- }
- if (m_pEntity->m_eDeviceType == eMobilePadType)
- {
- m_pEntity->m_stVideoParam.nUpDynamicFps = 3;
- }
- ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
- endpoint_invoke(m_pEntity->GetEndpoint(), &__make_call, cmd, &rc);
- ctx->Answer((ErrorCodeEnum)rc);
- }
- void CSIPPhoneSession::Handle_HangupCall( SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx )
- {
- LOG_FUNCTION();
- int rc;
- HangupCallCommand *cmd = new HangupCallCommand();
- cmd->pSIPPhoneSession = this;
- cmd->strSession_num = ctx->Req.session_num;
- cmd->strBranch_server_ip = ctx->Req.branch_server_ip;
- cmd->iBranch_server_port = ctx->Req.branch_server_port;
- if (m_pEntity->GetEndpoint())
- {
- endpoint_invoke(m_pEntity->GetEndpoint(), &__hangup_call, cmd, &rc);
- }
- ctx->Answer((ErrorCodeEnum)rc);
- }
- void CSIPPhoneSession::Handle_ReleaseCall( SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx )
- {
- LOG_FUNCTION();
- int rc = Error_Succeed;
- g_IsExternalTerminalted = TRUE;
- endpoint_invoke(m_pEntity->GetEndpoint(), &__release_call, this, &rc);
- Dbg("Handle_ReleaseCall endpoint_destroy m_pEndpoint addr is %0x.",m_pEntity->m_pEndpoint);
- endpoint_destroy(m_pEntity->m_pEndpoint);
- m_pEntity->m_pEndpoint = NULL;
- ctx->Answer((ErrorCodeEnum)rc);
- }
- void CSIPPhoneSession::Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx)
- {
- LOG_FUNCTION();
- Dbg("SetCallingParam CallType = %d", ctx->Info.CallType);
- m_pEntity->m_nCallType = (CallingTypeEnum)ctx->Info.CallType;
- }
- void CSIPPhoneSession::Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->m_SipErrorCode = Error_InvalidState;
- m_pEntity->RealSelfCheck();
- }
- void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx )
- {
- LOG_FUNCTION();
- int rc;
- ControlVideoCommand *pCmd = new ControlVideoCommand();
- pCmd->pSIPPhoneSession = this;
- pCmd->start = TRUE;
- pCmd->local_hwd_move = 0;
- pCmd->remote_hwd_move = 0;
- if(!(ctx->Info.remote_view_x||ctx->Info.remote_view_y||ctx->Info.remote_view_cx||ctx->Info.remote_view_cy||ctx->Info.remote_width||ctx->Info.remote_height))
- {
- m_IsLocalPlay= TRUE;
- m_VideoWindowPlayType = eOnly_Local_Video;
- Dbg("LocalPlay Mod");
- }
- else
- {
- m_IsLocalPlay= FALSE;
- m_VideoWindowPlayType = eOnline_Mode_Video;
- Dbg("OnlinePlay Mod");
- if (0 == ctx->Info.remote_port){
- m_VideoWindowPlayType = eBoth_Local_Remote_Video;
- m_pEntity->m_nCallType = NORMAL_CALLTYPE;
- Dbg("both local and remote mode.");
- if (NULL == m_pEntity->GetEndpoint())
- {
- Dbg("m_pEndpoint has destroy, now new init it.");
- m_pEntity->InitEndpoint();
- }
- }
- }
- pCmd->local_ip = inet_addr(m_pEntity->m_localip);
- pCmd->local_port = REC_COMMON_VIDEO_PORT;
- pCmd->remote_ip = inet_addr(ctx->Info.remote_ip);
- pCmd->remote_port = ctx->Info.remote_port;
- pCmd->local_view_x = ctx->Info.local_view_x;
- pCmd->local_view_y = ctx->Info.local_view_y;
- pCmd->local_view_cx = ctx->Info.local_view_cx;
- pCmd->local_view_cy = ctx->Info.local_view_cy;
- pCmd->remote_view_x = ctx->Info.remote_view_x;
- pCmd->remote_view_y = ctx->Info.remote_view_y;
- pCmd->remote_view_cx = ctx->Info.remote_view_cx;
- pCmd->remote_view_cy = ctx->Info.remote_view_cy;
- pCmd->remote_width = ctx->Info.remote_width;
- pCmd->remote_height = ctx->Info.remote_height;
- pCmd->local_hwd_move = ctx->Info.local_hwd_move;
- pCmd->remote_hwd_move = ctx->Info.remote_hwd_move;
- //初始化窗口参数
- //m_pEntity->m_stVideoParam.nWindowState = 0;
- //m_pEntity->GetFunction()->SetTimer(1, m_pEntity, 1000);
- //m_pEntity->m_nDownDynamicFps = ctx->Info.remote_fps;
- //g_nDynamicFps = ctx->Info.remote_fps;
- //g_nSysFps = ctx->Info.remote_fps;
- //g_nLastRecFrameTime = GetTickCount();
- endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
- }
- void CSIPPhoneSession::Handle_StopVideo( SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx )
- {
- LOG_FUNCTION();
- int rc;
- ControlVideoCommand *pCmd = new ControlVideoCommand();
- pCmd->pSIPPhoneSession = this;
- pCmd->start = FALSE;
- m_pEntity->GetFunction()->KillTimer(1);
- if (NULL != m_pEntity->GetEndpoint()){
- endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
- }
- else{
- endpoint_call_stop_double_record_broadcast_video();
- }
-
- m_pEntity->m_stVideoParam.bShowActiveImg = 0;
- m_pEntity->m_stVideoParam.bActiveInspect = 0;
- //初始化窗口参数
- m_pEntity->m_stVideoParam.nWindowState = 0;
- }
- void CSIPPhoneSession::Handle_BeginState( SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx )
- {
- LOG_FUNCTION();
- m_spCallbackContext = ctx;
- }
- void CSIPPhoneSession::Handle_EndState( SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx )
- {
- LOG_FUNCTION();
- SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer tmp_ctx = m_spCallbackContext;
- m_spCallbackContext.Clear();
- }
- void CSIPPhoneSession::hangup_call(HangupCallCommand* cmd)
- {
- LOG_FUNCTION();
- if (m_pCall) {
- Dbg("normal hangup.");
- endpoint_call_hangup(m_pCall);
- }
- else
- {
- if (m_pEntity && m_pEntity->m_nCallType == MOBILETOPAD_CALLTYPE){
- //分布式呼叫主动挂断场景
- Dbg("distribute hangup, without pickup");
- if (cmd){
- const char* pserver = cmd->strBranch_server_ip.GetData();
- const char* pcallnum = cmd->strSession_num.GetData();
- if (pcallnum && pserver){
- endpoint_distribute_call_info_t* tinfo = (endpoint_distribute_call_info_t*)malloc(sizeof(endpoint_distribute_call_info_t));
- if (tinfo){
- memset(tinfo, 0, sizeof(endpoint_distribute_call_info_t));
- memcpy(tinfo->server_ip, pserver, strlen(pserver));
- memcpy(tinfo->call_name, pcallnum, strlen(pcallnum));
- tinfo->etype = INS_HANGUP;
- tinfo->server_port = cmd->iBranch_server_port;
- endpoint_distribute_hangup(tinfo);
- free(tinfo);
- tinfo = NULL;
- }
- }
- }
- LogEvent(Severity_Middle,LOG_EVT_DISTRIBUTE_SIPPHONE_IDLE,"SIPPhone to idle.");
- LogEvent(Severity_Middle,LOG_EVT_DISTRIBUTE_ASSISTANTCHANNEL_IDLE,"AssistantChannel to idle.");
- }
- }
- }
- void CSIPPhoneSession::release_call()
- {
- if (m_pCall)
- {
- Terminatedcall(m_pCall);
- }
- }
- void CSIPPhoneSession::on_call_state(int state, const char *state_desc, const char *phrase)
- {
- LOG_FUNCTION();
- if (m_spCallbackContext != NULL)
- {
- LOG_TRACE("on_call_state message state = %d, status=%s, phrase=%s!", state, state_desc, phrase);
- PhoneService_PhoneState_Info Info;
- Info.state = state;
- Info.status = CSimpleStringA::Format("%s,%s", state_desc, phrase);
- m_spCallbackContext->SendMessage(Info);
- Dbg("%s:%d", __FUNCTION__, __LINE__);
- }
- if (state == TERMINATED)
- {
- Dbg("%s:%d", __FUNCTION__, __LINE__);
- if (m_pCall)
- {
- Dbg("%s:%d", __FUNCTION__, __LINE__);
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- }
- }
- Dbg("%s:%d", __FUNCTION__, __LINE__);
- m_pEntity->SetState(state);
- Dbg("%s:%d", __FUNCTION__, __LINE__);
- }
- int CSIPPhoneSession::make_call( const char *remote_uri )
- {
- if (m_pCall)
- {
- LOG_TRACE("call duplicated! and endpoint destroy old call.");
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- //return Error_Duplication;
- }
- //else
- {
- endpoint_call_callback_t cb = {0};
- cb.on_call_state = &__on_call_state;
- cb.user_data = this;
- m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), remote_uri, m_pEntity->m_localip,m_pEntity->m_eDeviceType,m_pEntity->m_nCallType,&cb);
- if (m_pCall)
- {
- g_IsExternalTerminalted = FALSE;
- Dbg("g_IsExternalTerminalted = FALSE");
- LOG_TRACE("create call endpoint ok!");
- if (endpoint_call_start(m_pCall) == 0)
- {
- LOG_TRACE("start call ok!");
- return Error_Succeed;
- }
- else
- {
- LOG_TRACE("start call failed! and endpoint destroy call.");
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- return Error_Unexpect;
- }
- }
- else
- {
- g_IsExternalTerminalted = TRUE;
- Dbg("g_IsExternalTerminalted = TRUE");
- LOG_TRACE("create call endpoint failed!");
- m_pEntity->m_SipErrorCode = Error_InvalidState;
- m_pEntity->RealSelfCheck();
- return Error_Unexpect;
- }
- }
- }
- void CSIPPhoneSession::control_video( ControlVideoCommand *pCmd )
- {
- LOG_FUNCTION();
- if (m_pCall)
- {
- if (pCmd->start)
- {
- endpoint_call_start_video(m_pCall,
- pCmd->remote_ip, pCmd->remote_port,
- pCmd->local_ip, pCmd->local_port,
- pCmd->remote_width, pCmd->remote_height,
- pCmd->local_view_x, pCmd->local_view_y, pCmd->local_view_cx, pCmd->local_view_cy,
- pCmd->remote_view_x, pCmd->remote_view_y, pCmd->remote_view_cx, pCmd->remote_view_cy,
- pCmd->local_hwd_move, pCmd->remote_hwd_move, &m_cb_video_box_move);
- }
- else
- {
- //双录第一阶段结束录像,销毁call资源
- if ((eOnly_Local_Video == m_VideoWindowPlayType) || (eBoth_Local_Remote_Video == m_VideoWindowPlayType && m_pEntity->m_nCallType != DOUBLERECORD_CALLTYPE ))
- {
- Dbg("stop record play.");
- local_play_stop_video(m_pCall);
- m_IsLocalPlay = FALSE;
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- }
- else
- {
- endpoint_call_stop_video(m_pCall);
- }
- }
- }
- else
- {
- if (pCmd->start)
- {
- endpoint_call_callback_t cb = {0};
- cb.on_call_state = &__on_call_state;
- cb.user_data = this;
- m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), "test",m_pEntity->m_localip,m_pEntity->m_eDeviceType,m_pEntity->m_nCallType, &cb);
-
- if (eOnly_Local_Video == m_VideoWindowPlayType){
- Dbg("start local play mode record.");
- local_play_start_video(m_pCall,pCmd->local_view_x, pCmd->local_view_y, pCmd->local_view_cx, pCmd->local_view_cy, pCmd->local_hwd_move, &m_cb_video_box_move);
- }
- else if (eBoth_Local_Remote_Video == m_VideoWindowPlayType){
- Dbg("start local and remote video play mode record.");
- local_remote_show_video(m_pCall,pCmd->local_view_x, pCmd->local_view_y, pCmd->local_view_cx, pCmd->local_view_cy,pCmd->remote_view_x, pCmd->remote_view_y, pCmd->remote_view_cx, pCmd->remote_view_cy, pCmd->local_hwd_move, pCmd->remote_hwd_move,&m_cb_video_box_move);
- }
- }
- else{
- Dbg("record call remote agent timeout, close video session.");
- endpoint_call_stop_double_record_broadcast_video();
- }
- }
- }
- int CSIPPhoneSession::on_video_box_move(int imessageType, int ivideotype, int ileft, int ibottom)
- {
- int iret = -1;
- if (0 == imessageType){
- VideoBoxStartMove evt;
- evt.videoboxflag = ivideotype;
- evt.leftlowerx = ileft;
- evt.leftlowery = ibottom;
- iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStartMove), SP_MSG_SIG_OF(VideoBoxStartMove), evt);
- Dbg("VideoBoxStartMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
- }
- else{
- VideoBoxStopMove evt;
- evt.videoboxflag = ivideotype;
- evt.leftlowerx = ileft;
- evt.leftlowery = ibottom;
- iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStopMove), SP_MSG_SIG_OF(VideoBoxStopMove), evt);
- Dbg("VideoBoxStopMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
- }
- return iret;
- }
- ChannelSipphoneClient::ChannelSipphoneClient( CSIPEntity *pEntity ) : ChannelService_ClientBase(pEntity)
- {
- }
- void ChannelSipphoneClient::OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData)
- {
- if (Error == Error_Succeed)
- {
- CSIPEntity *pEntity = static_cast<CSIPEntity*>(m_pEntityBase);
- if (Msg.state == eChannelState_Connected)
- {
- if (pEntity->m_pKeeperIn[DEV_HANDFREE])
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
- }
- if (pEntity->m_pKeeperOut[DEV_HANDFREE])
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
- }
- if (pEntity->m_pKeeperOut[DEV_PICKUP])
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
- }
- if (pEntity->m_pKeeperIn[DEV_PICKUP])
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
- }
- }
- //else if (Msg.state == eChannelState_Idle)
- //{
- // if (pEntity->m_kept_volume_out[DEV_PICKUP])
- // {
- // pEntity->ChangeKeeperVolumn(pEntity->m_pKeeperOut[DEV_PICKUP],pEntity->m_kept_volume_out[DEV_PICKUP],DEV_PICKUP);
- // }
- // if (pEntity->m_kept_volume_out[DEV_HANDFREE])
- // {
- // pEntity->ChangeKeeperVolumn(pEntity->m_pKeeperOut[DEV_HANDFREE],pEntity->m_kept_volume_out[DEV_HANDFREE],DEV_HANDFREE);
- // }
- //}
- }
- }
- void ChannelSipphoneClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
- {
- LOG_FUNCTION();
- if (Error == Error_Succeed)
- {
- CSIPEntity *pEntity = static_cast<CSIPEntity*>(m_pEntityBase);
- pEntity->OnReceivePkt(Msg.type,Msg.sub_type, (const char*)Msg.data.m_pData, Msg.data.m_iLength);
- }
- }
- SelfChekerClient::SelfChekerClient( CSIPEntity *pEntity ) : SelfCheckerService_ClientBase(pEntity)
- {
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CSIPEntity)
- SP_END_ENTITY_MAP()
|