123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360 |
- #include "stdafx.h"
- #include "mod_sipphone.h"
- #include "y2k_time.h"
- #include "../mod_agentip/sysvar.h"
- #include "../mod_facetracking/sysvar.h"
- #include "../mod_interactivecontrol/Event.h"
- #include "../mod_mediacontroller/Event.h"
- #include "sockutil.h"
- #include "rvc_media_common.h"
- #include "audio_session.h"
- #include "video_session.h"
- #include "../mod_counterconnector/Event.h"
- #include "../mod_evtconverter/Event.h"
- #define EVT_CONVERTER "EventConverter"
- #define DEVICE_HANDFREE_OUT 0
- #define DEVICE_PICKUP_OUT 1
- #define DEVICE_HANDFREE_IN 2
- #define DEVICE_PICKUP_IN 3
- #ifndef RVC_VIDEO_FRESH_TIME
- #define RVC_VIDEO_FRESH_TIME 50
- #endif // !RVC_VIDEO_FRESH_TIME
- #ifndef RVC_MAX_VIDEO_FRESH_TIME
- #define RVC_MAX_VIDEO_FRESH_TIME 200
- #endif // !RVC_MAX_VIDEO_FRESH_TIME
- #ifndef RVC_MIN_VIDEO_FRESH_TIME
- #define RVC_MIN_VIDEO_FRESH_TIME 1
- #endif // !RVC_MAX_VIDEO_FRESH_TIME
- extern bool g_IsExternalTerminalted;
- 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)
- {
- 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_t *cmd = (MakeCallCommand_t*)user_data;
- int rc = cmd->pSIPPhoneSession->make_call(cmd);
- delete cmd;
- return rc;
- }
- static int __hangup_call(void *user_data)
- {
- HangupCallCommand_t *cmd = (HangupCallCommand_t*)(user_data);
- cmd->pSIPPhoneSession->hangup_call();
- delete cmd;
- return 0;
- }
- static int __control_video(void *arg)
- {
- ControlVideoCommand_t* pCmd = (ControlVideoCommand_t*)(arg);
- pCmd->pSIPPhoneSession->control_video(pCmd);
- delete pCmd;
- return 0;
- }
- #ifdef RVC_OS_WIN
- #else
- static int __video_render(void* arg)
- {
- VideoRenderCommand_t* pCmd = (VideoRenderCommand_t*)(arg);
- pCmd->pSIPPhoneSession->video_render(pCmd);
- delete pCmd;
- return 0;
- }
- #endif
- static int __release_call(void *user_data)
- {
- CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
- pThis->release_call();
- pThis->on_call_state(TERMINATED,"STATE:terminated","bye bye");
- return 0;
- }
- static void __audiomgrlog(void* user_data, const char* fmt, va_list arg)
- {
- int n = rvc_vsnprintf(NULL, 0, fmt, arg);
- if (n >= 512) {
- char* buf = (char*)malloc((size_t)(n + 1));
- rvc_vsnprintf(buf, n + 1, fmt, arg);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", buf);
- free(buf);
- }
- else {
- char strlog[512] = { 0 };
- rvc_vsnprintf(strlog, 512, fmt, arg);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", strlog);
- }
- }
- static void __video_render_log(render_loglevel elevel, void* user_data, const char* fmt, va_list arg)
- {
- int n = rvc_vsnprintf(NULL, 0, fmt, arg);
- if (n >= MAX_PATH) {
- char* buf = (char*)malloc((size_t)(n + 1));
- rvc_vsnprintf(buf, n + 1, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", buf);
- free(buf);
- }
- else {
- char strlog[MAX_PATH] = { 0 };
- rvc_vsnprintf(strlog, MAX_PATH, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", strlog);
- }
- }
- #ifdef RVC_OS_WIN
- #else
- static int __on_stop_remote_video_render_callback(void* user_data)
- {
- int iret = -1;
- CSIPEntity* pThis = static_cast<CSIPEntity*>(user_data);
- if (NULL != pThis->m_render) {
- if (pThis->m_render->remote_render_threadid > 0) {
- iret = rvc_stop_remote_video_render(pThis->m_render);
- }
- }
- return iret;
- }
- static int __remote_video_render_callback(void* videoframe, void* user_data)
- {
- CSIPEntity* pThis = static_cast<CSIPEntity*>(user_data);
- return rvc_remote_video_render(pThis->m_render, videoframe);
- }
- #endif
- static int __on_window_type_callback(void* user_data)
- {
- CSIPEntity* pThis = static_cast<CSIPEntity*>(user_data);
- return pThis->m_stVideoParam.bShowPersonArea;
- }
- static CSimpleStringA generateAudioDspFlags(endpoint_audiodsp_config_t conf)
- {
- int ipickup_in_agc = 0;
- int ipickup_out_agc = 0;
- int ihandfree_in_agc = 0;
- int ihandfree_out_agc = 0;
- int ipickup_in_ns = 0;
- int ipickup_out_ns = 0;
- int ihandfree_in_ns = 0;
- int ihandfree_out_ns = 0;
- int ipickup_aec = 0;
- int ihandfree_aec = 0;
- conf.audio_pickup_in_agc ? ipickup_in_agc = 1 : ipickup_in_agc = 0;
- conf.audio_pickup_out_agc ? ipickup_out_agc = 1 : ipickup_out_agc = 0;
- conf.audio_handfree_in_agc ? ihandfree_in_agc = 1 : ihandfree_in_agc = 0;
- conf.audio_handfree_out_agc ? ihandfree_out_agc = 1 : ihandfree_out_agc = 0;
- conf.audio_pickup_in_ns ? ipickup_in_ns = 1 : ipickup_in_ns = 0;
- conf.audio_pickup_out_ns ? ipickup_out_ns = 1 : ipickup_out_ns = 0;
- conf.audio_handfree_in_ns ? ihandfree_in_ns = 1 : ihandfree_in_ns = 0;
- conf.audio_handfree_out_ns ? ihandfree_out_ns = 1 : ihandfree_out_ns = 0;
- conf.audio_pickup_aec ? ipickup_aec = 1 : ipickup_aec = 0;
- conf.audio_handfree_aec ? ihandfree_aec = 1 : ihandfree_aec = 0;
- return CSimpleStringA::Format("{\"handfree_in_agc\":\"%d\",\"handfree_out_agc\":\"%d\",\"pickup_in_agc\":\"%d\",\"pickup_out_agc\":\"%d\",\"handfree_in_ns\":\"%d\",\"handfree_out_ns\":\"%d\",\"pickup_in_ns\":\"%d\",\"pickup_out_ns\":\"%d\",\"handfree_aec\":\"%d\",\"pickup_aec\":\"%d\"}",
- ihandfree_in_agc, ihandfree_out_agc, ipickup_in_agc, ipickup_out_agc,
- ihandfree_in_ns, ihandfree_out_ns, ipickup_in_ns, ipickup_out_ns,
- ihandfree_aec, ipickup_aec);
- }
- static int countnum(uint32_t unum)
- {
- int icount = 0;
- while (unum){
- unum &= (unum - 1);
- icount++;
- }
- return icount;
- }
- static bool IsBothSoundCardError(uint32_t unum)
- {
- bool bRet = false;
- bool bHandfreeError = false;
- bool bPickUpError = false;
- if (unum & RVC_AUDIO_HANDFREEIN_ERROR || unum & RVC_AUDIO_HANDFREEOUT_ERROR) {
- bHandfreeError = true;
- }
- if (unum & RVC_AUDIO_PICKUPIN_ERROR || unum & RVC_AUDIO_PICKUPOUT_ERROR) {
- bPickUpError = true;
- }
- if (bHandfreeError && bPickUpError) {
- bRet = true;
- }
- return bRet;
- }
- static int tovalidwidth(int iwidth)
- {
- if (0 == iwidth % 4) {
- return iwidth;
- }
- else {
- return ((iwidth + 4) / 4) * 4;
- }
- }
- CSIPEntity::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;
- #ifdef RVC_OS_WIN
- m_pKeeperIn[0] = m_pKeeperIn[1] = NULL;
- m_pKeeperOut[0] = m_pKeeperOut[1] = NULL;
- m_eVideoRenderType = eGDI;
- m_bAudioMgrInited = false;
- #endif
- m_ilocalvideo_freshtime = RVC_VIDEO_FRESH_TIME;
- m_iremotevideo_freshtime = RVC_VIDEO_FRESH_TIME;
- m_render = NULL;
- m_SipErrorCode = Error_Succeed;
- m_pAudioMgr = NULL;
- m_pSipphoneChannel = NULL;
- memset((void*)&m_stVideoParam,0,sizeof(stVideoParam));
- m_bConnectedAssist = false;
- m_strStartTime = RVC_START_TIME;
- m_strEndTime = RVC_END_TIME;
- m_itervalTime = RVC_INTERVAL_TIME;
- m_bStopAutoRestart = false;
- m_nCallType = NORMAL_CALLTYPE;
- memset(m_localip, 0, RVC_MAX_IP_LEN);
- m_bFirstLaunched = false;
- m_pEndpoint = NULL;
- m_bMessageBox = false;
- m_bIsCameraRender = false;
- }
- void CSIPEntity::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)
- {
- switch (dwUserCode)
- {
- case LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS:
- {
- Sleep(810);
- if (m_pSipphoneChannel != NULL){
- m_bConnectedAssist = false;
- m_pSipphoneChannel->GetFunction()->CloseSession();
- #ifdef RVC_OS_WIN
- m_pSipphoneChannel->SafeDelete();
- #endif
- m_pSipphoneChannel = NULL;
- }
- if (Error_Succeed == ConnectAssistChannel()) {
- m_bConnectedAssist = true;
- }
- else {
- GetFunction()->SetTimer(2, this, 3200);
- }
- }
- 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;
- }
- if (old_state != m_iPickupPhoneState)
- {
- if (m_iPickupPhoneState == ePickupMicrophoneState_On)
- {
- SwitchPickup();
- }
- else
- {
- SwitchHandFree();
- }
- }
- }
- break;
- case LOG_EVT_ENTER_ACM_FLOW:
- {
- m_stVideoParam.nWindowState = 1;
- }
- break;
- case LOG_EVT_EXIT_ACM_FLOW:
- {
- if(m_stVideoParam.nWindowState == 1)
- {
- m_stVideoParam.nWindowState = 0;
- }
- }
- break;
- case LOG_EVT_UI_HIDEONLINEVIDEO:
- {
- m_stVideoParam.nWindowState = 2;
- #ifdef RVC_OS_LINUX
- HideBothVideo();
- #endif
- }
- break;
- case LOG_EVT_UI_SHOWONLINEVIDEO:
- {
- if (m_stVideoParam.nWindowState == 2)
- {
- m_stVideoParam.nWindowState = 3;
- #ifdef RVC_OS_LINUX
- ShowBothVideo();
- #endif
- }
- }
- break;
- case LOG_EVT_UI_STARTREMOTERECORD:
- {
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_UI_STARTREMOTERECORD event.");
- }
- break;
- case LOG_EVT_UI_STOPREMOTERECORD:
- {
- if (m_stVideoParam.bShowRecordArea){
- m_stVideoParam.bShowRecordArea = 0;
- }
- #ifdef RVC_OS_LINUX
- rvc_stop_video_render(m_render);
- #endif
- }
- break;
- case LOG_EVT_UI_RETURNMENU:
- {
- }
- break;
- case LOG_EVT_UI_SHOWLOCALVIDEO:
- {
- if (m_stVideoParam.nWindowState == 4)
- {
- m_stVideoParam.nWindowState = 3;
- #ifdef RVC_OS_LINUX
- ShowLocalVideo();
- #endif
- }
- }
- break;
- case LOG_EVT_UI_HIDELOCALVIDEO:
- {
- m_stVideoParam.nWindowState = 4;
- #ifdef RVC_OS_LINUX
- HideLocalVideo();
- #endif
- }
- break;
- case LOG_EVT_UI_HIDEPERSONAREA:
- {
- m_stVideoParam.bShowPersonArea = 0;
- }
- break;
- case LOG_EVT_UI_SHOWPERSONAREA:
- {
- m_stVideoParam.bShowPersonArea = 1;
- }
- break;
- case LOG_EVT_UI_STARTCAMERACAPTURE:
- {
- #ifdef RVC_OS_WIN
- #else
- int local_view_x = 0;
- int local_view_y = 0;
- int local_view_cx = 0;
- int local_view_cy = 0;
- char str[256] = {0};
- int isecond = 0;
- sscanf(pszMessage, "%d@%d@%d@%d@%d@%s", &local_view_x, &local_view_y, &local_view_cx, &local_view_cy, &isecond, str);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local_view_x = %d, local_view_y = %d, local_view_cx = %d, local_view_cy = %d.", local_view_x, local_view_y, local_view_cx, local_view_cy);
- StartCameraRender(0, local_view_x, local_view_y, local_view_cx, local_view_cy);
- #endif
- }
- break;
- case LOG_EVT_UI_STOPCAMERACAPTURE:
- {
- StopCameraRender();
- }
- break;
- default:
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown dwUserCode = 0x%08x.",dwUserCode);
- }
- break;
- }
- }
- void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName)
- {
- if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 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)
- {
- if (pszValue[0] == 'E')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if (pszValue[0] == 'O')
- {
- m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("warning: unknown ActiveTrackingCamera value!");
- }
- }
- else if (_stricmp(pszKey, SYSVAR_AGENTCAMERASWITCH) == 0)
- {
- if(pszValue[0] == 'E')
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
- }
- else if(pszValue[0] == 'O')
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
- }
- else if(pszValue[0] == 'A')
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- }
- }
- else if (_stricmp(pszKey, "UIState") == 0)
- {
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UIState %s -> %s.", pszOldValue, pszValue);
- if (pszOldValue[0] == 'X' && pszValue[0] == 'M')
- {
- if (false == m_bFirstLaunched) {
- m_bFirstLaunched = true;
- }
- }
- }
- else if (_stricmp(pszKey, SYSVAR_CALLSTATE) == 0) {
- HandleCheckAudioDevice(pszValue);
- }
- }
-
- void CSIPEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- if (Test_ShakeHand == eTestType)
- {
- pTransactionContext->SendAnswer(m_SipErrorCode);
- }
- }
- void CSIPEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- long lstarttime = SP::Module::Comm::RVCGetTickCount();
- ErrorCodeEnum Error = __OnStart(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- long lcosttime = SP::Module::Comm::RVCGetTickCount() - lstarttime;
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTING_COST, CSimpleStringA::Format("sipphone entity starting cost time is %dms.", lcosttime));
- }
- void CSIPEntity::OnStarted()
- {
- ErrorCodeEnum Error = Error_Succeed;
- m_pHMClient = new HealthManagerService_ClientBase(this);
- Error = m_pHMClient->Connect();
- if (Error != Error_Succeed) {
- m_pHMClient->SafeDelete();
- m_pHMClient = NULL;
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_pHMClient connect fail!");
- }
- m_pSipphoneChannel = new ChannelSipphoneClient(this);
- if (Error_Succeed == ConnectAssistChannel()){
- m_bConnectedAssist = true;
- }
- else {
- GetFunction()->SetTimer(2, this, 3200);
- }
- Error = GetLocalIP();
- if (Error != 0) {
- CSimpleStringA strErrMsg = "获取本地 IP 地址失败,请检查本地网络是否连接!";
- LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue("");
- Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
- if ('N' != strValue[0]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Sound Card State %s.", strValue.GetData());
- }
- }
-
- LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sipphone entity started successfully.");
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTED, "sipphone entity started.");
- #ifdef RVC_OS_WIN
- if (!m_pAudioMgr || !m_bAudioMgrInited){
- return;
- }
- int ideviceid = -1;
- if (strlen(conf.audio_handfree_in_dev) > 0){
- ideviceid = m_pAudioMgr->audio_get_device_id(conf.audio_handfree_in_dev, true);
- if (-1 == ideviceid){
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COREAUDIO_NOTMATCH_PORTAUDIO, CSimpleStringA::Format("core audio can not get [%s] device id.", conf.audio_handfree_in_dev).GetData());
- }
- }
- if (strlen(conf.audio_handfree_out_dev) > 0){
- ideviceid = m_pAudioMgr->audio_get_device_id(conf.audio_handfree_out_dev, false);
- if (-1 == ideviceid){
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COREAUDIO_NOTMATCH_PORTAUDIO, CSimpleStringA::Format("core audio can not get [%s] device id.", conf.audio_handfree_out_dev).GetData());
- }
- }
- if (eStand2sType == m_eDeviceType){
- if (strlen(conf.audio_pickup_in_dev) > 0){
- ideviceid = m_pAudioMgr->audio_get_device_id(conf.audio_pickup_in_dev, true);
- if (-1 == ideviceid){
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COREAUDIO_NOTMATCH_PORTAUDIO, CSimpleStringA::Format("core audio can not get [%s] device id.", conf.audio_pickup_in_dev).GetData());
- }
- }
- if (strlen(conf.audio_pickup_out_dev) > 0){
- ideviceid = m_pAudioMgr->audio_get_device_id(conf.audio_pickup_out_dev, false);
- if (-1 == ideviceid){
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COREAUDIO_NOTMATCH_PORTAUDIO, CSimpleStringA::Format("core audio can not get [%s] device id.", conf.audio_pickup_out_dev).GetData());
- }
- }
- }
- #endif
- }
- ErrorCodeEnum CSIPEntity::LoadEntityConfig()
- {
- SpIniMappingTable table;
- int iTime = RVC_INTERVAL_TIME;
- int iStopRestartFlag = 0;
- CSimpleStringA strStartTime("");
- CSimpleStringA strEndTime("");
- table.AddEntryInt("SipPhone", "ReStartInterVal", iTime, RVC_INTERVAL_TIME);
- table.AddEntryInt("SipPhone", "StopAutoRestartFlag", iStopRestartFlag, 0);
- table.AddEntryString("SipPhone", "StartTime", strStartTime, "$");
- table.AddEntryString("SipPhone", "EndTime", strEndTime, "$");
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
- if (Error == Error_Succeed) {
- Error = table.Load(spConfig);
- if (Error_Succeed == Error){
- if (iTime >= RVC_INTERVAL_TIME/3){
- m_itervalTime = iTime;
- }
- if (1 == iStopRestartFlag){
- m_bStopAutoRestart = true;
- }
- if (strStartTime.GetLength() > 1 && _stricmp(strStartTime.GetData(), RVC_START_TIME) >= 0) {
- m_strStartTime = strStartTime;
- }
- if (strEndTime.GetLength() > 1 && _stricmp(strEndTime.GetData(), RVC_END_TIME) <= 0) {
- m_strEndTime = strEndTime;
- }
- }
- }
- return Error;
- }
- ErrorCodeEnum CSIPEntity::ConnectAssistChannel()
- {
- if (NULL == m_pSipphoneChannel) {
- m_pSipphoneChannel = new ChannelSipphoneClient(this);
- }
- ErrorCodeEnum Error = m_pSipphoneChannel->Connect();
- if (Error != Error_Succeed) {
- #ifdef RVC_OS_WIN
- m_pSipphoneChannel->SafeDelete();
- #endif
- m_pSipphoneChannel = NULL;
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ChannelSipphoneClient connect fail!");
- return Error;
- }
- {
- ChannelService_BeginState_Sub Sub;
- Error = (*m_pSipphoneChannel)(EntityResource::getLink().upgradeLink())->BeginState(Sub);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- #ifdef RVC_OS_WIN
- m_pSipphoneChannel->SafeDelete();
- #endif
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- {
- ChannelService_BeginRecv_Sub Sub;
- Sub.type = ACM_TYPE_DEVICE;
- Error = (*m_pSipphoneChannel)(EntityResource::getLink().upgradeLink())->BeginRecv(Sub);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin BeginRecv ACM_TYPE_DEVICE failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- #ifdef RVC_OS_WIN
- m_pSipphoneChannel->SafeDelete();
- #endif
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- {
- ChannelService_BeginRecv_Sub Sub;
- Sub.type = ACM_TYPE_VIDEOFREQ;
- Error = (*m_pSipphoneChannel)(EntityResource::getLink().upgradeLink())->BeginRecv(Sub);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin BeginRecv ACM_TYPE_VIDEOFREQ failed!");
- m_pSipphoneChannel->GetFunction()->CloseSession();
- #ifdef RVC_OS_WIN
- m_pSipphoneChannel->SafeDelete();
- #endif
- m_pSipphoneChannel = NULL;
- return Error;
- }
- }
- return Error;
- }
- void CSIPEntity::HandleHandfreeAudioDeviceErrorEvent()
- {
- char strNow[MAX_PATH] = { 0 };
- #ifdef RVC_OS_WIN
- SYSTEMTIME st;
- GetLocalTime(&st);
- _snprintf(strNow, MAX_PATH, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond);
- #else
- struct tm* ptm = NULL;
- time_t t = time(NULL);
- ptm = localtime(&t);
- snprintf(strNow, MAX_PATH, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
- #endif // RVC_OS_WIN
- char strTime[MAX_PATH] = { 0 };
- unsigned int utime = y2k_time_now();
- y2k_to_string(utime, strTime, MAX_PATH);
- if (_stricmp(strNow, m_strStartTime.GetData()) < 0 || _stricmp(strNow, m_strEndTime.GetData()) >= 0) {
- GetFunction()->SetTimer(RVC_ENTER_HOME_PAGE_TIMER, this, 1000);
- }
- else {
- unsigned int ulasttime = 0;
- LoadRestartRunConfig(ulasttime);
- if (utime - ulasttime > m_itervalTime * 60) {
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SIPPHONE_RETART_REQUEST, "请求重启机器");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA3105")("识别不到免提声卡,请求自动重启机器");
- if (Error_Succeed != SaveRestartRunConfig(utime)) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Save Run Config Restart time[%s] failed.", strTime);
- }
- LogEvent(Severity_High, EVENT_MOD_SIP_RESART, "LogEvent Restart Event!");
- }
- }
- }
- //载入运行时配置
- ErrorCodeEnum CSIPEntity::LoadRestartRunConfig(unsigned int& utime)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
- if (Error == Error_Succeed)
- {
- SpIniMappingTable table;
- table.AddEntryUInt("AutoResart", "time", utime, 0);
- Error = table.Load(spConfig);
- if (Error != Error_Succeed){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("failed to load run config.");
- }
- }
- else{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("failed to open run config.");
- }
- return Error;
- }
- //保存运行时
- ErrorCodeEnum CSIPEntity::SaveRestartRunConfig(unsigned int utime)
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();;
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
- if (Error == Error_Succeed){
- Error = spConfig->WriteConfigValueInt("AutoResart", "time", utime);
- }
- else{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("auto resart failed, open sipphone.ini fail!");
- }
- return Error;
- }
- ErrorCodeEnum CSIPEntity::AudioDspFlagsUseCentersetting(endpoint_conf_t* conf)
- {
- SpIniMappingTable table;
- CSmartPointer<IConfigInfo> spConfig;
- endpoint_audiodsp_config_t audiodsp = { false, false, false, false, true, false, true, false, false, true };
- table.AddEntryBoolean("SipPhone", "pickup_out_agc", audiodsp.audio_pickup_out_agc, false);
- table.AddEntryBoolean("SipPhone", "pickup_in_agc", audiodsp.audio_pickup_in_agc, false);
- table.AddEntryBoolean("SipPhone", "handfree_in_agc", audiodsp.audio_handfree_in_agc, false);
- table.AddEntryBoolean("SipPhone", "handfree_out_agc", audiodsp.audio_handfree_out_agc, false);
- table.AddEntryBoolean("SipPhone", "pickup_out_ns", audiodsp.audio_pickup_out_ns, false);
- table.AddEntryBoolean("SipPhone", "pickup_in_ns", audiodsp.audio_pickup_in_ns, true);
- table.AddEntryBoolean("SipPhone", "handfree_in_ns", audiodsp.audio_handfree_in_ns, true);
- table.AddEntryBoolean("SipPhone", "handfree_out_ns", audiodsp.audio_handfree_out_ns, false);
- table.AddEntryBoolean("SipPhone", "pickup_aec", audiodsp.audio_pickup_aec, false);
- table.AddEntryBoolean("SipPhone", "handfree_aec", audiodsp.audio_handfree_aec, true);
- ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
- if (Error == Error_Succeed) {
- Error = table.Load(spConfig);
- if (Error_Succeed == Error) {
- memcpy(&conf->audio_dsp, &audiodsp, sizeof(endpoint_audiodsp_config_t));
- }
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("AudioDspFlagsUseCentersetting load Centersetting failed!");
- memcpy(&conf->audio_dsp, &audiodsp, sizeof(endpoint_audiodsp_config_t));
- }
- return Error;
- }
- ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
- {
- ErrorCodeEnum Error = Error_Succeed;
- m_eDeviceType = RvcGetDeviceType();
- audiomgr_callback_t t_callback = { 0 };
- t_callback.debug = &__audiomgrlog;
- m_pAudioMgr = CreateAudioMgrObj(&t_callback);
- if (m_pAudioMgr && 0 == m_pAudioMgr->audio_mgr_initialize()) {
- m_bAudioMgrInited = true;
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A1")("audio manager initialize success");
- }
- else {
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SIPPHONE_AUDIOMGR_INITIAL_FAILED, "audio manager initialize failed!");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402301A1").setResultCode("RTA310B")("音频服务初始化失败");
- }
- SetSoundCardSysVar(SOUNDCARD_INIT_STATE);
- m_stVideoParam.bActiveInspect = 0;
- m_stVideoParam.bShowActiveImg = 0;
- m_stVideoParam.nWindowState = 0;
- video_lib_init();
- audio_lib_init();
- endpoint_init_lib();
- RvcGetAudioDeviceInfo();
- if (Error_Succeed != LoadEntityConfig()){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("LoadEntityConfig failed.");
- }
- Error = LoadConfig(&conf);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load config failed!");
- }
- if (!IsPostAudioConfigInfo()) {
- //有配置为空的,进关门页
- SetSoundCardSysVar(SOUNDCARD_CONFIG_EMPTY);
- GetFunction()->SetSysVar("AuthErrMsg", "音频配置缺失,请使用硬件配置修改");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402301A3").setResultCode("RTA3101")("音频配置缺失,请使用硬件配置修改");
- return Error_Param;
- }
-
- uint32_t uCheckRet = CheckAudioDevice();
- if (RVC_AUDIO_NO_ERROR == uCheckRet) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A3")("load audio device config success.");
- SetSoundCardSysVar(SOUNDCARD_NO_ERROR);
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("error audio device number is %d.", countnum(uCheckRet));
- if (IsBothSoundCardError(uCheckRet)) { //两组声卡都故障
- SetSoundCardSysVar(SOUNDCARD_BOTH_ERROR);
- GetFunction()->SetSysVar("AuthErrMsg", "音频设备故障,请联系厂商排查");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402301A3").setResultCode("RTA3102")("音频设备故障,请联系厂商排查");
- return Error_Param;
- }
- if ((uCheckRet == (RVC_AUDIO_HANDFREEIN_ERROR | RVC_AUDIO_HANDFREEOUT_ERROR)) || (uCheckRet == RVC_AUDIO_HANDFREEIN_ERROR) || (uCheckRet == RVC_AUDIO_HANDFREEOUT_ERROR)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("can't find handfree audio device.");
- SetSoundCardSysVar(SOUNDCARD_HANDFREE_ERROR);
- HandleHandfreeAudioDeviceErrorEvent();
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402301A3").setResultCode("RTA3103")("识别不到免提声卡");
- }
- if ((uCheckRet == (RVC_AUDIO_PICKUPIN_ERROR | RVC_AUDIO_PICKUPOUT_ERROR)) || (uCheckRet == RVC_AUDIO_PICKUPIN_ERROR) || (uCheckRet == RVC_AUDIO_PICKUPOUT_ERROR)) {
- SetSoundCardSysVar(SOUNDCARD_PICKUP_ERROR);
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402301A3").setResultCode("RTA3104")("话筒声卡故障声卡");
- }
- }
- 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;
- }
- }
- #ifdef RVC_OS_LINUX
- RvcSetSaveAudioVolume();
- #endif
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CUUID id;
- int i = 0;
- m_arrListener.Init(25);
- 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_MOD_ASSISCHAN_STARTED_SUCCESS,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_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_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_STARTCAMERACAPTURE, NULL, false);
- m_arrListener[i++] = id;
- Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPCAMERACAPTURE, 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_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
- }
- else if((strValue[0] == 'O'))
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
- }
- else if ((strValue[0] == 'A'))
- {
- m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
- }
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue("");
- Func->RegistSysVarEvent("UIState", this);
- Func->GetSysVar("UIState", strValue);
- }
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue;
- Func->RegistSysVarEvent(SYSVAR_CALLSTATE, this);
- }
- #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]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("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]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
- }
- }
- if (m_kept_volume_in[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)){
- m_pKeeperIn[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_in_dev, 1, m_kept_volume_in[DEV_PICKUP]);
- if (!m_pKeeperIn[DEV_PICKUP]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP in volume keeper create failed!");
- }
- }
- if (m_kept_volume_out[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)){
- m_pKeeperOut[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_out_dev, 0, m_kept_volume_out[DEV_PICKUP]);
- if (!m_pKeeperOut[DEV_PICKUP]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
- }
- }
- #endif // RVC_OS_WIN
- return Error_Succeed;
- }
- void CSIPEntity::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);
- #ifdef RVC_OS_WIN
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr)
- {
- m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_handfree_out_dev, false);
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
- }
- #endif
- }
- else if(sub_type == ACM_SET_PICKUP_OUTVOLUMN)
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- #ifdef RVC_OS_WIN
- if (m_pKeeperOut[DEV_PICKUP])
- {
- 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 {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr)
- {
- m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_pickup_out_dev, false);
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
- }
- #endif
- }
- else if (sub_type == ACM_SET_HANDFREE_INVOLUMN)
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- #ifdef RVC_OS_WIN
- 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{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("handfree in volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr)
- {
- m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_handfree_in_dev, true);
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("handfree in volume keeper create failed!");
- }
- #endif
- }
- else if(sub_type == ACM_SET_PICKUP_INVOLUMN)
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- #ifdef RVC_OS_WIN
- if (m_pKeeperIn[DEV_PICKUP])
- {
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pickup in volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr)
- {
- m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_pickup_in_dev, true);
- 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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pickup in volume keeper create failed!");
- }
- #endif
- }
- else if (sub_type == ACM_CONTROL_PERSONAREA) //控制人形框
- {
- CVolumnValue num;
- SpBuffer buf;
- buf.OpenRead(buffer,size);
- num.Serialize(buf);
- if (num.nValue == 0) //隐藏人形框
- {
- 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_SHOWLOCALVIDEO,"Agent send show local video");
- LogEvent(Severity_Middle,LOG_EVT_UI_SHOWPERSONAREA,"Agent send Show Person area");
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv control person area sub_type error!");
- }
- }
- }
- else if (type == ACM_TYPE_VIDEOFREQ)
- {
- }
- }
- ErrorCodeEnum CSIPEntity::RvcGetAudioDeviceInfo()
- {
- #ifdef RVC_OS_WIN
- ErrorCodeEnum Error = Error_Succeed;
- CSimpleStringA strAudioInInfos = audio_get_dev_infos(true);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A2").setAPI("RvcMedia_GetAudioInDevInfo")(strAudioInInfos.GetData());
-
- CSimpleStringA strAudioOutInfos = audio_get_dev_infos(false);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A2").setAPI("RvcMedia_GetAudioOutDevInfo")(strAudioOutInfos.GetData());
- if (NULL != m_pAudioMgr || !m_bAudioMgrInited) {
- int icountmic = m_pAudioMgr->audio_get_device_count(true);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("core audio input device(%d):", icountmic);
- int i = 0;
- for (; i < icountmic; i++) {
- char strname[MAX_PATH] = { 0 };
- m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, true, i);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", i, strname);
- }
- if (icountmic < RVC_AUDIO_IN_DEVICE_COUNT) {
- LogWarn(Severity_Middle, Error_AudioIN, ERROR_MOD_SIP_AUDIO_IN_COUNT, CSimpleString::Format("audio in device count is %d.", icountmic).GetData());
- }
- int icountspeaker = m_pAudioMgr->audio_get_device_count(false);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("core audio output device(%d):", icountspeaker);
- for (i = 0; i < icountspeaker; i++) {
- char strname[MAX_PATH] = { 0 };
- m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, false, i);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", i, strname);
- }
- if (icountspeaker < RVC_AUDIO_IN_DEVICE_COUNT) {
- LogWarn(Severity_Middle, Error_AudioOut, ERROR_MOD_SIP_AUDIO_OUT_COUNT, CSimpleString::Format("audio out device count is %d.", icountspeaker).GetData());
- }
- Error = Error_Succeed;
- }
- return Error;
- #else
- ErrorCodeEnum Error = Error_Param;
- if (NULL != m_pAudioMgr) {
- int icountmic = m_pAudioMgr->audio_get_device_count(true);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio input devices(%d):", icountmic);
- int i = 0;
- CSimpleStringA strJsonIn("");
- for (; i < icountmic; i++) {
- char strname[MAX_PATH] = { 0 };
- m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, true, i);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", i, strname);
- strJsonIn += CSimpleStringA::Format("\"%d\":\"%s\",", i, strname);
- }
- if (strJsonIn.GetLength() > 0) {
- strJsonIn[strJsonIn.GetLength() - 1] = '\0';
- }
- CSimpleStringA strJsonInData = CSimpleStringA::Format("audio in devices [{%s}]", strJsonIn.GetData());
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SIPPHONE_GET_AUDIO_IN_INFOS, strJsonInData.GetData());
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A2").setAPI("RvcMedia_GetAudioInDevInfo")(GetAudioDeviceJsonInfos(true).GetData());
- CSimpleStringA strJsonOut("");
- int icountspeaker = m_pAudioMgr->audio_get_device_count(false);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio output devices(%d):", icountspeaker);
- for (i = 0; i < icountspeaker; i++) {
- char strname[MAX_PATH] = { 0 };
- m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, false, i);
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", i, strname);
- strJsonOut += CSimpleStringA::Format("\"%d\":\"%s\",", i, strname);
- }
- if (strJsonOut.GetLength() > 0) {
- strJsonOut[strJsonOut.GetLength() - 1] = '\0';
- }
- CSimpleStringA strJsonOutData = CSimpleStringA::Format("audio out devices [{%s}]", strJsonOut.GetData());
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SIPPHONE_GET_AUDIO_OUT_INFOS, strJsonOutData.GetData());
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402301A2").setAPI("RvcMedia_GetAudioOutDevInfo")(GetAudioDeviceJsonInfos(false).GetData());
-
- Error = Error_Succeed;
- }
- return Error;
- #endif
- }
- ErrorCodeEnum CSIPEntity::RvcSetSaveAudioVolume()
- {
- ErrorCodeEnum Error = Error_Succeed;
- #ifdef RVC_OS_LINUX
- if (m_pAudioMgr){
- m_pAudioMgr->audio_set_device_volume(m_kept_volume_out[DEV_HANDFREE], conf.audio_handfree_out_dev, false);
- m_pAudioMgr->audio_set_device_volume(m_kept_volume_in[DEV_HANDFREE], conf.audio_handfree_in_dev, true);
- m_pAudioMgr->audio_set_device_volume(m_kept_volume_out[DEV_PICKUP], conf.audio_pickup_out_dev, false);
- m_pAudioMgr->audio_set_device_volume(m_kept_volume_in[DEV_PICKUP], conf.audio_pickup_in_dev, true);
- }
- #endif
- return Error;
- }
- bool CSIPEntity::IsPostAudioConfigInfo()
- {
- bool bRet = false;
- size_t uhandfreein = strlen(conf.audio_handfree_in_dev);
- size_t uhandfreeout = strlen(conf.audio_handfree_out_dev);
- size_t upickupin = strlen(conf.audio_pickup_in_dev);
- size_t upickupout = strlen(conf.audio_pickup_out_dev);
- if ((uhandfreein > 0) && (uhandfreeout > 0) && (upickupin > 0) && (upickupout > 0)) {
- bRet = true;
- }
- return bRet;
- }
- uint32_t CSIPEntity::CheckAudioDevice()
- {
- int id = -1;
- uint32_t Error = RVC_AUDIO_NO_ERROR;
- #ifdef RVC_OS_WIN
- id = capture_get_audio_device_id(true, conf.audio_handfree_in_dev);
- #else
- if (NULL != m_pAudioMgr) {
- id = m_pAudioMgr->audio_get_device_id(conf.audio_handfree_in_dev, true);
- }
- #endif
- if (id == -1) {
- //CSimpleStringA strErrMsg = "外部麦克风配置错误,请重新配置!";
- //LogWarn(Severity_Middle, Error_Param, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, strErrMsg.GetData());
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free in audio device %s does not exist!", conf.audio_handfree_in_dev).GetData());
- Error = RVC_AUDIO_HANDFREEIN_ERROR;
- }
- #ifdef RVC_OS_WIN
- id = capture_get_audio_device_id(false, conf.audio_handfree_out_dev);
- #else
- if (NULL != m_pAudioMgr) {
- id = m_pAudioMgr->audio_get_device_id(conf.audio_handfree_out_dev, false);
- }
- #endif
- if (id == -1) {
- //CSimpleStringA strErrMsg = "外部扬声器配置错误,请重新配置!";
- //LogWarn(Severity_Middle, Error_Param, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, strErrMsg.GetData());
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free out audio device %s does not exist!", conf.audio_handfree_out_dev).GetData());
- Error |= RVC_AUDIO_HANDFREEOUT_ERROR;
- }
- #ifdef RVC_OS_WIN
- id = capture_get_audio_device_id(true, conf.audio_pickup_in_dev);
- #else
- if (NULL != m_pAudioMgr) {
- id = m_pAudioMgr->audio_get_device_id(conf.audio_pickup_in_dev, true);
- }
- #endif
- if (id == -1) {
- //CSimpleStringA strErrMsg = "话筒麦克风配置错误,请重新配置!";
- //LogWarn(Severity_Middle, Error_Param, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, strErrMsg.GetData());
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup in audio device %s does not exist!", conf.audio_pickup_in_dev).GetData());
- Error |= RVC_AUDIO_PICKUPIN_ERROR;
- }
- #ifdef RVC_OS_WIN
- id = capture_get_audio_device_id(false, conf.audio_pickup_out_dev);
- #else
- if (NULL != m_pAudioMgr) {
- id = m_pAudioMgr->audio_get_device_id(conf.audio_pickup_out_dev, false);
- }
- #endif
- if (id == -1) {
- //CSimpleStringA strErrMsg = "话筒扬声器配置错误,请重新配置!";
- //LogWarn(Severity_Middle, Error_Param, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, strErrMsg.GetData());
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup out audio device %s does not exist!", conf.audio_pickup_out_dev).GetData());
- Error |= RVC_AUDIO_PICKUPOUT_ERROR;
- }
- if (RVC_AUDIO_NO_ERROR != Error) {
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_CONFIG_ERROR, CSimpleStringA::Format("config audio device not exist.").GetData());
- }
- return Error;
- }
- ErrorCodeEnum CSIPEntity::SetSoundCardSysVar(const CSimpleStringA& newVal)
- {
- CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
- return spFunction->SetSysVar(SYSVAR_SOUNDCARDSTATE, newVal.GetData());
- }
- void CSIPEntity::HandleCheckAudioDevice(const char* pszValue)
- {
- if (!pszValue) {
- return;
- }
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue("");
- Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
- if ('N' != strValue[0]) {
- if (pszValue[0] == 'H' && m_iPickupPhoneState == ePickupMicrophoneState_On) {
- HandleSendBroadcastMsg(true);
- }
- else if (pszValue[0] == 'P' && m_iPickupPhoneState == ePickupMicrophoneState_Off) {
- HandleSendBroadcastMsg(false);
- }
- }
- }
- void CSIPEntity::SetMessageBoxFlag(bool bFlag)
- {
- m_bMessageBox = bFlag;
- }
- void CSIPEntity::HandleSendBroadcastMsg(bool bHandfreeError)
- {
- if (bHandfreeError) {
- if (m_bMessageBox) {
- UIMessageBox evt;
- evt.uboxtype = 1;
- evt.strtitle = CSimpleStringA2W("");
- evt.strmessage = CSimpleStringA2W("免提设备故障,请使用话筒办理业务");
- SpSendBroadcast(GetFunction(), SP_MSG_OF(UIMessageBox), SP_MSG_SIG_OF(UIMessageBox), evt);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SpSendBroadcast SwitchHandFree UIMessageBox.");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA3107")("免提设备故障,请使用话筒办理业务");
- m_bMessageBox = false;
- }
- else {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("MessageBox broadcast has post, ignore it.");
- }
- }
- else {
- if (m_bMessageBox) {
- UIMessageBox evt;
- evt.uboxtype = 1;
- evt.strtitle = CSimpleStringA2W("");
- evt.strmessage = CSimpleStringA2W("话筒设备故障,请使用免提办理业务");
- SpSendBroadcast(GetFunction(), SP_MSG_OF(UIMessageBox), SP_MSG_SIG_OF(UIMessageBox), evt);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SpSendBroadcast SwitchPickup UIMessageBox.");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA3108")("话筒设备故障,请使用免提办理业务");
- m_bMessageBox = false;
- }
- else {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("MessageBox broadcast has post, ignore it.");
- }
- }
- }
- ErrorCodeEnum CSIPEntity::GetLocalIP()
- {
- #ifdef RVC_OS_WIN
- char tmp[MAX_PATH] = { 0 };
- gethostname(tmp, sizeof(tmp));
- hostent* ent = gethostbyname(tmp);
- if (ent) {
- int icount = 0;
- for(; ent->h_addr_list[icount]; ){
- ++icount;
- }
- if(icount > 1){
- LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_CALL_MUTIL_NIC, CSimpleStringA::Format("device net adapter number is %d.", icount).GetData());
- }
- 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);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_GET_LOCAL_IP, CSimpleStringA::Format("local ip == %s", m_localip).GetData());
- return Error_Succeed;
- }
- else {
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_INVALID_IP, CSimpleStringA::Format("invalid ip == %s", p).GetData());
- }
- }
- }
- }
- }
- 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){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("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);
- ifreq++;
- if (NULL != strIP){
- if (NULL == strstr(strIP, "198.168.") && NULL == strstr(strIP, "127.0.0.1"))
- {
- strcpy(m_localip, strIP);
- error = Error_Succeed;
- break;
- }
- }
- }
- }
- close(sockfd);
- return error;
- #endif // RVC_OS_WIN
- }
- //send audio device volume
- void CSIPEntity::SendAudioDeviceVolumn(int nDevice)
- {
- ChannelService_Send_Info Info;
- Info.compress = false;
- Info.encrypt = false;
- Info.type = ACM_TYPE_DEVICE;
- Info.id = 0;
- int nValue = 0;
- bool rslt = false;
-
- void*keeper = NULL;
- if (nDevice == DEVICE_HANDFREE_OUT)
- {
- Info.sub_type = ACM_HANDFREE_OUTVOLUMN;
- #ifdef RVC_OS_WIN
- keeper = m_pKeeperOut[DEV_HANDFREE];
- #else
- m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_handfree_out_dev, false);
- rslt = true;
- #endif // RVC_OS_WIN
- }
- else if(nDevice == DEVICE_PICKUP_OUT)
- {
- if(eStand2sType == m_eDeviceType)
- {
- Info.sub_type = ACM_PICKUP_OUTVOLUMN;
- #ifdef RVC_OS_WIN
- keeper = m_pKeeperOut[DEV_PICKUP];
- #else
- m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_pickup_out_dev, false);
- rslt = true;
- #endif
- }
- else //pad版屏蔽当前PICKUP音量发送
- {
- return;
- }
- }
- else if(nDevice == DEVICE_HANDFREE_IN)
- {
- Info.sub_type = ACM_HANDFREE_INVOLUMN;
- #ifdef RVC_OS_WIN
- keeper = m_pKeeperIn[DEV_HANDFREE];
- #else
- m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_handfree_in_dev, true);
- rslt = true;
- #endif
- }
- else if(nDevice == DEVICE_PICKUP_IN)
- {
- if(eStand2sType == m_eDeviceType)
- {
- Info.sub_type = ACM_PICKUP_INVOLUMN;
- #ifdef RVC_OS_WIN
- keeper = m_pKeeperIn[DEV_PICKUP];
- #else
- m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_pickup_in_dev, true);
- rslt = true;
- #endif
- }
- else //pad版屏蔽当前PICKUP音量发送
- {
- return;
- }
- }
- Info.data.Alloc(sizeof(int));
- SpBuffer buf;
- buf.OpenWrite();
- #ifdef RVC_OS_WIN
- if (keeper){
- rslt = get_audiodevice_volumn(keeper, &nValue);
- }
- #endif
- if (rslt == true){
- buf & nValue;
- Info.data = buf.ToBlob();
- m_pSipphoneChannel->Send(Info);
- }
- else{
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Get cur Audio device %d volume Fail!",nDevice);
- }
- }
- ErrorCodeEnum CSIPEntity::SetHandfreeOutVolume(int iVolume)
- {
- ErrorCodeEnum Error = Error_Succeed;
- #ifdef RVC_OS_WIN
- if (m_pKeeperOut[DEV_HANDFREE]){
- volume_keeper_change(m_pKeeperOut[DEV_HANDFREE], iVolume);
- m_kept_volume_out[DEV_HANDFREE] = iVolume;
- 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{
- 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]);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr){
- m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_handfree_out_dev, false);
- m_kept_volume_out[DEV_HANDFREE] = iVolume;
- 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{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE out volume keeper create failed!");
- }
- #endif
- return Error;
- }
- ErrorCodeEnum CSIPEntity::SetPickupOutVolume(int iVolume)
- {
- ErrorCodeEnum Error = Error_Succeed;
- #ifdef RVC_OS_WIN
- if (m_pKeeperOut[DEV_PICKUP]){
- if (eStand2sType == m_eDeviceType){
- volume_keeper_change(m_pKeeperOut[DEV_PICKUP], iVolume);
- m_kept_volume_out[DEV_PICKUP] = iVolume;
- 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{
- 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]);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
- }
- #else
- if (m_pAudioMgr){
- if (eStand2sType == m_eDeviceType || eStand1SPlusType == m_eDeviceType){
- m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_pickup_out_dev, false);
- m_kept_volume_out[DEV_PICKUP] = iVolume;
- 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{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PAD type, ignore pickupout volume adj");
- }
- }
- else{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
- }
- #endif
- return Error;
- }
- ErrorCodeEnum CSIPEntity::SetHandfreeInVolume(int iVolume)
- {
- ErrorCodeEnum Error = Error_Succeed;
- #ifdef RVC_OS_WIN
- if (m_pKeeperIn[DEV_HANDFREE]) {
- volume_keeper_change(m_pKeeperIn[DEV_HANDFREE], iVolume);
- m_kept_volume_in[DEV_HANDFREE] = iVolume;
- }
- 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
- if (m_pAudioMgr) {
- m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_handfree_in_dev, true);
- m_kept_volume_in[DEV_HANDFREE] = iVolume;
- 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 {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("HANDFREE in volume keeper create failed!");
- }
- #endif
- return Error;
- }
- ErrorCodeEnum CSIPEntity::SetPickupInVolume(int iVolume)
- {
- ErrorCodeEnum Error = Error_Succeed;
- #ifdef RVC_OS_WIN
- if (m_pKeeperIn[DEV_PICKUP]) {
- volume_keeper_change(m_pKeeperIn[DEV_PICKUP], iVolume);
- m_kept_volume_in[DEV_PICKUP] = iVolume;
- }
- 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
- if (m_pAudioMgr) {
- if (eStand2sType == m_eDeviceType || eStand1SPlusType == m_eDeviceType) {
- m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_pickup_in_dev, true);
- m_kept_volume_in[DEV_PICKUP] = iVolume;
- 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 {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PAD type, ignore pickupin volume adj");
- }
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP in volume keeper create failed!");
- }
- #endif
- return Error;
- }
- void CSIPEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- ErrorCodeEnum Error = __OnClose(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- }
- ErrorCodeEnum CSIPEntity::__OnClose(ErrorCodeEnum preOperationError)
- {
- #ifdef RVC_OS_WIN
- 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;
- }
- #else
- if (NULL != m_pAudioMgr) {
- m_pAudioMgr->audio_mgr_terminate();
- DestroyIAudioMgrObj(m_pAudioMgr);
- m_pAudioMgr = NULL;
- }
- #endif
- CSmartPointer<IEntityFunction> Func = GetFunction();
- Func->UnregistSysVarEvent(SYSVAR_AGENTCAMERASWITCH);
- Func->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
- Func->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
- Func->UnregistSysVarEvent("UIState");
- Func->UnregistSysVarEvent(SYSVAR_CALLSTATE);
- for (int i = 0; i < m_arrListener.GetCount(); ++i) {
- Func->UnsubscribeLog(m_arrListener[i]);
- }
- m_arrListener.Clear();
- endpoint_destroy(m_pEndpoint);
- m_pEndpoint = NULL;
- video_lib_deinit();
- audio_lib_deinit();
- endpoint_deinit_lib();
- return Error_Succeed;
- }
- void CSIPEntity::OnPaused()
- {
- }
- void CSIPEntity::OnContinued()
- {
- }
- CServerSessionBase* CSIPEntity::OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/)
- {
- m_pCurrentSession = new CSIPPhoneSession(this);
- return m_pCurrentSession;
- }
- void CSIPEntity::OnTimeout(DWORD dwTimerID)
- {
- if (dwTimerID == 1)
- {
- GetFunction()->KillTimer(1);
- m_stVideoParam.nUpDynamicFps = -1;
- }
- else if (2 == dwTimerID)
- {
- if (!m_bConnectedAssist) {
- if (Error_Succeed == ConnectAssistChannel()) {
- m_bConnectedAssist = true;
- }
- }
- if (m_bConnectedAssist){
- GetFunction()->KillTimer(2);
- }
- }
- else if (RVC_ENTER_HOME_PAGE_TIMER == dwTimerID) {
- if (m_bFirstLaunched)
- {
- #ifdef RVC_OS_WIN
- Sleep(2000);
- #else
- usleep(2000 * 1000);
- #endif // RVC_OS_WIN
- UIMessageBox evt;
- evt.uboxtype = 2;
- evt.strtitle = CSimpleStringA2W("声卡识别故障");
- evt.strmessage = CSimpleStringA2W("识别不到免提声卡,请尝试重启机器解决,多次无效后请联系厂商处理");
- SpSendBroadcast(GetFunction(), SP_MSG_OF(UIMessageBox), SP_MSG_SIG_OF(UIMessageBox), evt);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SpSendBroadcast UIMessageBox.");
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA3106")("识别不到免提声卡,请尝试重启机器解决");
- GetFunction()->KillTimer(RVC_ENTER_HOME_PAGE_TIMER);
- }
- }
- }
- ErrorCodeEnum CSIPEntity::InitEndpoint()
- {
- ErrorCodeEnum eCode = Error_Param;
- CSmartPointer<IEntityFunction> Func = GetFunction();
- Func->GetSystemStaticInfo(staticInfo);
-
- CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
- if (strUri.GetLength() > 0)
- {
- _snprintf(conf.uri, MAX_PATH, "%s", strUri.GetData());
- 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) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
- eCode = Error_Unexpect;
- }
- else{
- eCode = Error_Succeed;
- }
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("strUri length equals zero!");
- eCode = Error_Unexpect;
- }
- return eCode;
- }
- void CSIPEntity::change_dev(int dev_type)
- {
- if (m_pEndpoint) {
- endpoint_change_audio_dev(m_pEndpoint, dev_type);
- }
- }
- static int __change_dev(void *arg)
- {
- ChangeDevCommand *pCmd = (ChangeDevCommand *)arg;
- pCmd->pEntity->change_dev(pCmd->dev_type);
- delete pCmd;
- return 0;
- }
- void CSIPEntity::SwitchHandFree()
- {
- int rc = 0;
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue("");
- Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
- if ('B' == strValue[0] || 'H' == strValue[0]) {
- HandleSendBroadcastMsg(true);
- return;
- }
- ChangeDevCommand *pCmd = new ChangeDevCommand();
- pCmd->pEntity = this;
- pCmd->dev_type = DEV_HANDFREE;
- if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("endpoint invoke failed!");
- delete pCmd;
- }
- }
- void CSIPEntity::SwitchPickup()
- {
- int rc = 0;
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue("");
- Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
- if ('B' == strValue[0] || 'P' == strValue[0]) {
- HandleSendBroadcastMsg(false);
- return;
- }
- ChangeDevCommand *pCmd = new ChangeDevCommand();
- pCmd->pEntity = this;
- pCmd->dev_type = DEV_PICKUP;
- if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("endpoint invoke failed!");
- delete pCmd;
- }
- }
- void CSIPEntity::SetState(int state)
- {
- m_state = state;
- }
- ErrorCodeEnum CSIPEntity::RealSelfCheck()
- {
- ErrorCodeEnum Error = Error_Succeed;
- if (m_pHMClient)
- {
- HealthManagerService_RealCheck_Req req;
- req.name = GetEntityName();
- HealthManagerService_RealCheck_Ans ans;
- DWORD Timeout = 500;
- Error = m_pHMClient->RealCheck(req,ans,Timeout);
- if (Error!=Error_Succeed){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RealSelfcheck fail!");
- }
- }
- return Error;
- }
- CSimpleStringA CSIPEntity::MakeUri(const char *terminal_id)
- {
- return CSimpleStringA::Format("sip:%s@%s;transport=UDP", terminal_id, m_localip);
- }
- #ifdef RVC_OS_WIN
- ErrorCodeEnum CSIPEntity::StartVideoRender()
- {
- ErrorCodeEnum Error = Error_Succeed;
- return Error;
- }
- ErrorCodeEnum CSIPEntity::StopVideoRender()
- {
- ErrorCodeEnum Error = Error_Succeed;
- return Error;
- }
- #endif
- ErrorCodeEnum CSIPEntity::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_dsp.audio_pickup_out_agc, false);
- table.AddEntryBoolean("audio", "pickup_in_agc", conf->audio_dsp.audio_pickup_in_agc, false);
- table.AddEntryBoolean("audio", "handfree_in_agc", conf->audio_dsp.audio_handfree_in_agc, false);
- table.AddEntryBoolean("audio", "handfree_out_agc", conf->audio_dsp.audio_handfree_out_agc, false);
- table.AddEntryBoolean("audio", "pickup_out_ns", conf->audio_dsp.audio_pickup_out_ns, false);
- table.AddEntryBoolean("audio", "pickup_in_ns", conf->audio_dsp.audio_pickup_in_ns, false);
- table.AddEntryBoolean("audio", "handfree_in_ns", conf->audio_dsp.audio_handfree_in_ns, false);
- table.AddEntryBoolean("audio", "handfree_out_ns", conf->audio_dsp.audio_handfree_out_ns, false);
- table.AddEntryBoolean("audio", "pickup_aec", conf->audio_dsp.audio_pickup_aec, false);
- table.AddEntryBoolean("audio", "handfree_aec", conf->audio_dsp.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) {
- rvc_snprintf(conf->audio_handfree_in_dev, MAX_PATH, "%s", strHandFreeIn.GetData());
- rvc_snprintf(conf->audio_handfree_out_dev, MAX_PATH, "%s", strHandFreeOut.GetData());
- rvc_snprintf(conf->audio_pickup_in_dev, MAX_PATH, "%s", strPickupIn.GetData());
- rvc_snprintf(conf->audio_pickup_out_dev, MAX_PATH, "%s", strPickupOut.GetData());
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_DSP_INFO, generateAudioDspFlags(conf->audio_dsp).GetData());
- AudioDspFlagsUseCentersetting(conf);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_CENTER_AUDIO_DSP_FLAGS, generateAudioDspFlags(conf->audio_dsp).GetData());
-
- 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;
- #ifdef RVC_OS_WIN
- conf->irendertype = (int)m_eVideoRenderType;
- #endif
- m_stVideoParam.nUpDynamicFps = 0;
-
- conf->ref_Up_Fps = &m_stVideoParam.nUpDynamicFps;
- if (eStand1SPlusType == m_eDeviceType)
- {
- conf->camera_count = 1;
- }
- else if(eStand2sType == m_eDeviceType)
- {
- conf->camera_count = 2;
- }
- //DecideCameraCount(conf->camera_count);
- DecideScreenCount(conf->screen_count);
- }
- }
- #ifdef RVC_OS_LINUX
- InitFreshTimeConfig();
- #endif
- return Error;
- }
- //载入运行时配置
- ErrorCodeEnum CSIPEntity::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)
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] failed to load run config.");
- }
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] failed to open run config.");
- }
- return Error;
- }
- //保存运行时
- ErrorCodeEnum CSIPEntity::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
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SaveAudioRunConfig handfree_out_volume fail!");
- return Error;
- }
- if(Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "handfree_in_volume", nHandfreein);
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SaveAudioRunConfig pickup_out_volume fail!");
- return Error;
- }
- if(Error == Error_Succeed)
- {
- Error = spConfig->WriteConfigValueInt("Audio", "pickup_in_volume", nPickupin);
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SaveAudioRunConfig handfree_in_volume fail!");
- return Error;
- }
- if (Error != Error_Succeed)
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SaveAudioRunConfig pickup_in_volume fail!");
- return Error;
- }
- }
- else
- {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SaveAudioRunConfig is fail , open sipphone.ini fail!");
- }
-
- return Error;
- }
- ErrorCodeEnum CSIPEntity::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 CSIPEntity::RvcGetDeviceType()
- {
- DeviceTypeEnum eType = eStand2sType;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSystemStaticInfo stStaticinfo;
- spFunction->GetSystemStaticInfo(stStaticinfo);
- if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
- eType = eStand1SPlusType;
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
- eType = eCardStore;
- }
- else {
- eType = eStand2sType;
- }
- if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
- }
- return eType;
- }
- #ifdef RVC_OS_WIN
- eVideoRenderType CSIPEntity::GetMediaConfig()
- {
- CSmartPointer<IConfigInfo> spConfig;
- SpIniMappingTable table;
- CSmartPointer<IEntityFunction> pFunc = GetFunction();
- ErrorCodeEnum Error = pFunc->OpenConfig(Config_CenterSetting, spConfig);
- int iRenderType = 0;
- if (Error == Error_Succeed)
- {
- table.AddEntryInt("SipPhone", "VideoRenderType", iRenderType, 0);
- table.Load(spConfig);
- }
- eVideoRenderType eRenderType = eGDI;
- if (0 != iRenderType){
- eRenderType = eSDL;
- }
- if (eRenderType >= eGDI && eRenderType < sizeof(VideoRender_Type_Table) / sizeof(char*)) {
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("video render type is %s.", VideoRender_Type_Table[eRenderType]);
- }
- return eRenderType;
- }
- #else
- void CSIPEntity::InitFreshTimeConfig()
- {
- int ileftvideo = RVC_MAX_VIDEO_FRESH_TIME;
- int irightvideo = RVC_MAX_VIDEO_FRESH_TIME;
- CSmartPointer<IConfigInfo> spCacheConfig;
- ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spCacheConfig);
- if (Error_Succeed == Error) {
- SpIniMappingTable table;
- table.AddEntryInt("SIPPhone", "lfreshtime", ileftvideo, RVC_MAX_VIDEO_FRESH_TIME);
- table.AddEntryInt("SIPPhone", "rfreshtime", irightvideo, RVC_MAX_VIDEO_FRESH_TIME);
- Error = table.Load(spCacheConfig);
- if (Error == Error_Succeed) {
- if (0 == ileftvideo) {
- ileftvideo = RVC_MAX_VIDEO_FRESH_TIME / 2;
- }
- if (0 == irightvideo) {
- irightvideo = RVC_MAX_VIDEO_FRESH_TIME / 2;
- }
- if (ileftvideo < RVC_MIN_VIDEO_FRESH_TIME) {
- ileftvideo = RVC_MIN_VIDEO_FRESH_TIME;
- }
- if (ileftvideo > RVC_MAX_VIDEO_FRESH_TIME) {
- ileftvideo = RVC_MAX_VIDEO_FRESH_TIME;
- }
- if (irightvideo < RVC_MIN_VIDEO_FRESH_TIME) {
- irightvideo = RVC_MIN_VIDEO_FRESH_TIME;
- }
- if (irightvideo > RVC_MAX_VIDEO_FRESH_TIME) {
- irightvideo = RVC_MAX_VIDEO_FRESH_TIME;
- }
- }
- }
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_OVERWRITE_FRESHVALUE,
- CSimpleStringA::Format("overwrite video freshtime from centersetting cache, left fresh time is %d, right fresh time is %d.", ileftvideo, irightvideo).GetData());
- m_ilocalvideo_freshtime = ileftvideo;
- m_iremotevideo_freshtime = irightvideo;
- }
- void CSIPEntity::HideLocalVideo()
- {
- if (NULL != m_render) {
- if (NULL != m_render->plocal_render) {
- m_render->plocal_render->HideVideoWindow();
- }
- }
- }
- void CSIPEntity::ShowLocalVideo()
- {
- if (NULL != m_render) {
- if (NULL != m_render->premote_render && NULL != m_render->plocal_render) {
- m_render->plocal_render->ShowVideoWindow();
- m_render->premote_render->HideVideoWindow();
- m_render->premote_render->ShowVideoWindow();
- }
- }
- }
- void CSIPEntity::HideBothVideo()
- {
- if (NULL != m_render) {
- if (NULL != m_render->premote_render && NULL != m_render->plocal_render) {
- m_render->plocal_render->HideVideoWindow();
- m_render->premote_render->HideVideoWindow();
- }
- }
- }
- void CSIPEntity::ShowBothVideo()
- {
- if (NULL != m_render) {
- if (NULL != m_render->premote_render && NULL != m_render->plocal_render) {
- m_render->plocal_render->ShowVideoWindow();
- m_render->premote_render->ShowVideoWindow();
- }
- }
- }
- CSimpleStringA CSIPEntity::GetAudioDeviceJsonInfos(bool bmicro)
- {
- CSimpleStringA strAudioDevJson("");
- cJSON* array = cJSON_CreateArray();
- cJSON* root = cJSON_CreateObject();
- if (NULL != m_pAudioMgr) {
- char* strkey = NULL;
- if (bmicro) {
- strkey = "MicrophoneInfo";
- }
- else {
- strkey = "SpeakerInfo";
- }
- int iaudiocount = m_pAudioMgr->audio_get_device_count(bmicro);
- for (int i = 0; i < iaudiocount; i++) {
- rvc_audio_device_t* audio_dev = m_pAudioMgr->audio_get_device_infos(bmicro, i);
- cJSON* pobject = cJSON_CreateObject();
- cJSON_AddItemToObject(pobject, "name", cJSON_CreateString(audio_dev->name));
- cJSON_AddItemToObject(pobject, "description", cJSON_CreateString(audio_dev->description));
- cJSON_AddItemToObject(pobject, "samprate", cJSON_CreateString(CSimpleStringA::Format("%d", audio_dev->samprate).GetData()));
- cJSON_AddItemToObject(pobject, "channels", cJSON_CreateString(CSimpleStringA::Format("%d", audio_dev->channels).GetData()));
- cJSON_AddItemToObject(pobject, "low_latency", cJSON_CreateString(CSimpleStringA::Format("%.2f", audio_dev->low_latency).GetData()));
- cJSON_AddItemToObject(pobject, "high_latency", cJSON_CreateString(CSimpleStringA::Format("%.2f", audio_dev->high_latency).GetData()));
- cJSON_AddItemToArray(array, pobject);
- }
- cJSON_AddItemToObject(root, strkey, array);
- }
-
- char* pjsonstr = cJSON_PrintUnformatted(root);
- strAudioDevJson = pjsonstr;
- cJSON_free(pjsonstr);
- cJSON_Delete(root);
- return strAudioDevJson;
- }
- #endif
- int CSIPEntity::StartCameraRender(int icamid, int ivideoview_x, int ivideoview_y, int ivideoview_cx, int ivideoview_cy)
- {
- int iRet = -1;
- if (m_bIsCameraRender) {
- return iRet;
- }
-
- m_render = new rvc_video_render_t();
- videorender_callback_t t_callback = { 0 };
- t_callback.debug = &__video_render_log;
- rvc_video_render_params_t render_param = { 0 };
- render_param.ilocal_view_cx = ivideoview_cx;
- render_param.ilocal_view_cy = ivideoview_cy;
- render_param.ilocal_view_x = ivideoview_x;
- render_param.ilocal_view_y = ivideoview_y;
- render_param.erender_queue = eSnapshot_Queue;
- m_render->plocal_render = CreateVideoRenderObj(&t_callback);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_VIDEO_RENDER_CREATE, "local video render create.");
- memcpy(&m_render->render_param, &render_param, sizeof(rvc_video_render_params_t));
- #ifdef RVC_OS_WIN
- m_render->local_render_stop_event = NULL;
- m_render->remote_render_stop_event = NULL;
- m_render->local_render_thread = NULL;
- m_render->remote_render_thread = NULL;
- #else
- m_render->local_render_threadid = 0;
- m_render->remote_render_threadid = 0;
- #endif // RVC_OS_WIN
- rvc_video_box_move_callback_t t_render_callback = { 0 };
- t_render_callback.on_video_box_move = &__on_video_box_move;
- t_render_callback.user_data = this;
- rvc_video_render_window_type_callback_t t_window_type_callback = { 0 };
- t_window_type_callback.on_window_type = &__on_window_type_callback;
- t_window_type_callback.user_data = this;
- memcpy(&m_render->cb, &t_window_type_callback, sizeof(rvc_video_render_window_type_callback_t));
- m_stVideoParam.bShowPersonArea = 0;
- if (Error_Succeed == rvc_start_video_render(m_render, eRender_Local_Single, &t_render_callback)) {
- m_bIsCameraRender = true;
- }
- iRet = 0;
- return iRet;
- }
- int CSIPEntity::StopCameraRender()
- {
- int iRet = -1;
- if (NULL == m_render) {
- return iRet;
- }
- if (Error_Succeed != rvc_stop_video_render(m_render)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop video render failed.");
- }
- if (NULL!= m_render->plocal_render) {
- DestroyVideoRenderObj(m_render->plocal_render);
- }
- if (NULL != m_render->premote_render) {
- DestroyVideoRenderObj(m_render->premote_render);
- }
- if (NULL != m_render) {
- delete(m_render);
- m_render = NULL;
- }
- m_bIsCameraRender = false;
- iRet = 0;
- return iRet;
- }
- int CSIPEntity::StartBothCameraRender(SpReqAnsContext<PhoneService_StartBothCameraRender_Req, PhoneService_StartBothCameraRender_Ans>::Pointer ctx)
- {
- int iRet = -1;
- if (m_bIsCameraRender) {
- return iRet;
- }
- m_render = new rvc_video_render_t();
- videorender_callback_t t_callback = { 0 };
- t_callback.debug = &__video_render_log;
- rvc_video_render_params_t render_param = { 0 };
- render_param.ilocal_view_cx = ctx->Req.env_view_cx;
- render_param.ilocal_view_cy = ctx->Req.env_view_cy;
- render_param.ilocal_view_x = ctx->Req.env_view_x;
- render_param.ilocal_view_y = ctx->Req.env_view_y;
- render_param.iremote_view_cx = ctx->Req.opt_view_cx;
- render_param.iremote_view_cy = ctx->Req.opt_view_cy;
- render_param.iremote_view_x = ctx->Req.opt_view_x;
- render_param.iremote_view_y = ctx->Req.opt_view_y;
- render_param.erender_queue = eSnapshot_Queue;
- m_render->plocal_render = CreateVideoRenderObj(&t_callback);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_VIDEO_RENDER_CREATE, "local video render create.");
- m_render->premote_render = CreateVideoRenderObj(&t_callback);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_VIDEO_RENDER_CREATE, "remote video render create.");
- memcpy(&m_render->render_param, &render_param, sizeof(rvc_video_render_params_t));
- #ifdef RVC_OS_WIN
- m_render->local_render_stop_event = NULL;
- m_render->remote_render_stop_event = NULL;
- m_render->local_render_thread = NULL;
- m_render->remote_render_thread = NULL;
- #else
- m_render->local_render_threadid = 0;
- m_render->remote_render_threadid = 0;
- #endif // RVC_OS_WIN
- rvc_video_box_move_callback_t t_render_callback = { 0 };
- t_render_callback.on_video_box_move = &__on_video_box_move;
- t_render_callback.user_data = this;
- rvc_video_render_window_type_callback_t t_window_type_callback = { 0 };
- t_window_type_callback.on_window_type = &__on_window_type_callback;
- t_window_type_callback.user_data = this;
- memcpy(&m_render->cb, &t_window_type_callback, sizeof(rvc_video_render_window_type_callback_t));
- m_stVideoParam.bShowPersonArea = 0;
- if (Error_Succeed == rvc_start_video_render(m_render, eRender_Local_Both, &t_render_callback)) {
- m_bIsCameraRender = true;
- }
- iRet = 0;
- return iRet;
- }
- //
- // CSIPPhoneSession
- //
- CSIPPhoneSession::CSIPPhoneSession(CSIPEntity* pEntity) : m_pEntity(pEntity), m_pCall(NULL), m_iLastState(0)
- {
- #ifdef RVS_OS_WIN
- 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;
- #endif
- }
- void CSIPPhoneSession::OnClose( ErrorCodeEnum eErrorCode )
- {
- }
- void CSIPPhoneSession::Handle_MakeCall( SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_CALL_URL, CSimpleStringA::Format("make call [%s]", ctx->Req.to_uri.GetData()).GetData());
- int rc = Error_Succeed;
- MakeCallCommand_t *cmd = new MakeCallCommand_t();
- cmd->pSIPPhoneSession = this;
- cmd->toUri = ctx->Req.to_uri;
- cmd->fromUri = ctx->Req.from_uri;
- cmd->callId = ctx->Req.call_id;
- ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
- if (m_pEntity->m_pEndpoint){
- endpoint_destroy(m_pEntity->m_pEndpoint);
- m_pEntity->m_pEndpoint = NULL;
- }
- ErrorCodeEnum Error = m_pEntity->GetLocalIP();
- if (Error != 0){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get local ip failed!");
- ctx->Answer(Error_Unexpect);
- return;
- }
- cmd->strlocalip = m_pEntity->m_localip;
- 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;
-
- CSmartPointer<IEntityFunction> Func = m_pEntity->GetFunction();
- CSimpleStringA strValue("");
- Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
-
- if ('N' != strValue[0]) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Sound Card State %s.", strValue.GetData());
- if ('H' == strValue[0]) {
- m_pEntity->m_iPickupPhoneState = ePickupMicrophoneState_On;
- }
- else if('P' == strValue[0]) {
- m_pEntity->m_iPickupPhoneState = ePickupMicrophoneState_Off;
- }
- m_pEntity->SetMessageBoxFlag(true);
- }
- m_pEntity->m_pEndpoint = endpoint_create(m_pEntity, &m_pEntity->conf, m_pEntity->m_iPickupPhoneState);
- if (!m_pEntity->m_pEndpoint){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
- return;
- }
- else{
- cmd->iaudio_port = new_media_port(m_pEntity->m_pEndpoint);
- cmd->ivideo_port = REC_COMMON_VIDEO_PORT;
- }
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("strUri length equals zero!");
- }
- ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
- if (m_pEntity->GetEndpoint()) {
- 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 )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int rc = Error_Succeed;
- HangupCallCommand_t *cmd = new HangupCallCommand_t();
- cmd->pSIPPhoneSession = this;
- 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 )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int rc = Error_Succeed;
- g_IsExternalTerminalted = true;
- endpoint_invoke(m_pEntity->GetEndpoint(), &__release_call, this, &rc);
- if (NULL != 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)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- m_pEntity->m_nCallType = (CallingTypeEnum)ctx->Info.CallType;
- }
- void CSIPPhoneSession::Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- m_pEntity->m_SipErrorCode = Error_InvalidState;
- m_pEntity->RealSelfCheck();
- }
- void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int rc;
- ControlVideoCommand_t*pCmd = new ControlVideoCommand_t();
- pCmd->pSIPPhoneSession = this;
- pCmd->start = true;
- pCmd->local_hwd_move = 0;
- pCmd->remote_hwd_move = 0;
- #ifdef RVC_OS_WIN
- m_VideoWindowPlayType = eOnline_Mode_Video;
- if (0 == ctx->Info.remote_port){
- m_VideoWindowPlayType = eBoth_Local_Remote_Video;
- m_pEntity->m_nCallType = NORMAL_CALLTYPE;
- if (NULL == m_pEntity->GetEndpoint())
- {
- m_pEntity->InitEndpoint();
- }
- }
- #endif
- 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 = tovalidwidth(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 = tovalidwidth(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;
- #ifdef RVC_OS_WIN
- #else
- pCmd->local_fresh_time = m_pEntity->m_ilocalvideo_freshtime;
- pCmd->remote_fresh_time = m_pEntity->m_iremotevideo_freshtime;
- #endif
- endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
-
- #ifdef RVC_OS_WIN
- m_pEntity->m_stVideoParam.bShowActiveImg = 0;
- m_pEntity->m_stVideoParam.bActiveInspect = 0;
- //初始化窗口参数
- m_pEntity->m_stVideoParam.nWindowState = 0;
- #endif
- }
- void CSIPPhoneSession::Handle_StopVideo( SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int rc;
- ControlVideoCommand_t *pCmd = new ControlVideoCommand_t();
- 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{
- #ifdef RVC_OS_WIN
- endpoint_call_stop_double_record_broadcast_video();
- #endif
- }
-
- m_pEntity->m_stVideoParam.bShowActiveImg = 0;
- m_pEntity->m_stVideoParam.bActiveInspect = 0;
- //初始化窗口参数
- m_pEntity->m_stVideoParam.nWindowState = 0;
- #ifdef RVC_OS_WIN
- m_VideoWindowPlayType = eOnline_Mode_Video;
- #endif
- }
- void CSIPPhoneSession::Handle_StartVideoRender(SpOnewayCallContext<PhoneService_StartVideoRender_Info>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- #ifdef RVC_OS_WIN
- #else
- int rc;
- VideoRenderCommand_t* pCmd = new VideoRenderCommand_t();
- pCmd->pSIPPhoneSession = this;
- pCmd->bstart = true;
- pCmd->local_hwd_move = 0;
- pCmd->remote_hwd_move = 0;
- 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->local_hwd_move = ctx->Info.local_hwd_move;
- pCmd->remote_hwd_move = ctx->Info.remote_hwd_move;
- pCmd->local_fresh_time = m_pEntity->m_ilocalvideo_freshtime;
- pCmd->remote_fresh_time = m_pEntity->m_iremotevideo_freshtime;
-
- if (NULL == m_pEntity->GetEndpoint()) {
- m_pEntity->InitEndpoint();
- }
- endpoint_invoke(m_pEntity->GetEndpoint(), &__video_render, pCmd, &rc);
- #endif
- }
- void CSIPPhoneSession::Handle_StopVideoRender(SpOnewayCallContext<PhoneService_StopVideoRender_Info>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- #ifdef RVC_OS_WIN
- #else
- VideoRenderCommand_t* pCmd = new VideoRenderCommand_t();
- int rc;
- pCmd->pSIPPhoneSession = this;
- pCmd->bstart = false;
- m_pEntity->GetFunction()->KillTimer(1);
- if (NULL != m_pEntity->GetEndpoint()) {
- endpoint_invoke(m_pEntity->GetEndpoint(), &__video_render, pCmd, &rc);
- }
- #endif
- }
- void CSIPPhoneSession::Handle_GetHandfreeInVolume(SpReqAnsContext<PhoneService_GetHandfreeInVolume_Req, PhoneService_GetHandfreeInVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Ans.Volume = m_pEntity->m_kept_volume_in[DEV_HANDFREE];
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_SetHandfreeInVolume(SpReqAnsContext<PhoneService_SetHandfreeInVolume_Req, PhoneService_SetHandfreeInVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int iVolume = ctx->Req.Volume;
- if (iVolume > 100) {
- iVolume = 100;
- }
- if (iVolume < 0) {
- iVolume = 0;
- }
- m_pEntity->SetHandfreeInVolume(iVolume);
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_SetPickupInVolume(SpReqAnsContext<PhoneService_SetPickupInVolume_Req, PhoneService_SetPickupInVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- if (eStand2sType == m_pEntity->m_eDeviceType || eStand1SPlusType == m_pEntity->m_eDeviceType) {
- int iVolume = ctx->Req.Volume;
- if (iVolume > 100) {
- iVolume = 100;
- }
- if (iVolume < 0) {
- iVolume = 0;
- }
- m_pEntity->SetPickupInVolume(iVolume);
- }
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_GetPickupInVolume(SpReqAnsContext<PhoneService_GetPickupInVolume_Req, PhoneService_GetPickupInVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- if (eStand2sType == m_pEntity->m_eDeviceType || eStand1SPlusType == m_pEntity->m_eDeviceType) {
- ctx->Ans.Volume = m_pEntity->m_kept_volume_in[DEV_PICKUP];
- }
- else {
- ctx->Ans.Volume = 0;
- }
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_GetAudioDevices(SpReqAnsContext<PhoneService_GetAudioDevices_Req, PhoneService_GetAudioDevices_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Ans.strHandfreeIn = m_pEntity->conf.audio_handfree_in_dev;
- ctx->Ans.strHandfreeOut = m_pEntity->conf.audio_handfree_out_dev;
- ctx->Ans.strPickupIn = m_pEntity->conf.audio_pickup_in_dev;
- ctx->Ans.strPickupOut = m_pEntity->conf.audio_pickup_out_dev;
- ctx->Ans.retCode = Error_Succeed;
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_StartCameraRender(SpReqAnsContext<PhoneService_StartCameraRender_Req, PhoneService_StartCameraRender_Ans>::Pointer ctx)
- {
- int iRet = m_pEntity->StartCameraRender(ctx->Req.icameraid, ctx->Req.video_view_x, ctx->Req.video_view_y, ctx->Req.video_view_cx, ctx->Req.video_view_cy);
- ctx->Ans.result = iRet;
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_StopCameraRender(SpReqAnsContext<PhoneService_StopCameraRender_Req, PhoneService_StopCameraRender_Ans>::Pointer ctx)
- {
- if (m_pEntity->m_bIsCameraRender) {
- int iRet = m_pEntity->StopCameraRender();
- ctx->Ans.result = iRet;
- }
- else {
- ctx->Ans.result = 0;
- }
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_IsCameraRender(SpReqAnsContext<PhoneService_IsCameraRender_Req, PhoneService_IsCameraRender_Ans>::Pointer ctx)
- {
- ctx->Ans.result = m_pEntity->m_bIsCameraRender;
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_StartBothCameraRender(SpReqAnsContext<PhoneService_StartBothCameraRender_Req, PhoneService_StartBothCameraRender_Ans>::Pointer ctx)
- {
- #ifdef DEVOPS_ON_PRD
- #else
- int iRet = m_pEntity->StartBothCameraRender(ctx);
- ctx->Ans.result = iRet;
- #endif
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_BeginState( SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx )
- {
- m_spCallbackContext = ctx;
- }
- void CSIPPhoneSession::Handle_EndState( SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer tmp_ctx = m_spCallbackContext;
- m_spCallbackContext.Clear();
- }
- void CSIPPhoneSession::Handle_GetHandfreeOutVolume(SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req, PhoneService_GetHandfreeOutVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Ans.Volume = m_pEntity->m_kept_volume_out[DEV_HANDFREE];
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_SetHandfreeOutVolume(SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req, PhoneService_SetHandfreeOutVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int iVolume = ctx->Req.Volume;
- if (iVolume > 100){
- iVolume = 100;
- }
- if (iVolume < 0){
- iVolume = 0;
- }
- m_pEntity->SetHandfreeOutVolume(iVolume);
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_GetPickupOutVolume(SpReqAnsContext<PhoneService_GetPickupOutVolume_Req, PhoneService_GetPickupOutVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- if (eStand2sType == m_pEntity->m_eDeviceType || eStand1SPlusType == m_pEntity->m_eDeviceType){
- ctx->Ans.Volume = m_pEntity->m_kept_volume_out[DEV_PICKUP];
- }
- else{
- ctx->Ans.Volume = 0;
- }
-
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::Handle_SetPickupOutVolume(SpReqAnsContext<PhoneService_SetPickupOutVolume_Req, PhoneService_SetPickupOutVolume_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- if (eStand2sType == m_pEntity->m_eDeviceType || eStand1SPlusType == m_pEntity->m_eDeviceType){
- int iVolume = ctx->Req.Volume;
- if (iVolume > 100) {
- iVolume = 100;
- }
- if (iVolume < 0) {
- iVolume = 0;
- }
- m_pEntity->SetPickupOutVolume(iVolume);
- }
- ctx->Answer(Error_Succeed);
- }
- void CSIPPhoneSession::hangup_call()
- {
- if (m_pCall) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("normal hangup.");
- endpoint_call_hangup(m_pCall);
- }
- }
- void CSIPPhoneSession::release_call()
- {
- if (m_pCall){
- terminatedcall(m_pCall);
- }
- }
- void CSIPPhoneSession::on_call_state(int state, const char *state_desc, const char *phrase)
- {
- if (m_spCallbackContext != NULL)
- {
- PhoneService_PhoneState_Info Info;
- Info.state = state;
- Info.status = CSimpleStringA::Format("%s,%s", state_desc, phrase);
- m_spCallbackContext->SendMessage(Info);
- }
- if (state == e_call_state::TERMINATED)
- {
- if (NULL != m_pCall){
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- }
- }
- m_pEntity->SetState(state);
- }
- int CSIPPhoneSession::make_call( MakeCallCommand_t *pCmd)
- {
- if (m_pCall)
- {
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- }
- {
- endpoint_call_callback_t cb = {0};
- cb.on_call_state = &__on_call_state;
- cb.user_data = this;
- endpoint_call_params_t t_callparam = {0};
- t_callparam.to_uri = pCmd->toUri.GetData();
- t_callparam.call_id = (pCmd->callId.GetLength() > 0) ? pCmd->callId.GetData() : NULL;
- t_callparam.from_uri = (pCmd->fromUri.GetLength() > 0) ? pCmd->fromUri.GetData() : NULL;
- t_callparam.local_ip = (pCmd->strlocalip.GetLength() > 0) ? pCmd->strlocalip.GetData() : NULL;
- t_callparam.ilocal_audio_port = pCmd->iaudio_port;
- t_callparam.ilocal_video_port = pCmd->ivideo_port;
- t_callparam.nDeviceType = m_pEntity->m_eDeviceType;
- t_callparam.nCallType = m_pEntity->m_nCallType;
- m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), &t_callparam, &cb);
- if (m_pCall)
- {
- g_IsExternalTerminalted = false;
- if (endpoint_call_start(m_pCall) == 0)
- {
- return Error_Succeed;
- }
- else
- {
- endpoint_call_destroy(m_pCall);
- m_pCall = NULL;
- return Error_Unexpect;
- }
- }
- else
- {
- g_IsExternalTerminalted = true;
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create call endpoint failed!");
- m_pEntity->m_SipErrorCode = Error_InvalidState;
- m_pEntity->RealSelfCheck();
- return Error_Unexpect;
- }
- }
- }
- #ifdef RVC_OS_WIN
- void CSIPPhoneSession::control_video( ControlVideoCommand_t *pCmd )
- {
- 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 (eBoth_Local_Remote_Video == m_VideoWindowPlayType && m_pEntity->m_nCallType != DOUBLERECORD_CALLTYPE)
- {
- local_play_stop_video(m_pCall);
- 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;
- endpoint_call_params_t t_callparam = {0};
- t_callparam.to_uri = "test";
- t_callparam.call_id = NULL;
- t_callparam.from_uri = NULL;
- t_callparam.local_ip = m_pEntity->m_localip;
- t_callparam.nDeviceType = m_pEntity->m_eDeviceType;
- t_callparam.nCallType = m_pEntity->m_nCallType;
- m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), &t_callparam, &cb);
-
- if (eBoth_Local_Remote_Video == m_VideoWindowPlayType){
- 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{
- endpoint_call_stop_double_record_broadcast_video();
- }
- }
- }
- #else
- void CSIPPhoneSession::control_video( ControlVideoCommand_t *pCmd)
- {
- if (m_pCall)
- {
- if (pCmd->start)
- {
- endpoint_call_param_t callparam = { 0 };
- callparam.remote_ip = pCmd->remote_ip;
- callparam.remote_port = pCmd->remote_port;
- callparam.local_ip = pCmd->local_ip;
- callparam.local_port = pCmd->local_port;
- callparam.remote_width = pCmd->remote_width;
- callparam.remote_height = pCmd->remote_height;
- rvc_video_render_callback_t t_callback = { 0 };
- t_callback.user_data = m_pEntity;
- t_callback.on_remote_video_render = &__remote_video_render_callback;
- t_callback.on_stop_remote_video_render = &__on_stop_remote_video_render_callback;
- endpoint_call_start_video(m_pCall, &callparam, &t_callback);
- if (DOUBLERECORD_CALLTYPE != m_pEntity->m_nCallType) {
- rvc_video_render_params_t render_param = { 0 };
- render_param.ilocal_view_x = pCmd->local_view_x;
- render_param.ilocal_view_y = pCmd->local_view_y;
- render_param.ilocal_view_cx = pCmd->local_view_cx;
- render_param.ilocal_view_cy = pCmd->local_view_cy;
- render_param.iremote_view_x = pCmd->remote_view_x;
- render_param.iremote_view_y = pCmd->remote_view_y;
- render_param.iremote_view_cx = pCmd->remote_view_cx;
- render_param.iremote_view_cy = pCmd->remote_view_cy;
- render_param.ilocal_move = pCmd->local_hwd_move;
- render_param.iremote_move = pCmd->remote_hwd_move;
- render_param.ilocal_fresh_time = pCmd->local_fresh_time;
- render_param.iremote_fresh_time = pCmd->remote_fresh_time;
- render_param.erender_queue = ePreview_Queue;
- start_video_render(&render_param, eRender_Local_Single);
- }
- }
- else {
- endpoint_call_stop_video(m_pCall);
- if (NULL != m_pEntity->m_render) {
- stop_video_render();
- }
- }
- }
- else
- {
- if (pCmd->start)
- {
- endpoint_call_callback_t cb = {0};
- cb.on_call_state = &__on_call_state;
- cb.user_data = this;
- endpoint_call_params_t t_callparam = {0};
- t_callparam.to_uri = "test";
- t_callparam.call_id = NULL;
- t_callparam.from_uri = NULL;
- t_callparam.local_ip = m_pEntity->m_localip;
- t_callparam.nDeviceType = m_pEntity->m_eDeviceType;
- t_callparam.nCallType = m_pEntity->m_nCallType;
- m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), &t_callparam, &cb);
- }
- else {
- if (NULL != m_pEntity->m_render) {
- stop_video_render();
- }
- }
- }
- }
- void CSIPPhoneSession::video_render(VideoRenderCommand_t* pCmd)
- {
- if (true== pCmd->bstart) {
- rvc_video_render_params_t render_param = { 0 };
- render_param.ilocal_view_x = pCmd->local_view_x;
- render_param.ilocal_view_y = pCmd->local_view_y;
- render_param.ilocal_view_cx = pCmd->local_view_cx;
- render_param.ilocal_view_cy = pCmd->local_view_cy;
- render_param.iremote_view_x = pCmd->remote_view_x;
- render_param.iremote_view_y = pCmd->remote_view_y;
- render_param.iremote_view_cx = pCmd->remote_view_cx;
- render_param.iremote_view_cy = pCmd->remote_view_cy;
- render_param.ilocal_move = pCmd->local_hwd_move;
- render_param.iremote_move = pCmd->remote_hwd_move;
- render_param.ilocal_fresh_time = pCmd->local_fresh_time;
- render_param.iremote_fresh_time = pCmd->remote_fresh_time;
- render_param.erender_queue = ePreview_Queue;
- start_video_render(&render_param, eRender_LocalRemote);
- }
- else {
- stop_video_render();
- }
- }
- int CSIPPhoneSession::start_video_render(rvc_video_render_params_t* render_param, eVideoRenderMode eMode)
- {
- m_pEntity->m_render = new rvc_video_render_t();
- videorender_callback_t t_callback = { 0 };
- t_callback.debug = &__video_render_log;
- m_pEntity->m_render->plocal_render = CreateVideoRenderObj(&t_callback);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_VIDEO_RENDER_CREATE, "local video render create.");
- m_pEntity->m_render->premote_render = CreateVideoRenderObj(&t_callback);
- LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_VIDEO_RENDER_CREATE, "remote video render create.");
- memcpy(&m_pEntity->m_render->render_param, render_param, sizeof(rvc_video_render_params_t));
- m_pEntity->m_render->local_render_threadid = 0;
- m_pEntity->m_render->remote_render_threadid = 0;
- rvc_video_box_move_callback_t t_render_callback = { 0 };
- t_render_callback.on_video_box_move = &__on_video_box_move;
- t_render_callback.user_data = this;
- rvc_video_render_window_type_callback_t t_window_type_callback = { 0 };
- t_window_type_callback.on_window_type = &__on_window_type_callback;
- t_window_type_callback.user_data = this->m_pEntity;
- memcpy(&m_pEntity->m_render->cb, &t_window_type_callback, sizeof(rvc_video_render_window_type_callback_t));
- m_pEntity->m_stVideoParam.bShowPersonArea = 0;
- if (Error_Succeed != rvc_start_video_render(m_pEntity->m_render, eMode, &t_render_callback)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video render failed!");
- }
- return 0;
- }
- int CSIPPhoneSession::stop_video_render()
- {
- if (Error_Succeed != rvc_stop_video_render(m_pEntity->m_render)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop video render failed.");
- }
- if (NULL != m_pEntity->m_render->plocal_render) {
- DestroyVideoRenderObj(m_pEntity->m_render->plocal_render);
- }
- if (NULL != m_pEntity->m_render->premote_render) {
- DestroyVideoRenderObj(m_pEntity->m_render->premote_render);
- }
- delete(m_pEntity->m_render);
- m_pEntity->m_render = NULL;
- return 0;
- }
- #endif
- 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);
- }
- 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);
- }
- 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)
- {
- #ifdef RVC_OS_WIN
- if (pEntity->m_pKeeperIn[DEV_HANDFREE])
- #else
- if (pEntity->m_pAudioMgr)
- #endif
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
- }
- #ifdef RVC_OS_WIN
- if (pEntity->m_pKeeperOut[DEV_HANDFREE])
- #else
- if (pEntity->m_pAudioMgr)
- #endif
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
- }
- #ifdef RVC_OS_WIN
- if (pEntity->m_pKeeperOut[DEV_PICKUP])
- #else
- if (pEntity->m_pAudioMgr)
- #endif
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
- }
- #ifdef RVC_OS_WIN
- if (pEntity->m_pKeeperIn[DEV_PICKUP])
- #else
- if (pEntity->m_pAudioMgr)
- #endif
- {
- pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
- }
- }
- }
- }
- void ChannelSipphoneClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
- {
- 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);
- }
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CSIPEntity)
- SP_END_ENTITY_MAP()
|