mod_sipphone.cpp 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546
  1. #include "stdafx.h"
  2. #include "pthread.h"
  3. #include "endpoint.h"
  4. #include "mod_sipphone.h"
  5. #include "../mod_agentip/sysvar.h"
  6. #include "../mod_facetracking/sysvar.h"
  7. #include "sockutil.h"
  8. #include "rec_common.h"
  9. #include "audio_session.h"
  10. #include "video_session.h"
  11. //#include "volumekeeper.h"
  12. #define EVT_CONVERTER "EventConverter"
  13. #define DEVICE_HANDFREE_OUT 0
  14. #define DEVICE_PICKUP_OUT 1
  15. #define DEVICE_HANDFREE_IN 2
  16. #define DEVICE_PICKUP_IN 3
  17. #ifndef DEFAULT_RECORD_VIDEO_WIDTH
  18. #define DEFAULT_RECORD_VIDEO_WIDTH 1056
  19. #endif
  20. #ifndef DEFAULT_RECORD_VIDEO_HEIGHT
  21. #define DEFAULT_RECORD_VIDEO_HEIGHT 595
  22. #endif
  23. #ifndef SMALL_RECORD_VIDEO_WIDTH
  24. #define SMALL_RECORD_VIDEO_WIDTH 244
  25. #endif
  26. #ifndef SMALL_RECORD_VIDEO_HEIGHT
  27. #define SMALL_RECORD_VIDEO_HEIGHT 138
  28. #endif
  29. /////////////////////////////////////////////
  30. // future roadmap
  31. // 1. 使用session timer
  32. // 2. 增强稳定性
  33. // 3. 健康检查里面触发 主备服务器切换(switch between freeswitchs) 定时发送options ping switch server
  34. /////////////////////////////////////////////
  35. extern BOOL g_IsExternalTerminalted;
  36. extern BOOL g_bIsSalesRecord;
  37. extern BOOL g_bEwsRecord;
  38. static void __on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom, void *user_data)
  39. {
  40. CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
  41. pThis->on_video_box_move(imessagetype, ivideotype, ileft, ibottom);
  42. }
  43. CSIPPhoneSession::CSIPPhoneSession(CSIPEntity *pEntity) : m_pEntity(pEntity), m_pCall(NULL), m_iLastState(0),m_IsLocalPlay(0),m_VideoWindowPlayType(eOnline_Mode_Video)
  44. {
  45. m_cb_video_box_move.on_video_box_move = &__on_video_box_move;
  46. m_cb_video_box_move.user_data = this;
  47. }
  48. static void __on_call_state(int state, const char *state_desc, const char *phrase, void *user_data)
  49. {
  50. CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
  51. if (pThis->m_iLastState != state) {
  52. pThis->m_iLastState = state;
  53. pThis->on_call_state(state, state_desc, phrase);
  54. }
  55. }
  56. static int __make_call(void *user_data)
  57. {
  58. MakeCallCommand *cmd = (MakeCallCommand*)user_data;
  59. int rc = cmd->pSIPPhoneSession->make_call(cmd->strUri);
  60. delete cmd;
  61. return rc;
  62. }
  63. static int __hangup_call(void *user_data)
  64. {
  65. HangupCallCommand *cmd = (HangupCallCommand*)(user_data);
  66. cmd->pSIPPhoneSession->hangup_call(/*cmd*/);
  67. delete cmd;
  68. return 0;
  69. }
  70. static int __control_video(void *arg)
  71. {
  72. ControlVideoCommand *pCmd = (ControlVideoCommand*)(arg);
  73. pCmd->pSIPPhoneSession->control_video(pCmd);
  74. delete pCmd;
  75. return 0;
  76. }
  77. static int __release_call(void *user_data)
  78. {
  79. CSIPPhoneSession *pThis = static_cast<CSIPPhoneSession*>(user_data);
  80. pThis->release_call();
  81. pThis->on_call_state(TERMINATED,"STATE:terminated","byebye");
  82. return 0;
  83. }
  84. CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhoneState(ePickupMicrophoneState_Off)
  85. {
  86. m_kept_volume_in[0] = m_kept_volume_in[1] = 0;
  87. m_kept_volume_out[0] = m_kept_volume_out[1] = 0;
  88. #ifdef RVC_OS_WIN
  89. m_pKeeperIn[0] = m_pKeeperIn[1] = NULL;
  90. m_pKeeperOut[0] = m_pKeeperOut[1] = NULL;
  91. #endif
  92. m_SipErrorCode = Error_Succeed;
  93. memset((void*)&m_stVideoParam,0,sizeof(stVideoParam));
  94. m_ilocalvideo_freshtime = 200;
  95. }
  96. void CSIPEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  97. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  98. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage)
  99. {
  100. LOG_TRACE("user_code = 0x%08x", dwUserCode);
  101. switch (dwUserCode)
  102. {
  103. case LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE:
  104. {
  105. Dbg("recv LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE");
  106. if (m_pSipphoneChannel != NULL)
  107. {
  108. m_pSipphoneChannel->GetFunction()->CloseSession();
  109. m_pSipphoneChannel = NULL;
  110. Dbg("Close AssistChannel Session ");
  111. }
  112. ErrorCodeEnum Error;
  113. if (m_pSipphoneChannel == NULL)
  114. {
  115. Dbg("ReConnection AssistChannel Session");
  116. m_pSipphoneChannel = new ChannelSipphoneClient(this);
  117. Error = m_pSipphoneChannel->Connect();
  118. if (Error != Error_Succeed)
  119. {
  120. m_pSipphoneChannel->SafeDelete();
  121. Dbg("ChannelSipphoneClient connect fail!");
  122. }
  123. if (Error == Error_Succeed)
  124. {
  125. ChannelService_BeginState_Sub Sub;
  126. Error = m_pSipphoneChannel->BeginState(Sub);
  127. if (Error != Error_Succeed)
  128. {
  129. LOG_TRACE("BeginState biz channel failed!");
  130. m_pSipphoneChannel->GetFunction()->CloseSession();
  131. m_pSipphoneChannel = NULL;
  132. }
  133. }
  134. if (Error == Error_Succeed)
  135. {
  136. ChannelService_BeginRecv_Sub Sub;
  137. Sub.type = ACM_TYPE_DEVICE;
  138. Error = m_pSipphoneChannel->BeginRecv(Sub);
  139. if (Error != Error_Succeed)
  140. {
  141. Dbg("Begin BeginRecv ACM_TYPE_DEVICE failed!");
  142. m_pSipphoneChannel->GetFunction()->CloseSession();
  143. m_pSipphoneChannel = NULL;
  144. }
  145. }
  146. }
  147. }
  148. break;
  149. case EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP:
  150. case EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP:
  151. case EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE:
  152. case EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE:
  153. case EVENT_MOD_CONNECT_PICKUP_CALL:
  154. case EVENT_MOD_CONNECT_SLV_HANDFREECALL:
  155. case EVENT_MOD_CONNECT_SLV_PICKUPCALL:
  156. case LOG_EVT_HANDFREE_MODE_REMOTE_CALL:
  157. case LOG_EVT_PICKUP_MODE_REMOTE_CALL:
  158. {
  159. int old_state = m_iPickupPhoneState;
  160. if (dwUserCode == EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP) { // 免提->提机
  161. m_iPickupPhoneState = ePickupMicrophoneState_On;
  162. }
  163. else if (dwUserCode == EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP) { //坐席控制免提->提机
  164. m_iPickupPhoneState = ePickupMicrophoneState_On;
  165. }
  166. else if (dwUserCode == EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE) { //坐席控制提机->免提
  167. m_iPickupPhoneState = ePickupMicrophoneState_Off;
  168. }
  169. else if (dwUserCode == EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE)
  170. { // // 提机->免提
  171. m_iPickupPhoneState = ePickupMicrophoneState_Off;
  172. }
  173. else if (dwUserCode == EVENT_MOD_CONNECT_PICKUP_CALL)
  174. { // 提机拨号
  175. m_iPickupPhoneState = ePickupMicrophoneState_On;
  176. }
  177. else if (dwUserCode == EVENT_MOD_CONNECT_SLV_HANDFREECALL)
  178. { // 免提拨号
  179. m_iPickupPhoneState = ePickupMicrophoneState_Off;
  180. }
  181. else if (dwUserCode == EVENT_MOD_CONNECT_SLV_PICKUPCALL)
  182. {
  183. // 通过界面拨号,但话筒未挂,进入提机拨号
  184. m_iPickupPhoneState = ePickupMicrophoneState_On;
  185. }
  186. else if (dwUserCode == LOG_EVT_HANDFREE_MODE_REMOTE_CALL)
  187. { // 免提模式开始远程双录连线
  188. m_iPickupPhoneState = ePickupMicrophoneState_Off;
  189. }
  190. else if (dwUserCode == LOG_EVT_PICKUP_MODE_REMOTE_CALL)
  191. {
  192. // 话筒模式开始远程双录连线
  193. m_iPickupPhoneState = ePickupMicrophoneState_On;
  194. }
  195. LOG_TRACE("dwUserCode = 0x%08x,m_iPickupPhoneState %d", dwUserCode, m_iPickupPhoneState);
  196. Dbg("dwUserCode = 0x%08x,old_PhoneState = %d,PickupPhoneState = %d", dwUserCode,old_state, m_iPickupPhoneState);
  197. if (old_state != m_iPickupPhoneState)
  198. {
  199. if (m_iPickupPhoneState == ePickupMicrophoneState_On)
  200. {
  201. SwitchPickup();
  202. }
  203. else
  204. {
  205. SwitchHandFree();
  206. }
  207. }
  208. }
  209. break;
  210. case LOG_EVT_ENTER_ACM_FLOW:
  211. {
  212. Dbg("LOG_EVT_ENTER_ACM_FLOW");
  213. m_stVideoParam.nWindowState = 1;
  214. }
  215. break;
  216. case LOG_EVT_EXIT_ACM_FLOW:
  217. {
  218. Dbg("LOG_EVT_EXIT_ACM_FLOW");
  219. if(m_stVideoParam.nWindowState == 1)
  220. {
  221. m_stVideoParam.nWindowState = 0;
  222. }
  223. }
  224. break;
  225. case LOG_EVT_STARTLIVEDETECTDISPLAY:
  226. {
  227. Dbg("start livedetection display");
  228. m_stVideoParam.bActiveInspect = 1;
  229. }
  230. break;
  231. case LOG_EVT_STOPLIVEDETECTDISPLAY:
  232. {
  233. Dbg("stop livedetection display and show livedetection photo %s",pszMessage);
  234. }
  235. break;
  236. case LOG_EVT_CHANGELIVEDETECTIONCAM:
  237. {
  238. if (pszMessage && strlen(pszMessage) > 0)
  239. {
  240. int i = atoi(pszMessage);
  241. Dbg("change active display camera to %d",i);
  242. m_stVideoParam.iCameraSwitch = i;
  243. }
  244. else
  245. {
  246. Dbg("change active display camera param error");
  247. }
  248. }
  249. break;
  250. case LOG_EVT_RELEASELIVEDETECTION:
  251. {
  252. Dbg("release show active image");
  253. m_stVideoParam.bActiveInspect = 0;
  254. m_stVideoParam.bShowActiveImg = 0;
  255. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
  256. }
  257. break;
  258. case LOG_EVT_UI_HIDEONLINEVIDEO:
  259. {
  260. Dbg("Receive UI hide online video evt!");
  261. m_stVideoParam.nWindowState = 2;
  262. }
  263. break;
  264. case LOG_EVT_UI_SHOWONLINEVIDEO:
  265. {
  266. Dbg("Receive UI show online video evt!");
  267. if (m_stVideoParam.nWindowState == 2)
  268. {
  269. m_stVideoParam.nWindowState = 3;
  270. }
  271. }
  272. break;
  273. case LOG_EVT_UI_STARTRECORD:
  274. case LOG_EVT_UI_STARTREMOTERECORD:
  275. {
  276. Dbg("start sales record video.");
  277. m_bIsSalesRecord = TRUE;
  278. g_bIsSalesRecord = m_bIsSalesRecord;
  279. m_bEwsRecord = FALSE;
  280. if (strlen(pszMessage)>=4&&!strnicmp(pszMessage,"ews|",4)){
  281. m_bEwsRecord = TRUE;
  282. }
  283. g_bEwsRecord = m_bEwsRecord;
  284. }
  285. break;
  286. case LOG_EVT_UI_STARTRECORDPREVIEW:
  287. {
  288. Dbg("start sales record preview.");
  289. m_stVideoParam.bShowRecordArea = 1;
  290. Handle_RecordVideoLocation_Info(pszMessage);
  291. }
  292. break;
  293. case LOG_EVT_UI_STOPRECORD:
  294. case LOG_EVT_UI_STOPREMOTERECORD:
  295. {
  296. Dbg("stop sales record video.");
  297. m_bIsSalesRecord = FALSE;
  298. g_bIsSalesRecord = m_bIsSalesRecord;
  299. m_bEwsRecord = FALSE; //add by ly@2019/04/18
  300. g_bEwsRecord = m_bEwsRecord; //add by ly@2019/04/18
  301. if (m_stVideoParam.bShowRecordArea){
  302. Dbg("stop sales record and stop preview.");
  303. m_stVideoParam.bShowRecordArea = 0;
  304. }
  305. }
  306. break;
  307. case LOG_EVT_UI_STOPRECORDPREVIEW:
  308. {
  309. Dbg("stop sales record preview.");
  310. m_stVideoParam.bShowRecordArea = 0;
  311. }
  312. break;
  313. case LOG_EVT_UI_RETURNMENU:
  314. {
  315. Dbg("return menu");
  316. m_bIsSalesRecord = FALSE;
  317. g_bIsSalesRecord = m_bIsSalesRecord;
  318. m_bEwsRecord = FALSE; //add by ly@2019/04/18
  319. g_bEwsRecord = m_bEwsRecord; //add by ly@2019/04/18
  320. }
  321. break;
  322. case LOG_EVT_UI_SHOWLOCALVIDEO:
  323. {
  324. Dbg("Receive UI show all video evt!");
  325. if (m_stVideoParam.nWindowState == 4)
  326. {
  327. m_stVideoParam.nWindowState = 3;
  328. }
  329. }
  330. break;
  331. case LOG_EVT_UI_HIDELOCALVIDEO:
  332. {
  333. Dbg("Receive UI hide local video evt!");
  334. m_stVideoParam.nWindowState = 4;
  335. }
  336. break;
  337. case LOG_EVT_UI_HIDEPERSONAREA:
  338. {
  339. Dbg("Receive UI hide person area!");
  340. m_stVideoParam.bShowPersonArea = 0;
  341. }
  342. break;
  343. case LOG_EVT_UI_SHOWPERSONAREA:
  344. {
  345. Dbg("Receive UI show person area!");
  346. m_stVideoParam.bShowPersonArea = 1;
  347. }
  348. break;
  349. case EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST:
  350. {
  351. Dbg("stop remote record audio broadcast.");
  352. }
  353. break;
  354. case EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL:
  355. {
  356. Dbg("begin double record call.");
  357. }
  358. break;
  359. case LOG_EVT_UI_ADJUSTVIDEOECHOSIZE:
  360. {
  361. Dbg("adjust video echo size %s.", pszMessage);
  362. Handle_AdjustVideoEchoEvent(pszMessage);
  363. }
  364. break;
  365. default:
  366. {
  367. Dbg("unknown dwUserCode = 0x%08x.",dwUserCode);
  368. }
  369. break;
  370. }
  371. }
  372. void CSIPEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName)
  373. {
  374. if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 0)
  375. {
  376. Dbg("camera state from : %c to %c", pszOldValue[0], pszValue[0]);
  377. if (pszValue[0] == 'E')
  378. {
  379. m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
  380. }
  381. else if (pszValue[0] == 'O')
  382. {
  383. m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
  384. }
  385. else if(pszValue[0] == 'B') ///////显示贴图
  386. {
  387. /////////////////////////此处显示贴图//////////////////////////////////
  388. //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
  389. m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
  390. }
  391. else if (pszValue[0] == 'N')
  392. {
  393. m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
  394. //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
  395. }
  396. }
  397. else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
  398. {
  399. Dbg("active camera from : %c to %c", pszOldValue[0], pszValue[0]);
  400. if (pszValue[0] == 'E')
  401. {
  402. m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
  403. }
  404. else if (pszValue[0] == 'O')
  405. {
  406. m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
  407. }
  408. else
  409. {
  410. Dbg("warning: unknown ActiveTrackingCamera value!");
  411. }
  412. }
  413. else if (_stricmp(pszKey, SYSVAR_AGENTCAMERASWITCH) == 0)
  414. {
  415. Dbg("agent camera switch from : %c to %c", pszOldValue[0], pszValue[0]);
  416. if((pszValue[0] == 'E')/*&&((m_iCameraState==CAMERA_TYPE_AUTO)||(m_iCameraState==CAMERA_TYPE_ENV))*/)
  417. {
  418. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
  419. }
  420. else if((pszValue[0] == 'O')/*&&((m_iCameraState==CAMERA_TYPE_AUTO)||(m_iCameraState==CAMERA_TYPE_OPT))*/)
  421. {
  422. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
  423. }
  424. else if((pszValue[0] == 'A')/*&&(m_iCameraState==CAMERA_TYPE_AUTO)*/)
  425. {
  426. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
  427. }
  428. }
  429. else if (_stricmp(pszKey, SYSVAR_CALLTYPE) == 0)
  430. {
  431. Dbg("sys calltype from: %c to %c", pszOldValue[0], pszValue[0]);
  432. if(pszValue[0] == CALLTYPE_NORMAL)
  433. {
  434. m_nSysCallType = 0;
  435. }
  436. else if(pszValue[0] == CALLTYPE_MOBILE)
  437. {
  438. m_nSysCallType = 1;
  439. }
  440. else
  441. {
  442. m_nSysCallType =-1;
  443. }
  444. }
  445. }
  446. void CSIPEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  447. {
  448. if (Test_ShakeHand == eTestType)
  449. {
  450. pTransactionContext->SendAnswer(m_SipErrorCode);
  451. }
  452. }
  453. void CSIPEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  454. {
  455. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  456. pTransactionContext->SendAnswer(Error);
  457. LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTED, "sipphone entity started.");
  458. }
  459. void CSIPEntity::OnStarted()
  460. {
  461. ErrorCodeEnum Error = Error_Succeed;
  462. m_pSelfcheckClient = new SelfChekerClient(this);
  463. Error = m_pSelfcheckClient->Connect();
  464. if (Error != Error_Succeed)
  465. {
  466. m_pSelfcheckClient->SafeDelete();
  467. m_pSelfcheckClient = NULL;
  468. Dbg("SelfcheckClient connect fail!");
  469. }
  470. else
  471. {
  472. Dbg("SelfcheckClient connect success!");
  473. }
  474. }
  475. static void __audiomgrlog(void* user_data, const char* fmt, va_list arg)
  476. {
  477. vDbg(fmt, arg);
  478. }
  479. ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
  480. {
  481. ErrorCodeEnum Error;
  482. //MessageBoxA(0,0,0,0);
  483. m_nCallType = NORMAL_CALLTYPE;
  484. m_nSysCallType = 0;
  485. m_pSipphoneChannel = new ChannelSipphoneClient(this);
  486. memset(m_localip,0,256);
  487. Error = m_pSipphoneChannel->Connect();
  488. if (Error != Error_Succeed)
  489. {
  490. m_pSipphoneChannel->SafeDelete();
  491. Dbg("ChannelSipphoneClient connect fail!");
  492. return Error;
  493. }
  494. {
  495. ChannelService_BeginState_Sub Sub;
  496. Error = m_pSipphoneChannel->BeginState(Sub);
  497. if (Error != Error_Succeed)
  498. {
  499. LOG_TRACE("BeginState biz channel failed!");
  500. m_pSipphoneChannel->GetFunction()->CloseSession();
  501. m_pSipphoneChannel = NULL;
  502. return Error;
  503. }
  504. }
  505. {
  506. ChannelService_BeginRecv_Sub Sub;
  507. Sub.type = ACM_TYPE_DEVICE;
  508. Error = m_pSipphoneChannel->BeginRecv(Sub);
  509. if (Error != Error_Succeed)
  510. {
  511. Dbg("Begin BeginRecv ACM_TYPE_DEVICE failed!");
  512. m_pSipphoneChannel->GetFunction()->CloseSession();
  513. m_pSipphoneChannel = NULL;
  514. return Error;
  515. }
  516. }
  517. {
  518. ChannelService_BeginRecv_Sub Sub;
  519. Sub.type = ACM_TYPE_VIDEOFREQ;
  520. Error = m_pSipphoneChannel->BeginRecv(Sub);
  521. if (Error != Error_Succeed)
  522. {
  523. Dbg("Begin BeginRecv ACM_TYPE_VIDEOFREQ failed!");
  524. m_pSipphoneChannel->GetFunction()->CloseSession();
  525. m_pSipphoneChannel = NULL;
  526. return Error;
  527. }
  528. }
  529. {
  530. m_pSelfcheckClient = new SelfChekerClient(this);
  531. Error = m_pSelfcheckClient->Connect();
  532. if (Error != Error_Succeed)
  533. {
  534. m_pSelfcheckClient->SafeDelete();
  535. m_pSelfcheckClient = NULL;
  536. Dbg("SelfcheckClient connect fail!");
  537. }
  538. else
  539. {
  540. Dbg("SelfcheckClient connect success!");
  541. }
  542. }
  543. #ifdef RVC_OS_LINUX
  544. {
  545. audiomgr_callback_t t_callback = { 0 };
  546. t_callback.debug = &__audiomgrlog;
  547. m_pAudioMgr = CreateAudioMgrObj(&t_callback);
  548. if (0 == m_pAudioMgr->audio_mgr_initialize()) {
  549. Dbg("Audio Manager Initialize success!");
  550. }
  551. else {
  552. Dbg("Audio Manager Initialize failed!");
  553. return Error_Param;
  554. }
  555. }
  556. #endif
  557. m_eDeviceType = RvcGetDeviceType();
  558. m_stVideoParam.bActiveInspect = 0;
  559. m_stVideoParam.bShowActiveImg = 0;
  560. m_bIsSalesRecord = FALSE;
  561. g_bIsSalesRecord = m_bIsSalesRecord;
  562. m_bEwsRecord = FALSE;
  563. g_bEwsRecord = m_bEwsRecord;
  564. m_stVideoParam.nWindowState = 0;
  565. m_RecordVideoLocation.x = 0;
  566. m_RecordVideoLocation.y = 0;
  567. m_RecordVideoLocation.width = DEFAULT_RECORD_VIDEO_WIDTH;
  568. m_RecordVideoLocation.height = DEFAULT_RECORD_VIDEO_HEIGHT;
  569. video_lib_init();
  570. audio_lib_init();
  571. endpoint_init_lib();
  572. Error = GetLocalIP();
  573. if (Error != 0)
  574. {
  575. LOG_TRACE("get local ip failed!");
  576. CSimpleStringA strErrMsg = "获取 IP 地址失败,请检查本地网络是否连接!";
  577. LogWarn(Severity_Middle, Error_NetBroken, 0, strErrMsg);
  578. return Error;
  579. }
  580. #ifdef RVC_OS_LINUX
  581. RvcGetAudioDeviceInfo();
  582. #endif
  583. Error = LoadConfig(&conf);
  584. if (Error != Error_Succeed)
  585. {
  586. LOG_TRACE("load config failed!");
  587. return Error;
  588. }
  589. int nhandfreeout = 0;
  590. int npickupout = 0;
  591. int nhanfreein = 0;
  592. int npickupin = 0;
  593. Error = LoadAudioRunConfig(nhandfreeout,npickupout,nhanfreein,npickupin);
  594. if (Error == Error_Succeed)
  595. {
  596. if (nhandfreeout > 0)
  597. {
  598. m_kept_volume_out[DEV_HANDFREE] = nhandfreeout;
  599. }
  600. if (npickupout > 0)
  601. {
  602. m_kept_volume_out[DEV_PICKUP] = npickupout;
  603. }
  604. if (nhanfreein > 0)
  605. {
  606. m_kept_volume_in[DEV_HANDFREE] = nhanfreein;
  607. }
  608. if (npickupin > 0)
  609. {
  610. m_kept_volume_in[DEV_PICKUP] = npickupin;
  611. }
  612. }
  613. #ifdef RVC_OS_LINUX
  614. RvcSetSaveAudioVolume();
  615. #endif
  616. {
  617. CSmartPointer<IEntityFunction> Func = GetFunction();
  618. Func->GetSystemStaticInfo(staticInfo);
  619. }
  620. CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
  621. if (strUri.GetLength() > 0)
  622. {
  623. strcpy(conf.uri, strUri);
  624. conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
  625. conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
  626. m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
  627. if (!m_pEndpoint) {
  628. LOG_TRACE("create endpoint failed!");
  629. return Error_Unexpect;
  630. }
  631. else{
  632. Dbg("%s:%d call uri is %s, endpoint_create m_pEndpoint addr is 0x%08x.", __FUNCTION__, __LINE__, conf.uri, m_pEndpoint);
  633. }
  634. }
  635. else
  636. {
  637. LOG_TRACE("strUri length equals zero!");
  638. return Error_Unexpect;
  639. }
  640. {
  641. CSmartPointer<IEntityFunction> Func = GetFunction();
  642. CUUID id;
  643. int i = 0;
  644. m_arrListener.Init(32);
  645. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP, EVT_CONVERTER);
  646. m_arrListener[i++] = id;
  647. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE, EVT_CONVERTER);
  648. m_arrListener[i++] = id;
  649. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_CALL, EVT_CONVERTER);
  650. m_arrListener[i++] = id;
  651. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_SLV_HANDFREECALL,NULL,false);
  652. m_arrListener[i++] = id;
  653. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_SLV_PICKUPCALL,NULL,false);
  654. m_arrListener[i++] = id;
  655. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP,NULL,false);
  656. m_arrListener[i++] = id;
  657. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE,NULL,false);
  658. m_arrListener[i++] = id;
  659. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE,NULL,false);
  660. m_arrListener[i++] = id;
  661. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_ENTER_ACM_FLOW,NULL,false);
  662. m_arrListener[i++] = id;
  663. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_EXIT_ACM_FLOW,NULL,false);
  664. m_arrListener[i++] = id;
  665. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_STARTLIVEDETECTDISPLAY,NULL,false);
  666. m_arrListener[i++] = id;
  667. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_STOPLIVEDETECTDISPLAY,NULL,false);
  668. m_arrListener[i++] = id;
  669. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_CHANGELIVEDETECTIONCAM,NULL,false);
  670. m_arrListener[i++] = id;
  671. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_RELEASELIVEDETECTION,NULL,false);
  672. m_arrListener[i++] = id;
  673. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDEONLINEVIDEO,NULL,false);
  674. m_arrListener[i++] = id;
  675. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWONLINEVIDEO,NULL,false);
  676. m_arrListener[i++] = id;
  677. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTRECORD,NULL,false);
  678. m_arrListener[i++] = id;
  679. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPRECORD,NULL,false);
  680. m_arrListener[i++] = id;
  681. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_RETURNMENU,NULL,false);
  682. m_arrListener[i++] = id;
  683. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDELOCALVIDEO,NULL,false);
  684. m_arrListener[i++] = id;
  685. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWLOCALVIDEO,NULL,false);
  686. m_arrListener[i++] = id;
  687. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_HIDEPERSONAREA,NULL,false);
  688. m_arrListener[i++] = id;
  689. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_SHOWPERSONAREA,NULL,false);
  690. m_arrListener[i++] = id;
  691. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST,NULL,false);
  692. m_arrListener[i++] = id;
  693. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL,NULL,false);
  694. m_arrListener[i++] = id;
  695. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD,NULL,false);
  696. m_arrListener[i++] = id;
  697. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD,NULL,false);
  698. m_arrListener[i++] = id;
  699. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_HANDFREE_MODE_REMOTE_CALL,NULL,false);
  700. m_arrListener[i++] = id;
  701. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_PICKUP_MODE_REMOTE_CALL,NULL,false);
  702. m_arrListener[i++] = id;
  703. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTRECORDPREVIEW,NULL,false);
  704. m_arrListener[i++] = id;
  705. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPRECORDPREVIEW,NULL,false);
  706. m_arrListener[i++] = id;
  707. Func->SubscribeLog(id, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_ADJUSTVIDEOECHOSIZE,NULL,false);
  708. m_arrListener[i++] = id;
  709. }
  710. {
  711. CSmartPointer<IEntityFunction> Func = GetFunction();
  712. CSimpleStringA strValue;
  713. Func->RegistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA, this);
  714. Func->GetSysVar(SYSVAR_ACTIVETRACKINGCAMERA, strValue);
  715. if (strValue[0] == 'E')
  716. {
  717. m_stVideoParam.iActiveCamera = CAMERA_TYPE_ENV;
  718. }
  719. else if (strValue[0] == 'O')
  720. {
  721. m_stVideoParam.iActiveCamera = CAMERA_TYPE_OPT;
  722. }
  723. else
  724. {
  725. assert(0);
  726. }
  727. }
  728. {
  729. CSmartPointer<IEntityFunction> Func = GetFunction();
  730. CSimpleStringA strValue;
  731. Func->RegistSysVarEvent(SYSVAR_CAMERASTATE, this);
  732. Func->GetSysVar(SYSVAR_CAMERASTATE, strValue);
  733. if (strValue[0] == 'E')
  734. {
  735. m_stVideoParam.iCameraState = CAMERA_TYPE_OPT;
  736. }
  737. else if (strValue[0] == 'O')
  738. {
  739. m_stVideoParam.iCameraState = CAMERA_TYPE_ENV;
  740. }
  741. else if(strValue[0] == 'B') ///////显示贴图
  742. {
  743. /////////////////////////此处显示贴图//////////////////////////////////
  744. //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ERROR;
  745. m_stVideoParam.iCameraState = CAMERA_TYPE_ERROR;
  746. }
  747. else if (strValue[0] == 'N')
  748. {
  749. //m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
  750. m_stVideoParam.iCameraState = CAMERA_TYPE_AUTO;
  751. }
  752. }
  753. {
  754. CSmartPointer<IEntityFunction> Func = GetFunction();
  755. CSimpleStringA strValue;
  756. Func->RegistSysVarEvent(SYSVAR_AGENTCAMERASWITCH, this);
  757. Func->GetSysVar(SYSVAR_AGENTCAMERASWITCH, strValue);
  758. if((strValue[0] == 'E')/*&&((m_iCameraState == CAMERA_TYPE_AUTO)||(m_iCameraState = CAMERA_TYPE_ENV))*/)
  759. {
  760. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_ENV;
  761. }
  762. else if((strValue[0] == 'O')/*&&((m_iCameraState == CAMERA_TYPE_AUTO)||(m_iCameraState = CAMERA_TYPE_OPT))*/)
  763. {
  764. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_OPT;
  765. }
  766. else if ((strValue[0] == 'A')/*&&(m_iCameraState == CAMERA_TYPE_AUTO)*/)
  767. {
  768. m_stVideoParam.iCameraSwitch = CAMERA_TYPE_AUTO;
  769. }
  770. }
  771. {
  772. CSmartPointer<IEntityFunction> Func = GetFunction();
  773. CSimpleStringA strValue;
  774. Func->RegistSysVarEvent(SYSVAR_CALLTYPE, this);
  775. Func->GetSysVar(SYSVAR_CALLTYPE, strValue);
  776. if (strValue[0] == CALLTYPE_NORMAL)
  777. {
  778. m_nSysCallType = 0;
  779. }
  780. else if (strValue[0] == CALLTYPE_MOBILE)
  781. {
  782. m_nSysCallType = 1;
  783. }
  784. else
  785. {
  786. assert(0);
  787. }
  788. }
  789. #ifdef RVC_OS_WIN
  790. if (m_kept_volume_in[DEV_HANDFREE])
  791. {
  792. m_pKeeperIn[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_in_dev, 1, m_kept_volume_in[DEV_HANDFREE]);
  793. if (m_pKeeperIn[DEV_HANDFREE])
  794. {
  795. Dbg("HANDFREE in volume keeper create ok! %d", m_kept_volume_in[DEV_HANDFREE]);
  796. }
  797. else
  798. {
  799. Dbg("HANDFREE in volume keeper create failed!");
  800. }
  801. }
  802. if (m_kept_volume_out[DEV_HANDFREE])
  803. {
  804. m_pKeeperOut[DEV_HANDFREE] = volume_keeper_create(conf.audio_handfree_out_dev, 0, m_kept_volume_out[DEV_HANDFREE]);
  805. if (m_pKeeperOut[DEV_HANDFREE])
  806. {
  807. Dbg("HANDFREE out volume keeper create ok! %d", m_kept_volume_out[DEV_HANDFREE]);
  808. }
  809. else
  810. {
  811. Dbg("HANDFREE out volume keeper create failed!");
  812. }
  813. }
  814. if (m_kept_volume_in[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)) //pad版屏蔽pickup
  815. {
  816. m_pKeeperIn[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_in_dev, 1, m_kept_volume_in[DEV_PICKUP]);
  817. if (m_pKeeperIn[DEV_PICKUP])
  818. {
  819. Dbg("PICKUP in volume keeper create ok! %d", m_kept_volume_in[DEV_PICKUP]);
  820. }
  821. else
  822. {
  823. Dbg("PICKUP in volume keeper create failed!");
  824. }
  825. }
  826. if (m_kept_volume_out[DEV_PICKUP]&&(eStand2sType == m_eDeviceType)) //pad版屏蔽pickup
  827. {
  828. m_pKeeperOut[DEV_PICKUP] = volume_keeper_create(conf.audio_pickup_out_dev, 0, m_kept_volume_out[DEV_PICKUP]);
  829. if (m_pKeeperOut[DEV_PICKUP])
  830. {
  831. Dbg("PICKUP out volume keeper create ok! %d", m_kept_volume_out[DEV_PICKUP]);
  832. }
  833. else
  834. {
  835. Dbg("PICKUP out volume keeper create failed!");
  836. }
  837. }
  838. #else
  839. #endif // RVC_OS_WIN
  840. return Error_Succeed;
  841. }
  842. video_session_t *video_session;
  843. void CSIPEntity::OnReceivePkt(int type, int sub_type, const char *buffer, int size)
  844. {
  845. if (type == ACM_TYPE_DEVICE)
  846. {
  847. if (sub_type == ACM_SET_HANDFREE_OUTVOLUMN)
  848. {
  849. CVolumnValue num;
  850. SpBuffer buf;
  851. buf.OpenRead(buffer,size);
  852. num.Serialize(buf);
  853. Dbg("recv adj handfree out volumn = %d",num.nValue);
  854. #ifdef RVC_OS_WIN
  855. if (m_pKeeperOut[DEV_HANDFREE])
  856. {
  857. volume_keeper_change(m_pKeeperOut[DEV_HANDFREE], num.nValue);
  858. m_kept_volume_out[DEV_HANDFREE] = num.nValue;
  859. SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
  860. 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]);
  861. }
  862. else
  863. {
  864. Dbg("HANDFREE out volume keeper create failed!");
  865. }
  866. #else
  867. if (m_pAudioMgr)
  868. {
  869. m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_handfree_out_dev, false);
  870. m_kept_volume_out[DEV_HANDFREE] = num.nValue;
  871. SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
  872. 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]);
  873. }
  874. else
  875. {
  876. Dbg("HANDFREE out volume keeper create failed!");
  877. }
  878. #endif
  879. }
  880. else if((sub_type == ACM_SET_PICKUP_OUTVOLUMN)&&(eStand2sType == m_eDeviceType))
  881. {
  882. CVolumnValue num;
  883. SpBuffer buf;
  884. buf.OpenRead(buffer,size);
  885. num.Serialize(buf);
  886. Dbg("recv adj pickup out volumn = %d",num.nValue);
  887. #ifdef RVC_OS_WIN
  888. if (m_pKeeperOut[DEV_PICKUP])
  889. {
  890. if (eStand2sType == m_eDeviceType)
  891. {
  892. volume_keeper_change(m_pKeeperOut[DEV_PICKUP], num.nValue);
  893. m_kept_volume_out[DEV_PICKUP] = num.nValue;
  894. SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
  895. 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]);
  896. }
  897. else //pad版屏蔽当前PICKUP音量设置
  898. {
  899. Dbg("PAD type, ignore pickupout volume adj");
  900. }
  901. }
  902. else
  903. {
  904. Dbg("PICKUP out volume keeper create failed!");
  905. }
  906. #else
  907. if (m_pAudioMgr)
  908. {
  909. if (eStand2sType == m_eDeviceType)
  910. {
  911. m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_pickup_out_dev, false);
  912. m_kept_volume_out[DEV_PICKUP] = num.nValue;
  913. SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
  914. 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]);
  915. }
  916. else //pad版屏蔽当前PICKUP音量设置
  917. {
  918. Dbg("PAD type, ignore pickupout volume adj");
  919. }
  920. }
  921. else
  922. {
  923. Dbg("PICKUP out volume keeper create failed!");
  924. }
  925. #endif
  926. }
  927. else if (sub_type == ACM_SET_HANDFREE_INVOLUMN)
  928. {
  929. CVolumnValue num;
  930. SpBuffer buf;
  931. buf.OpenRead(buffer,size);
  932. num.Serialize(buf);
  933. Dbg("recv adj handfree in volumn = %d",num.nValue);
  934. #ifdef RVC_OS_WIN
  935. if (m_pKeeperIn[DEV_HANDFREE])
  936. {
  937. volume_keeper_change(m_pKeeperIn[DEV_HANDFREE], num.nValue);
  938. m_kept_volume_in[DEV_HANDFREE] = num.nValue;
  939. SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
  940. 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]);
  941. }
  942. else
  943. {
  944. Dbg("handfree in volume keeper create failed!");
  945. }
  946. #else
  947. if (m_pAudioMgr)
  948. {
  949. m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_handfree_in_dev, true);
  950. m_kept_volume_in[DEV_HANDFREE] = num.nValue;
  951. SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
  952. 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]);
  953. }
  954. else
  955. {
  956. Dbg("handfree in volume keeper create failed!");
  957. }
  958. #endif
  959. }
  960. else if((sub_type == ACM_SET_PICKUP_INVOLUMN)&&(eStand2sType == m_eDeviceType))
  961. {
  962. CVolumnValue num;
  963. SpBuffer buf;
  964. buf.OpenRead(buffer,size);
  965. num.Serialize(buf);
  966. Dbg("recv adj pickup in volume = %d",num.nValue);
  967. #ifdef RVC_OS_WIN
  968. if (m_pKeeperIn[DEV_PICKUP])
  969. {
  970. if (eStand2sType == m_eDeviceType)
  971. {
  972. volume_keeper_change(m_pKeeperIn[DEV_PICKUP], num.nValue);
  973. m_kept_volume_in[DEV_PICKUP] = num.nValue;
  974. SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
  975. 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]);
  976. }
  977. else //pad版屏蔽当前PICKUP音量设置
  978. {
  979. Dbg("PAD type, ignore pickupin volume adj");
  980. }
  981. }
  982. else
  983. {
  984. Dbg("pickup in volume keeper create failed!");
  985. }
  986. #else
  987. if (m_pAudioMgr)
  988. {
  989. if (eStand2sType == m_eDeviceType)
  990. {
  991. m_pAudioMgr->audio_set_device_volume(num.nValue, conf.audio_pickup_in_dev, true);
  992. m_kept_volume_in[DEV_PICKUP] = num.nValue;
  993. SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
  994. 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]);
  995. }
  996. else //pad版屏蔽当前PICKUP音量设置
  997. {
  998. Dbg("PAD type, ignore pickupin volume adj");
  999. }
  1000. }
  1001. else
  1002. {
  1003. Dbg("pickup in volume keeper create failed!");
  1004. }
  1005. #endif
  1006. }
  1007. else if (sub_type == ACM_CONTROL_PERSONAREA) //控制人形框
  1008. {
  1009. CVolumnValue num;
  1010. SpBuffer buf;
  1011. buf.OpenRead(buffer,size);
  1012. num.Serialize(buf);
  1013. Dbg("recv control personarea subtype = %d",num.nValue);
  1014. if (num.nValue == 0) //隐藏人形框
  1015. {
  1016. LogEvent(Severity_Middle,LOG_EVT_UI_HIDELOCALVIDEO,"Agent send hide local video");
  1017. LogEvent(Severity_Middle,LOG_EVT_UI_HIDEPERSONAREA,"Agent send Hide Person area");
  1018. }
  1019. else if (num.nValue == 1) //显示人形框
  1020. {
  1021. LogEvent(Severity_Middle,LOG_EVT_UI_SHOWLOCALVIDEO,"Agent send show local video");
  1022. LogEvent(Severity_Middle,LOG_EVT_UI_SHOWPERSONAREA,"Agent send Show Person area");
  1023. }
  1024. else
  1025. {
  1026. Dbg("recv control personarea sub_type error!");
  1027. }
  1028. }
  1029. }
  1030. else if (type == ACM_TYPE_VIDEOFREQ)
  1031. {
  1032. if (eMobilePadType == m_eDeviceType)
  1033. {
  1034. CFpsValue nFps;
  1035. SpBuffer buf;
  1036. buf.OpenRead(buffer,size);
  1037. nFps.Serialize(buf);
  1038. Dbg("adj up stream fps to %d",nFps.nValue);
  1039. if((m_stVideoParam.nUpDynamicFps == 1)&&(nFps.nValue!=1))
  1040. {
  1041. GetFunction()->KillTimer(1);
  1042. }
  1043. else if (nFps.nValue==1)
  1044. {
  1045. //如果1帧每秒维持20秒,停止视频
  1046. Dbg("start timer for up fps");
  1047. GetFunction()->SetTimer(1, this, 20000);
  1048. }
  1049. m_stVideoParam.nUpDynamicFps = nFps.nValue;
  1050. }
  1051. else
  1052. {
  1053. Dbg("not mobile pad,ignore down message!");
  1054. }
  1055. }
  1056. }
  1057. #ifdef RVC_OS_LINUX
  1058. ErrorCodeEnum CSIPEntity::RvcGetAudioDeviceInfo()
  1059. {
  1060. ErrorCodeEnum Error = Error_Param;
  1061. if (NULL != m_pAudioMgr) {
  1062. int icountmic = m_pAudioMgr->audio_get_device_count(true);
  1063. Dbg("audio input device(%d):", icountmic);
  1064. int i = 0;
  1065. for (; i < icountmic; i++) {
  1066. char strname[MAX_PATH] = { 0 };
  1067. m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, true, i);
  1068. Dbg("%d = %s", i, strname);
  1069. }
  1070. int icountspeaker = m_pAudioMgr->audio_get_device_count(false);
  1071. Dbg("audio output device(%d):", icountspeaker);
  1072. for (i = 0; i < icountspeaker; i++) {
  1073. char strname[MAX_PATH] = { 0 };
  1074. m_pAudioMgr->audio_get_device_name(strname, MAX_PATH, false, i);
  1075. Dbg("%d = %s", i, strname);
  1076. }
  1077. Error = Error_Succeed;
  1078. }
  1079. return Error;
  1080. }
  1081. ErrorCodeEnum CSIPEntity::RvcSetSaveAudioVolume()
  1082. {
  1083. ErrorCodeEnum Error = Error_Succeed;
  1084. if (eStand2sType == m_eDeviceType) {
  1085. Dbg("handfree out volume is %d, handfree in volume is %d, pickup out volume is %d, pickup in volume %d", m_kept_volume_out[DEV_HANDFREE], m_kept_volume_in[DEV_HANDFREE], m_kept_volume_out[DEV_PICKUP], m_kept_volume_in[DEV_PICKUP]);
  1086. if (m_pAudioMgr){
  1087. m_pAudioMgr->audio_set_device_volume(m_kept_volume_out[DEV_HANDFREE], conf.audio_handfree_out_dev, false);
  1088. m_pAudioMgr->audio_set_device_volume(m_kept_volume_in[DEV_HANDFREE], conf.audio_handfree_in_dev, true);
  1089. m_pAudioMgr->audio_set_device_volume(m_kept_volume_out[DEV_PICKUP], conf.audio_pickup_out_dev, false);
  1090. m_pAudioMgr->audio_set_device_volume(m_kept_volume_in[DEV_PICKUP], conf.audio_pickup_in_dev, true);
  1091. }
  1092. }
  1093. return Error;
  1094. }
  1095. #endif
  1096. ErrorCodeEnum CSIPEntity::GetLocalIP()
  1097. {
  1098. #ifdef RVC_OS_WIN
  1099. char tmp[MAX_PATH] = { 0 };
  1100. gethostname(tmp, sizeof(tmp));
  1101. hostent* ent = gethostbyname(tmp);
  1102. if (ent) {
  1103. for (int i = 0; ent->h_addr_list[i]; ++i) {
  1104. if (ent->h_addrtype == AF_INET) {
  1105. struct in_addr* in = (struct in_addr*)ent->h_addr_list[i];
  1106. char* p = inet_ntoa(*in);
  1107. if (p[0] != '0')
  1108. {
  1109. if (strstr(p, "198.168.") == NULL)
  1110. {
  1111. strcpy(m_localip, p);
  1112. Dbg("local ip == %s", m_localip);
  1113. return Error_Succeed;
  1114. }
  1115. }
  1116. }
  1117. }
  1118. }
  1119. return Error_Unexpect;
  1120. #else
  1121. ErrorCodeEnum error = Error_Unexpect;
  1122. int sockfd = -1;
  1123. struct ifconf ifconf;
  1124. struct ifreq* ifreq = NULL;
  1125. char strbuf[MAX_PATH] = {0};
  1126. ifconf.ifc_len = MAX_PATH;
  1127. ifconf.ifc_buf = strbuf;
  1128. if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
  1129. Dbg("socket error");
  1130. return error;
  1131. }
  1132. ioctl(sockfd, SIOCGIFCONF, &ifconf); //get all socket info
  1133. ifreq = (struct ifreq*)ifconf.ifc_buf;
  1134. for (int i = (ifconf.ifc_len / sizeof(struct ifreq)); i > 0; i--){
  1135. if (ifreq->ifr_flags == AF_INET) { //for ipv4
  1136. char* strIP = inet_ntoa(((struct sockaddr_in*) & (ifreq->ifr_addr))->sin_addr);
  1137. Dbg("name = %s, local addr = %s", ifreq->ifr_name, strIP);
  1138. ifreq++;
  1139. if (NULL != strIP){
  1140. if (NULL == strstr(strIP, "198.168.") && NULL == strstr(strIP, "127.0.0.1"))
  1141. {
  1142. strcpy(m_localip, strIP);
  1143. Dbg("local ip == %s", m_localip);
  1144. error = Error_Succeed;
  1145. break;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. return error;
  1151. #endif // RVC_OS_WIN
  1152. }
  1153. //send DynamicFps
  1154. void CSIPEntity::SendDynamicFps(int nFps)
  1155. {
  1156. if (eMobilePadType == m_eDeviceType)
  1157. {
  1158. ChannelService_Send_Info Info;
  1159. Info.compress = false;
  1160. Info.encrypt = false;
  1161. Info.type = ACM_TYPE_VIDEOFREQ;
  1162. Info.id = 0;
  1163. Info.sub_type = ACM_VIDEOFREQ_DOWN;
  1164. Info.data.Alloc(sizeof(int));
  1165. SpBuffer buf;
  1166. buf.OpenWrite();
  1167. buf & nFps;
  1168. Info.data = buf.ToBlob();
  1169. m_pSipphoneChannel->Send(Info);
  1170. Dbg("adj down stream fps to %d",nFps);
  1171. }
  1172. else
  1173. {
  1174. Dbg("not mobile pad,ignore up message!");
  1175. }
  1176. }
  1177. //send audio device volume
  1178. void CSIPEntity::SendAudioDeviceVolumn(int nDevice)
  1179. {
  1180. if (m_nSysCallType == 0)
  1181. {
  1182. ChannelService_Send_Info Info;
  1183. Info.compress = false;
  1184. Info.encrypt = false;
  1185. Info.type = ACM_TYPE_DEVICE;
  1186. Info.id = 0;
  1187. int nValue = 0;
  1188. bool rslt = false;
  1189. void*keeper = NULL;
  1190. if (nDevice == DEVICE_HANDFREE_OUT)
  1191. {
  1192. Info.sub_type = ACM_HANDFREE_OUTVOLUMN;
  1193. #ifdef RVC_OS_WIN
  1194. keeper = m_pKeeperOut[DEV_HANDFREE];
  1195. #else
  1196. m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_handfree_out_dev, false);
  1197. rslt = true;
  1198. #endif // RVC_OS_WIN
  1199. }
  1200. else if(nDevice == DEVICE_PICKUP_OUT)
  1201. {
  1202. if(eStand2sType == m_eDeviceType)
  1203. {
  1204. Info.sub_type = ACM_PICKUP_OUTVOLUMN;
  1205. #ifdef RVC_OS_WIN
  1206. keeper = m_pKeeperOut[DEV_PICKUP];
  1207. #else
  1208. m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_pickup_out_dev, false);
  1209. rslt = true;
  1210. #endif
  1211. }
  1212. else //pad版屏蔽当前PICKUP音量发送
  1213. {
  1214. return;
  1215. }
  1216. }
  1217. else if(nDevice == DEVICE_HANDFREE_IN)
  1218. {
  1219. Info.sub_type = ACM_HANDFREE_INVOLUMN;
  1220. #ifdef RVC_OS_WIN
  1221. keeper = m_pKeeperIn[DEV_HANDFREE];
  1222. #else
  1223. m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_handfree_in_dev, true);
  1224. rslt = true;
  1225. #endif
  1226. }
  1227. else if(nDevice == DEVICE_PICKUP_IN)
  1228. {
  1229. if(eStand2sType == m_eDeviceType)
  1230. {
  1231. Info.sub_type = ACM_PICKUP_INVOLUMN;
  1232. #ifdef RVC_OS_WIN
  1233. keeper = m_pKeeperIn[DEV_PICKUP];
  1234. #else
  1235. m_pAudioMgr->audio_get_device_volume(&nValue, conf.audio_pickup_in_dev, true);
  1236. rslt = true;
  1237. #endif
  1238. }
  1239. else //pad版屏蔽当前PICKUP音量发送
  1240. {
  1241. return;
  1242. }
  1243. }
  1244. Info.data.Alloc(sizeof(int));
  1245. SpBuffer buf;
  1246. buf.OpenWrite();
  1247. #ifdef RVC_OS_WIN
  1248. if (keeper){
  1249. rslt = get_audiodevice_volumn(keeper, &nValue);
  1250. }
  1251. #endif
  1252. if (rslt == true)
  1253. {
  1254. buf & nValue;
  1255. Info.data = buf.ToBlob();
  1256. m_pSipphoneChannel->Send(Info);
  1257. Dbg("send cur Audio device %d,value = %d",nDevice,nValue);
  1258. }
  1259. else
  1260. {
  1261. Dbg("Get cur Audio device %d volume Fail!",nDevice);
  1262. }
  1263. }
  1264. else
  1265. {
  1266. Dbg("cur call type cannot send pkt");
  1267. }
  1268. }
  1269. ErrorCodeEnum CSIPEntity::SetHandfreeOutVolume(int iVolume)
  1270. {
  1271. ErrorCodeEnum Error = Error_Succeed;
  1272. Dbg("handle set hand free out volume = %d.", iVolume);
  1273. #ifdef RVC_OS_WIN
  1274. if (m_pKeeperOut[DEV_HANDFREE])
  1275. {
  1276. volume_keeper_change(m_pKeeperOut[DEV_HANDFREE], num.nValue);
  1277. m_kept_volume_out[DEV_HANDFREE] = iVolume;
  1278. Dbg("set hand free out volume to %d.", iVolume);
  1279. 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]);
  1280. }
  1281. else
  1282. {
  1283. Dbg("HANDFREE out volume keeper create failed!");
  1284. }
  1285. #else
  1286. if (m_pAudioMgr)
  1287. {
  1288. m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_handfree_out_dev, false);
  1289. m_kept_volume_out[DEV_HANDFREE] = iVolume;
  1290. Dbg("set hand free out volume to %d.", iVolume);
  1291. 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]);
  1292. }
  1293. else
  1294. {
  1295. Dbg("HANDFREE out volume keeper create failed!");
  1296. }
  1297. #endif
  1298. return Error;
  1299. }
  1300. ErrorCodeEnum CSIPEntity::SetPickupOutVolume(int iVolume)
  1301. {
  1302. ErrorCodeEnum Error = Error_Succeed;
  1303. Dbg("handle set pickup out volume = %d.", iVolume);
  1304. #ifdef RVC_OS_WIN
  1305. if (m_pKeeperOut[DEV_PICKUP])
  1306. {
  1307. if (eStand2sType == m_eDeviceType)
  1308. {
  1309. volume_keeper_change(m_pKeeperOut[DEV_PICKUP], num.nValue);
  1310. m_kept_volume_out[DEV_PICKUP] = iVolume;
  1311. Dbg("set pick up out volume to %d.", iVolume);
  1312. 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]);
  1313. }
  1314. else //pad版屏蔽当前PICKUP音量设置
  1315. {
  1316. Dbg("PAD type, ignore pickupout volume adj");
  1317. }
  1318. }
  1319. else
  1320. {
  1321. Dbg("PICKUP out volume keeper create failed!");
  1322. }
  1323. #else
  1324. if (m_pAudioMgr)
  1325. {
  1326. if (eStand2sType == m_eDeviceType)
  1327. {
  1328. m_pAudioMgr->audio_set_device_volume(iVolume, conf.audio_pickup_out_dev, false);
  1329. m_kept_volume_out[DEV_PICKUP] = iVolume;
  1330. 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]);
  1331. }
  1332. else //pad版屏蔽当前PICKUP音量设置
  1333. {
  1334. Dbg("PAD type, ignore pickupout volume adj");
  1335. }
  1336. }
  1337. else
  1338. {
  1339. Dbg("PICKUP out volume keeper create failed!");
  1340. }
  1341. #endif
  1342. return Error;
  1343. }
  1344. void CSIPEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  1345. {
  1346. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  1347. pTransactionContext->SendAnswer(Error);
  1348. }
  1349. ErrorCodeEnum CSIPEntity::__OnClose(ErrorCodeEnum preOperationError)
  1350. {
  1351. LOG_FUNCTION();
  1352. int i;
  1353. CSmartPointer<IEntityFunction> Func = GetFunction();
  1354. Func->UnregistSysVarEvent(SYSVAR_AGENTCAMERASWITCH);
  1355. Func->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
  1356. Func->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
  1357. Func->UnregistSysVarEvent(SYSVAR_CALLTYPE);
  1358. for (i = 0; i < m_arrListener.GetCount(); ++i) {
  1359. Func->UnsubscribeLog(m_arrListener[i]);
  1360. }
  1361. m_arrListener.Clear();
  1362. Dbg("__OnClose endpoint_destroy m_pEndpoint addr is 0x%08x.",m_pEndpoint);
  1363. endpoint_destroy(m_pEndpoint);
  1364. m_pEndpoint = NULL;
  1365. video_lib_deinit();
  1366. audio_lib_deinit();
  1367. endpoint_deinit_lib();
  1368. #ifdef RVC_OS_WIN
  1369. if (m_pKeeperIn[DEV_HANDFREE]) {
  1370. volume_keeper_destroy(m_pKeeperIn[DEV_HANDFREE]);
  1371. m_pKeeperIn[DEV_HANDFREE] = NULL;
  1372. }
  1373. if (m_pKeeperOut[DEV_HANDFREE]) {
  1374. volume_keeper_destroy(m_pKeeperOut[DEV_HANDFREE]);
  1375. m_pKeeperOut[DEV_HANDFREE] = NULL;
  1376. }
  1377. if (m_pKeeperIn[DEV_PICKUP]) {
  1378. volume_keeper_destroy(m_pKeeperIn[DEV_PICKUP]);
  1379. m_pKeeperIn[DEV_PICKUP] = NULL;
  1380. }
  1381. if (m_pKeeperOut[DEV_PICKUP]) {
  1382. volume_keeper_destroy(m_pKeeperOut[DEV_PICKUP]);
  1383. m_pKeeperOut[DEV_PICKUP] = NULL;
  1384. }
  1385. #else
  1386. if (NULL != m_pAudioMgr) {
  1387. m_pAudioMgr->audio_mgr_terminate();
  1388. DestroyIAudioMgrObj(m_pAudioMgr);
  1389. m_pAudioMgr = NULL;
  1390. }
  1391. #endif
  1392. return Error_Succeed;
  1393. }
  1394. void CSIPEntity::OnPaused()
  1395. {
  1396. int rc;
  1397. video_session_conf_t conf = {0};
  1398. conf.bit_rate = 256*1024;
  1399. conf.local_rtp_ip = htonl(INADDR_LOOPBACK);
  1400. conf.local_rtp_port = 3000;
  1401. conf.local_video_view_cx = 320;
  1402. conf.local_video_view_cy = 240;
  1403. conf.local_video_view_x = 0;
  1404. conf.local_video_view_y = 0;
  1405. conf.mtu = 1500;
  1406. conf.remote_rtp_ip = htonl(INADDR_LOOPBACK);
  1407. conf.remote_rtp_port = 3000;
  1408. conf.remote_video_view_cx = 320;
  1409. conf.remote_video_view_cy = 320;
  1410. conf.remote_video_view_x = 0;
  1411. conf.remote_video_view_y = 320;
  1412. conf.video_quant = 3;
  1413. conf.remote_video_width = 320;
  1414. conf.remote_video_height = 320;
  1415. conf.ref_active_camera = &m_stVideoParam.iActiveCamera;
  1416. video_session_create(&conf, &video_session);
  1417. video_session_start(video_session);
  1418. }
  1419. void CSIPEntity::OnContinued()
  1420. {
  1421. video_session_stop(video_session);
  1422. video_session_destroy(video_session);
  1423. }
  1424. CServerSessionBase* CSIPEntity::OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/)
  1425. {
  1426. LOG_FUNCTION();
  1427. m_pCurrentSession = new CSIPPhoneSession(this);
  1428. return m_pCurrentSession;
  1429. }
  1430. void CSIPEntity::OnTimeout(DWORD dwTimerID)
  1431. {
  1432. if (dwTimerID == 1)
  1433. {
  1434. //如果当前动态帧频不等于之前的帧频,发送当前帧频
  1435. //if (g_nDynamicFps != m_nDownDynamicFps)
  1436. //{
  1437. // m_nDownDynamicFps = g_nDynamicFps;
  1438. // SendDynamicFps(g_nDynamicFps);
  1439. //}
  1440. Dbg("stop up stream!");
  1441. GetFunction()->KillTimer(1);
  1442. m_stVideoParam.nUpDynamicFps = -1;
  1443. }
  1444. }
  1445. ErrorCodeEnum CSIPEntity::InitEndpoint()
  1446. {
  1447. LOG_FUNCTION();
  1448. ErrorCodeEnum eCode = Error_Param;
  1449. CSmartPointer<IEntityFunction> Func = GetFunction();
  1450. Func->GetSystemStaticInfo(staticInfo);
  1451. CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
  1452. if (strUri.GetLength() > 0)
  1453. {
  1454. strcpy(conf.uri, strUri);
  1455. conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
  1456. conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
  1457. m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
  1458. if (!m_pEndpoint) {
  1459. LOG_TRACE("create endpoint failed!");
  1460. eCode = Error_Unexpect;
  1461. }
  1462. else{
  1463. Dbg("%s:%d endpoint_create m_pEndpoint addr is 0x%08x.", __FUNCTION__, __LINE__, m_pEndpoint);
  1464. eCode = Error_Succeed;
  1465. }
  1466. }
  1467. else
  1468. {
  1469. LOG_TRACE("strUri length equals zero!");
  1470. eCode = Error_Unexpect;
  1471. }
  1472. return eCode;
  1473. }
  1474. void CSIPEntity::change_dev(int dev_type)
  1475. {
  1476. Dbg("change_dev dev_type:%d", dev_type);
  1477. if (m_pEndpoint) {
  1478. Dbg("begin invoke endpoint change audio device!");
  1479. endpoint_change_audio_dev(m_pEndpoint, dev_type);
  1480. Dbg("end invoke endpoint change audio device!");
  1481. }
  1482. }
  1483. static int __change_dev(void *arg)
  1484. {
  1485. ChangeDevCommand *pCmd = (ChangeDevCommand *)arg;
  1486. pCmd->pEntity->change_dev(pCmd->dev_type);
  1487. delete pCmd;
  1488. return 0;
  1489. }
  1490. void CSIPEntity::SwitchHandFree()
  1491. {
  1492. LOG_FUNCTION();
  1493. int rc = 0;
  1494. ChangeDevCommand *pCmd = new ChangeDevCommand();
  1495. pCmd->pEntity = this;
  1496. pCmd->dev_type = DEV_HANDFREE;
  1497. if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
  1498. Dbg("endpoint invoke failed!");
  1499. delete pCmd;
  1500. }
  1501. }
  1502. void CSIPEntity::SwitchPickup()
  1503. {
  1504. LOG_FUNCTION();
  1505. int rc = 0;
  1506. ChangeDevCommand *pCmd = new ChangeDevCommand();
  1507. pCmd->pEntity = this;
  1508. pCmd->dev_type = DEV_PICKUP;
  1509. if (endpoint_invoke(m_pEndpoint, &__change_dev, pCmd, &rc) != 0) {
  1510. Dbg("endpoint invoke failed!");
  1511. delete pCmd;
  1512. }
  1513. }
  1514. void CSIPEntity::SetState(int state)
  1515. {
  1516. m_state = state;
  1517. }
  1518. ErrorCodeEnum CSIPEntity::RealSelfCheck()
  1519. {
  1520. ErrorCodeEnum Error = Error_Succeed;
  1521. if (m_pSelfcheckClient)
  1522. {
  1523. SelfCheckerService_RealCheck_Req req;
  1524. req.name = GetEntityName();
  1525. SelfCheckerService_RealCheck_Ans ans;
  1526. DWORD Timeout = 500;
  1527. Error = m_pSelfcheckClient->RealCheck(req,ans,Timeout);
  1528. if (Error!=Error_Succeed)
  1529. {
  1530. Dbg("RealSelfcheck fail!");
  1531. }
  1532. else
  1533. {
  1534. Dbg("RealSelfcheck");
  1535. }
  1536. }
  1537. return Error;
  1538. }
  1539. CSimpleStringA CSIPEntity::MakeUri(const char *terminal_id)
  1540. {
  1541. CSimpleStringA str;
  1542. str = CSimpleStringA::Format("sip:%s@%s;transport=UDP", terminal_id, m_localip);
  1543. return str;
  1544. }
  1545. void CSIPEntity::Handle_RecordVideoLocation_Info(const char* pszMessage)
  1546. {
  1547. if (NULL == pszMessage){
  1548. return;
  1549. }
  1550. CSimpleStringA strMsg = pszMessage;
  1551. if (strMsg.IsStartWith("ews|",true)){
  1552. strMsg = strMsg.SubString(4,strMsg.GetLength()-4);
  1553. }
  1554. int lxPos,lyPos,lwidth,lheight;
  1555. CSimpleStringA str;
  1556. sscanf(strMsg.GetData(), "%d@%d@%d@%d@%d@%s", &lxPos, &lyPos, &lwidth, &lheight, &str);
  1557. Dbg("start record preview local video param : (x=%d,y=%d,width=%d,height=%d).",lxPos,lyPos,lwidth,lheight);
  1558. m_RecordVideoLocation.x = lxPos;
  1559. m_RecordVideoLocation.y = lyPos;
  1560. m_RecordVideoLocation.width = lwidth;
  1561. m_RecordVideoLocation.height = lheight;
  1562. }
  1563. void CSIPEntity::Handle_AdjustVideoEchoEvent(const char* pszMessage)
  1564. {
  1565. if (NULL == pszMessage){
  1566. return;
  1567. }
  1568. CSimpleStringA strMsg = pszMessage;
  1569. if (strMsg.IsStartWith("ews|",true)){
  1570. strMsg = strMsg.SubString(4,strMsg.GetLength()-4);
  1571. }
  1572. int lxPos,lyPos,lwidth,lheight;
  1573. CSimpleStringA str;
  1574. sscanf(strMsg.GetData(), "%d@%d@%d@%d@%d@%s", &lxPos, &lyPos, &lwidth, &lheight, &str);
  1575. Dbg("begin adjust local video param : (x=%d,y=%d,width=%d,height=%d).",lxPos,lyPos,lwidth,lheight);
  1576. if (DEFAULT_RECORD_VIDEO_WIDTH == lwidth && DEFAULT_RECORD_VIDEO_HEIGHT == lheight){
  1577. m_stVideoParam.nWindowState = 0;
  1578. }
  1579. else if(SMALL_RECORD_VIDEO_WIDTH == lwidth && SMALL_RECORD_VIDEO_HEIGHT == lheight){
  1580. m_stVideoParam.nWindowState = 5;
  1581. }
  1582. else{
  1583. Dbg("not support width and height.");
  1584. }
  1585. m_RecordVideoLocation.x = lxPos;
  1586. m_RecordVideoLocation.y = lyPos;
  1587. m_RecordVideoLocation.width = lwidth;
  1588. m_RecordVideoLocation.height = lheight;
  1589. }
  1590. void CSIPEntity::InitFreshTimeConfig()
  1591. {
  1592. CSmartPointer<IConfigInfo> spCacheConfig;
  1593. GetFunction()->OpenConfig(Config_Cache, spCacheConfig);
  1594. int value(0);
  1595. spCacheConfig->ReadConfigValueInt("SIPPhone", "lfreshtime", value);
  1596. if (value > 0) {
  1597. LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_OVERWRITE_FRESHVALUE,
  1598. CSimpleStringA::Format("overwrite lfreshtime from global cache: %d", value));
  1599. m_ilocalvideo_freshtime = value;
  1600. }
  1601. }
  1602. ErrorCodeEnum CSIPEntity::LoadConfig(endpoint_conf_t *conf)
  1603. {
  1604. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1605. CSmartPointer<IConfigInfo> spRootConfig;
  1606. ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spRootConfig);
  1607. if (Error == Error_Succeed) {
  1608. CSimpleStringA strHandFreeIn;
  1609. CSimpleStringA strHandFreeOut;
  1610. CSimpleStringA strPickupIn;
  1611. CSimpleStringA strPickupOut;
  1612. SpIniMappingTable table;
  1613. table.AddEntryString("audio", "handfree_in_dev", strHandFreeIn, "$");
  1614. table.AddEntryString("audio", "handfree_out_dev", strHandFreeOut, "$");
  1615. table.AddEntryString("audio", "pickup_in_dev", strPickupIn, "$");
  1616. table.AddEntryString("audio", "pickup_out_dev", strPickupOut, "$");
  1617. table.AddEntryBoolean("audio", "pickup_out_agc", conf->audio_pickup_out_agc, false);
  1618. table.AddEntryBoolean("audio", "pickup_in_agc", conf->audio_pickup_in_agc, false);
  1619. table.AddEntryBoolean("audio", "handfree_in_agc", conf->audio_handfree_in_agc, false);
  1620. table.AddEntryBoolean("audio", "handfree_out_agc", conf->audio_handfree_out_agc, false);
  1621. table.AddEntryBoolean("audio", "pickup_out_ns", conf->audio_pickup_out_ns, false);
  1622. table.AddEntryBoolean("audio", "pickup_in_ns", conf->audio_pickup_in_ns, false);
  1623. table.AddEntryBoolean("audio", "handfree_in_ns", conf->audio_handfree_in_ns, false);
  1624. table.AddEntryBoolean("audio", "handfree_out_ns", conf->audio_handfree_out_ns, false);
  1625. table.AddEntryBoolean("audio", "pickup_aec", conf->audio_pickup_aec, false);
  1626. table.AddEntryBoolean("audio", "handfree_aec", conf->audio_handfree_aec, false);
  1627. table.AddEntryInt("audio", "handfree_in_volume", m_kept_volume_in[DEV_HANDFREE], 0);
  1628. table.AddEntryInt("audio", "handfree_out_volume", m_kept_volume_out[DEV_HANDFREE], 0);
  1629. table.AddEntryInt("audio", "pickup_in_volume", m_kept_volume_in[DEV_PICKUP], 0);
  1630. table.AddEntryInt("audio", "pickup_out_volume", m_kept_volume_out[DEV_PICKUP], 0);
  1631. table.AddEntryInt("video", "quant", conf->quant, 0);
  1632. table.AddEntryInt("video", "mtu", conf->mtu, 0);
  1633. Error = table.Load(spRootConfig);
  1634. if (Error == Error_Succeed) {
  1635. int id;
  1636. #ifdef RVC_OS_WIN
  1637. id = capture_get_audio_device_id(true, strHandFreeIn);
  1638. #else
  1639. id = m_pAudioMgr->audio_get_device_id(strHandFreeIn.GetData(), true);
  1640. #endif
  1641. if (id == -1) {
  1642. Dbg("audio handfree in device %s does not exist!", (LPCSTR)strHandFreeIn);
  1643. CSimpleStringA strErrMsg = "外部麦克风配置错误,请重新配置!";
  1644. LogWarn(Severity_Middle, Error_Param, 0, strErrMsg);
  1645. Error = Error_Param;
  1646. }
  1647. strcpy(conf->audio_handfree_in_dev, strHandFreeIn);
  1648. #ifdef RVC_OS_WIN
  1649. id = capture_get_audio_device_id(false, strHandFreeOut);
  1650. #else
  1651. id = m_pAudioMgr->audio_get_device_id(strHandFreeOut.GetData(), false);
  1652. #endif
  1653. if (id == -1) {
  1654. Dbg("audio handfree out device %s does not exist!", (LPCSTR)strHandFreeOut);
  1655. CSimpleStringA strErrMsg = "外部扬声器配置错误,请重新配置!";
  1656. LogWarn(Severity_Middle, Error_Param, 0, strErrMsg);
  1657. Error = Error_Param;
  1658. }
  1659. strcpy(conf->audio_handfree_out_dev, strHandFreeOut);
  1660. #ifdef RVC_OS_WIN
  1661. id = capture_get_audio_device_id(true, strPickupIn);
  1662. #else
  1663. id = m_pAudioMgr->audio_get_device_id(strPickupIn.GetData(), true);
  1664. #endif
  1665. if (id == -1) {
  1666. Dbg("audio pickup in device %s does not exist!", (LPCSTR)strPickupIn);
  1667. CSimpleStringA strErrMsg = "话筒麦克风(大机)配置错误,请重新配置!";
  1668. LogWarn(Severity_Middle, Error_Param, 0, strErrMsg);
  1669. Error = Error_Param;
  1670. }
  1671. strcpy(conf->audio_pickup_in_dev, strPickupIn);
  1672. #ifdef RVC_OS_WIN
  1673. id = capture_get_audio_device_id(false, strPickupOut);
  1674. #else
  1675. id = m_pAudioMgr->audio_get_device_id(strPickupOut.GetData(), false);
  1676. #endif
  1677. if (id == -1) {
  1678. Dbg("audio device %s does not exist!", (LPCSTR)strPickupOut);
  1679. CSimpleStringA strErrMsg = "话筒扬声器(大机)配置错误,请重新配置!";
  1680. LogWarn(Severity_Middle, Error_Param, 0, strErrMsg);
  1681. Error = Error_Param;
  1682. }
  1683. strcpy(conf->audio_pickup_out_dev, strPickupOut);
  1684. conf->ref_active_camera = &m_stVideoParam.iActiveCamera;
  1685. conf->ref_camera_switch = &m_stVideoParam.iCameraSwitch;
  1686. conf->ref_window_state = &m_stVideoParam.nWindowState;
  1687. conf->ref_active_img = &m_stVideoParam.bShowActiveImg;
  1688. conf->ref_Is_ActiveInspect = &m_stVideoParam.bActiveInspect;
  1689. conf->ref_camera_state = &m_stVideoParam.iCameraState;
  1690. conf->ref_Is_showPersonArea = &m_stVideoParam.bShowPersonArea;
  1691. conf->ref_Is_showRecordArea = &m_stVideoParam.bShowRecordArea;
  1692. if (eMobilePadType == m_eDeviceType)
  1693. {
  1694. m_stVideoParam.nUpDynamicFps = 3;
  1695. }
  1696. else if ((ePadtype==m_eDeviceType)||(eDesk2SType==m_eDeviceType)||(eDesk1SType==m_eDeviceType)||(eDesk2SIntegratedType==m_eDeviceType))
  1697. {
  1698. m_stVideoParam.nUpDynamicFps = REC_COMMON_VIDEO_FPS_MOBILE;
  1699. }
  1700. else if(eStand2sType == m_eDeviceType)
  1701. {
  1702. m_stVideoParam.nUpDynamicFps = 0;
  1703. }
  1704. Dbg("init up dynamic fps to %d",m_stVideoParam.nUpDynamicFps);
  1705. conf->ref_Up_Fps = &m_stVideoParam.nUpDynamicFps;
  1706. if ((eMobilePadType == m_eDeviceType)||(ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType)||(eDesk1SType==m_eDeviceType)||(eDesk2SIntegratedType==m_eDeviceType))
  1707. {
  1708. conf->camera_count = 1;
  1709. }
  1710. else if(eStand2sType == m_eDeviceType)
  1711. {
  1712. conf->camera_count = 2;
  1713. }
  1714. //DecideCameraCount(conf->camera_count);
  1715. DecideScreenCount(conf->screen_count);
  1716. if (m_ilocalvideo_freshtime > 500 || m_ilocalvideo_freshtime < 50) {
  1717. m_ilocalvideo_freshtime = 200;
  1718. }
  1719. }
  1720. }
  1721. InitFreshTimeConfig();
  1722. return Error;
  1723. }
  1724. //载入运行时配置
  1725. ErrorCodeEnum CSIPEntity::LoadAudioRunConfig(int&nHandfreeout,int&nPickupout,int&nHandfreein,int&nPickupin)
  1726. {
  1727. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1728. CSmartPointer<IConfigInfo> spConfig;
  1729. ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
  1730. if (Error == Error_Succeed)
  1731. {
  1732. SpIniMappingTable table;
  1733. table.AddEntryInt("Audio", "handfree_out_volume", nHandfreeout, 0);
  1734. table.AddEntryInt("Audio", "pickup_out_volume", nPickupout, 0);
  1735. table.AddEntryInt("Audio", "handfree_in_volume", nHandfreein, 0);
  1736. table.AddEntryInt("Audio", "pickup_in_volume", nPickupin, 0);
  1737. Error = table.Load(spConfig);
  1738. if (Error != Error_Succeed)
  1739. {
  1740. LOG_TRACE("[dbg] failed to load run config.");
  1741. }
  1742. }
  1743. else
  1744. {
  1745. LOG_TRACE("[dbg] failed to open run config.");
  1746. }
  1747. return Error;
  1748. }
  1749. //保存运行时
  1750. ErrorCodeEnum CSIPEntity::SaveAudioRunConfig(int nHandfreeout,int nPickupout,int nHandfreein,int nPickupin)
  1751. {
  1752. CSmartPointer<IEntityFunction> spFunction = GetFunction();;
  1753. CSmartPointer<IConfigInfo> spConfig;
  1754. ErrorCodeEnum Error = spFunction->OpenConfig(Config_Run, spConfig);
  1755. if (Error == Error_Succeed)
  1756. {
  1757. Error = spConfig->WriteConfigValueInt("Audio", "handfree_out_volume", nHandfreeout);
  1758. if(Error == Error_Succeed)
  1759. {
  1760. Error = spConfig->WriteConfigValueInt("Audio", "pickup_out_volume", nPickupout);
  1761. }
  1762. else
  1763. {
  1764. Dbg("SaveAudioRunConfig handfree_out_volume fail!");
  1765. return Error;
  1766. }
  1767. if(Error == Error_Succeed)
  1768. {
  1769. Error = spConfig->WriteConfigValueInt("Audio", "handfree_in_volume", nHandfreein);
  1770. }
  1771. else
  1772. {
  1773. Dbg("SaveAudioRunConfig pickup_out_volume fail!");
  1774. return Error;
  1775. }
  1776. if(Error == Error_Succeed)
  1777. {
  1778. Error = spConfig->WriteConfigValueInt("Audio", "pickup_in_volume", nPickupin);
  1779. }
  1780. else
  1781. {
  1782. Dbg("SaveAudioRunConfig handfree_in_volume fail!");
  1783. return Error;
  1784. }
  1785. if (Error != Error_Succeed)
  1786. {
  1787. Dbg("SaveAudioRunConfig pickup_in_volume fail!");
  1788. return Error;
  1789. }
  1790. }
  1791. else
  1792. {
  1793. Dbg("SaveAudioRunConfig is fail , open sipphone.ini fail!");
  1794. }
  1795. return Error;
  1796. }
  1797. // we use root.ini Video section config to decide camera count
  1798. ErrorCodeEnum CSIPEntity::DecideCameraCount(int &nCount)
  1799. {
  1800. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1801. CSmartPointer<IConfigInfo> spConfig;
  1802. ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spConfig);
  1803. if (Error == Error_Succeed) {
  1804. CSimpleStringA strVideoEnv;
  1805. CSimpleStringA strVideoOpt;
  1806. SpIniMappingTable table;
  1807. nCount = 0;
  1808. table.AddEntryString("Video", "EnvCamera", strVideoEnv, "$");
  1809. table.AddEntryString("Video", "OptCamera", strVideoOpt, "$");
  1810. Error = table.Load(spConfig);
  1811. if (Error == Error_Succeed) {
  1812. if (strVideoEnv.GetLength() > 1)
  1813. nCount++;
  1814. if (strVideoOpt.GetLength() > 1)
  1815. nCount++;
  1816. }
  1817. }
  1818. return Error;
  1819. }
  1820. ErrorCodeEnum CSIPEntity::DecideScreenCount(int &nCount)
  1821. {
  1822. CSystemStaticInfo Info;
  1823. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1824. ErrorCodeEnum Error = spFunction->GetSystemStaticInfo(Info);
  1825. if (Error == Error_Succeed)
  1826. {
  1827. nCount = (int)Info.eScreen;
  1828. }
  1829. return Error;
  1830. }
  1831. DeviceTypeEnum CSIPEntity::RvcGetDeviceType()
  1832. {
  1833. DeviceTypeEnum eType = eStand2sType;
  1834. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1835. CSystemStaticInfo stStaticinfo;
  1836. spFunction->GetSystemStaticInfo(stStaticinfo);
  1837. if (stricmp(stStaticinfo.strMachineType, "RVC.PAD") == 0) {
  1838. if (stricmp(stStaticinfo.strSite, "CMB.FLB") == 0) {
  1839. eType = eMobilePadType;
  1840. }
  1841. else {
  1842. eType = ePadtype;
  1843. }
  1844. }
  1845. else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk2S") == 0) {
  1846. eType = eDesk2SType;
  1847. WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
  1848. WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
  1849. Dbg("MachineVersion is %d.%d", nMajor, nMinor);
  1850. if (2 == nMajor) {
  1851. eType = eDesk2SIntegratedType;
  1852. }
  1853. }
  1854. else if (stricmp(stStaticinfo.strMachineType, "RPM.Stand1S") == 0) {
  1855. eType = eRpm1sType;
  1856. }
  1857. else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk1S") == 0) {
  1858. eType = eDesk1SType;
  1859. }
  1860. else {
  1861. eType = eStand2sType;
  1862. }
  1863. if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
  1864. LOG_TRACE("device type is %s.", Device_Type_Table[eType]);
  1865. }
  1866. return eType;
  1867. }
  1868. //
  1869. // CSIPPhoneSession
  1870. //
  1871. void CSIPPhoneSession::OnClose( ErrorCodeEnum eErrorCode )
  1872. {
  1873. LOG_FUNCTION();
  1874. }
  1875. void CSIPPhoneSession::Handle_MakeCall( SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx )
  1876. {
  1877. LOG_FUNCTION();
  1878. LOG_TRACE("make call [%s]", (LPCSTR)ctx->Req.call_uri);
  1879. int rc;
  1880. MakeCallCommand *cmd = new MakeCallCommand();
  1881. cmd->pSIPPhoneSession = this;
  1882. cmd->strUri = ctx->Req.call_uri;
  1883. ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
  1884. if (m_pEntity->m_pEndpoint){
  1885. Dbg("%s:%d m_pEndpoint is not null and it's addr is 0x%08x,destroy it.", __FUNCTION__, __LINE__, m_pEntity->m_pEndpoint);
  1886. endpoint_destroy(m_pEntity->m_pEndpoint);
  1887. m_pEntity->m_pEndpoint = NULL;
  1888. }
  1889. CSimpleStringA strUri = m_pEntity->MakeUri(m_pEntity->staticInfo.strTerminalID);
  1890. if (strUri.GetLength() > 0) {
  1891. strcpy(m_pEntity->conf.uri, strUri);
  1892. m_pEntity->conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
  1893. m_pEntity->conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
  1894. m_pEntity->m_pEndpoint = endpoint_create(m_pEntity, &m_pEntity->conf, m_pEntity->m_iPickupPhoneState);
  1895. if (!m_pEntity->m_pEndpoint) {
  1896. LOG_TRACE("create endpoint failed!");
  1897. }
  1898. else {
  1899. Dbg("%s:%d endpoint_create m_pEndpoint addr is 0x%08x.", __FUNCTION__, __LINE__, m_pEntity->m_pEndpoint);
  1900. }
  1901. }
  1902. else {
  1903. LOG_TRACE("strUri length equals zero!");
  1904. }
  1905. ErrorCodeEnum Error = m_pEntity->GetLocalIP();
  1906. if (Error != 0) {
  1907. LOG_TRACE("get local ip failed!");
  1908. ctx->Answer(Error_Unexpect);
  1909. return;
  1910. }
  1911. if (m_pEntity->m_eDeviceType == eMobilePadType) {
  1912. m_pEntity->m_stVideoParam.nUpDynamicFps = 3;
  1913. }
  1914. ///////////重新初始化sip话机,防止断网导致IP改变//////////////////
  1915. if (m_pEntity->GetEndpoint()) {
  1916. endpoint_invoke(m_pEntity->GetEndpoint(), &__make_call, cmd, &rc);
  1917. }
  1918. ctx->Answer((ErrorCodeEnum)rc);
  1919. }
  1920. void CSIPPhoneSession::Handle_HangupCall( SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx )
  1921. {
  1922. LOG_FUNCTION();
  1923. int rc;
  1924. HangupCallCommand *cmd = new HangupCallCommand();
  1925. cmd->pSIPPhoneSession = this;
  1926. cmd->strSession_num = ctx->Req.session_num;
  1927. cmd->strBranch_server_ip = ctx->Req.branch_server_ip;
  1928. cmd->iBranch_server_port = ctx->Req.branch_server_port;
  1929. if (m_pEntity->GetEndpoint())
  1930. {
  1931. endpoint_invoke(m_pEntity->GetEndpoint(), &__hangup_call, cmd, &rc);
  1932. }
  1933. ctx->Answer((ErrorCodeEnum)rc);
  1934. }
  1935. void CSIPPhoneSession::Handle_ReleaseCall( SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx )
  1936. {
  1937. LOG_FUNCTION();
  1938. int rc = Error_Succeed;
  1939. g_IsExternalTerminalted = TRUE;
  1940. endpoint_invoke(m_pEntity->GetEndpoint(), &__release_call, this, &rc);
  1941. Dbg("%s:%d endpoint_destroy m_pEndpoint addr is 0x%08x.", __FUNCTION__, __LINE__, m_pEntity->m_pEndpoint);
  1942. if (NULL != m_pEntity->m_pEndpoint){
  1943. endpoint_destroy(m_pEntity->m_pEndpoint);
  1944. m_pEntity->m_pEndpoint = NULL;
  1945. }
  1946. ctx->Answer((ErrorCodeEnum)rc);
  1947. }
  1948. void CSIPPhoneSession::Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx)
  1949. {
  1950. LOG_FUNCTION();
  1951. Dbg("SetCallingParam CallType = %d", ctx->Info.CallType);
  1952. m_pEntity->m_nCallType = (CallingTypeEnum)ctx->Info.CallType;
  1953. }
  1954. void CSIPPhoneSession::Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
  1955. {
  1956. LOG_FUNCTION();
  1957. m_pEntity->m_SipErrorCode = Error_InvalidState;
  1958. m_pEntity->RealSelfCheck();
  1959. }
  1960. void CSIPPhoneSession::Handle_StartVideo( SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx )
  1961. {
  1962. LOG_FUNCTION();
  1963. int rc;
  1964. ControlVideoCommand *pCmd = new ControlVideoCommand();
  1965. pCmd->pSIPPhoneSession = this;
  1966. pCmd->start = TRUE;
  1967. pCmd->local_hwd_move = 0;
  1968. pCmd->remote_hwd_move = 0;
  1969. if(!(ctx->Info.remote_view_x||ctx->Info.remote_view_y||ctx->Info.remote_view_cx||ctx->Info.remote_view_cy||ctx->Info.remote_width||ctx->Info.remote_height))
  1970. {
  1971. m_IsLocalPlay= TRUE;
  1972. m_VideoWindowPlayType = eOnly_Local_Video;
  1973. Dbg("LocalPlay Mod");
  1974. }
  1975. else
  1976. {
  1977. m_IsLocalPlay= FALSE;
  1978. m_VideoWindowPlayType = eOnline_Mode_Video;
  1979. Dbg("OnlinePlay Mod");
  1980. if (0 == ctx->Info.remote_port){
  1981. m_VideoWindowPlayType = eBoth_Local_Remote_Video;
  1982. m_pEntity->m_nCallType = NORMAL_CALLTYPE;
  1983. Dbg("both local and remote mode.");
  1984. if (NULL == m_pEntity->GetEndpoint())
  1985. {
  1986. Dbg("m_pEndpoint has destroy, now new init it.");
  1987. m_pEntity->InitEndpoint();
  1988. }
  1989. }
  1990. }
  1991. pCmd->local_ip = inet_addr(m_pEntity->m_localip);
  1992. pCmd->local_port = REC_COMMON_VIDEO_PORT;
  1993. pCmd->remote_ip = inet_addr(ctx->Info.remote_ip);
  1994. pCmd->remote_port = ctx->Info.remote_port;
  1995. pCmd->local_view_x = ctx->Info.local_view_x;
  1996. pCmd->local_view_y = ctx->Info.local_view_y;
  1997. pCmd->local_view_cx = ctx->Info.local_view_cx;
  1998. pCmd->local_view_cy = ctx->Info.local_view_cy;
  1999. pCmd->remote_view_x = ctx->Info.remote_view_x;
  2000. pCmd->remote_view_y = ctx->Info.remote_view_y;
  2001. pCmd->remote_view_cx = ctx->Info.remote_view_cx;
  2002. pCmd->remote_view_cy = ctx->Info.remote_view_cy;
  2003. pCmd->remote_width = ctx->Info.remote_width;
  2004. pCmd->remote_height = ctx->Info.remote_height;
  2005. pCmd->local_hwd_move = ctx->Info.local_hwd_move;
  2006. pCmd->remote_hwd_move = ctx->Info.remote_hwd_move;
  2007. pCmd->local_fresh_time = m_pEntity->m_ilocalvideo_freshtime;
  2008. //初始化窗口参数
  2009. //m_pEntity->m_stVideoParam.nWindowState = 0;
  2010. //m_pEntity->GetFunction()->SetTimer(1, m_pEntity, 1000);
  2011. //m_pEntity->m_nDownDynamicFps = ctx->Info.remote_fps;
  2012. //g_nDynamicFps = ctx->Info.remote_fps;
  2013. //g_nSysFps = ctx->Info.remote_fps;
  2014. //g_nLastRecFrameTime = GetTickCount();
  2015. endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
  2016. }
  2017. void CSIPPhoneSession::Handle_StopVideo( SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx )
  2018. {
  2019. int rc;
  2020. ControlVideoCommand *pCmd = new ControlVideoCommand();
  2021. pCmd->pSIPPhoneSession = this;
  2022. pCmd->start = FALSE;
  2023. m_pEntity->GetFunction()->KillTimer(1);
  2024. if (NULL != m_pEntity->GetEndpoint()){
  2025. endpoint_invoke(m_pEntity->GetEndpoint(), &__control_video, pCmd, &rc);
  2026. }
  2027. else{
  2028. endpoint_call_stop_double_record_broadcast_video();
  2029. }
  2030. m_pEntity->m_stVideoParam.bShowActiveImg = 0;
  2031. m_pEntity->m_stVideoParam.bActiveInspect = 0;
  2032. //初始化窗口参数
  2033. m_pEntity->m_stVideoParam.nWindowState = 0;
  2034. }
  2035. void CSIPPhoneSession::Handle_BeginState( SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx )
  2036. {
  2037. m_spCallbackContext = ctx;
  2038. }
  2039. void CSIPPhoneSession::Handle_EndState( SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx )
  2040. {
  2041. SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer tmp_ctx = m_spCallbackContext;
  2042. m_spCallbackContext.Clear();
  2043. }
  2044. void CSIPPhoneSession::Handle_GetHandfreeOutVolume(SpReqAnsContext<PhoneService_GetHandfreeOutVolume_Req, PhoneService_GetHandfreeOutVolume_Ans>::Pointer ctx)
  2045. {
  2046. LOG_FUNCTION();
  2047. ctx->Ans.Volume = m_pEntity->m_kept_volume_out[DEV_HANDFREE];
  2048. Dbg("get hand free out volume is %d.", ctx->Ans.Volume);
  2049. ctx->Answer(Error_Succeed);
  2050. }
  2051. void CSIPPhoneSession::Handle_SetHandfreeOutVolume(SpReqAnsContext<PhoneService_SetHandfreeOutVolume_Req, PhoneService_SetHandfreeOutVolume_Ans>::Pointer ctx)
  2052. {
  2053. LOG_FUNCTION();
  2054. int iVolume = ctx->Req.Volume;
  2055. if (iVolume > 100){
  2056. iVolume = 100;
  2057. }
  2058. if (iVolume < 30){
  2059. iVolume = 30;
  2060. }
  2061. m_pEntity->SetHandfreeOutVolume(iVolume);
  2062. ctx->Answer(Error_Succeed);
  2063. }
  2064. void CSIPPhoneSession::Handle_GetPickupOutVolume(SpReqAnsContext<PhoneService_GetPickupOutVolume_Req, PhoneService_GetPickupOutVolume_Ans>::Pointer ctx)
  2065. {
  2066. LOG_FUNCTION();
  2067. if (eStand2sType == m_pEntity->m_eDeviceType){
  2068. ctx->Ans.Volume = m_pEntity->m_kept_volume_out[DEV_PICKUP];
  2069. }
  2070. else{
  2071. ctx->Ans.Volume = 0;
  2072. }
  2073. Dbg("get pickup out volume is %d.", ctx->Ans.Volume);
  2074. ctx->Answer(Error_Succeed);
  2075. }
  2076. void CSIPPhoneSession::Handle_SetPickupOutVolume(SpReqAnsContext<PhoneService_SetPickupOutVolume_Req, PhoneService_SetPickupOutVolume_Ans>::Pointer ctx)
  2077. {
  2078. LOG_FUNCTION();
  2079. if (eStand2sType == m_pEntity->m_eDeviceType) {
  2080. int iVolume = ctx->Req.Volume;
  2081. if (iVolume > 100) {
  2082. iVolume = 100;
  2083. }
  2084. if (iVolume < 30) {
  2085. iVolume = 30;
  2086. }
  2087. m_pEntity->SetPickupOutVolume(iVolume);
  2088. }
  2089. ctx->Answer(Error_Succeed);
  2090. }
  2091. void CSIPPhoneSession::hangup_call(/*CSIPPhoneSession::HangupCallCommand* cmd*/)
  2092. {
  2093. if (m_pCall) {
  2094. Dbg("normal hangup.");
  2095. endpoint_call_hangup(m_pCall);
  2096. }
  2097. }
  2098. void CSIPPhoneSession::release_call()
  2099. {
  2100. if (m_pCall){
  2101. Terminatedcall(m_pCall);
  2102. }
  2103. }
  2104. void CSIPPhoneSession::on_call_state(int state, const char *state_desc, const char *phrase)
  2105. {
  2106. if (m_spCallbackContext != NULL)
  2107. {
  2108. PhoneService_PhoneState_Info Info;
  2109. Info.state = state;
  2110. Info.status = CSimpleStringA::Format("%s,%s", state_desc, phrase);
  2111. m_spCallbackContext->SendMessage(Info);
  2112. }
  2113. if (state == TERMINATED)
  2114. {
  2115. if (NULL != m_pCall){
  2116. endpoint_call_destroy(m_pCall);
  2117. m_pCall = NULL;
  2118. }
  2119. }
  2120. m_pEntity->SetState(state);
  2121. }
  2122. int CSIPPhoneSession::make_call(const char *remote_uri)
  2123. {
  2124. if (m_pCall)
  2125. {
  2126. LOG_TRACE("call duplicated! and endpoint destroy old call.");
  2127. endpoint_call_destroy(m_pCall);
  2128. m_pCall = NULL;
  2129. //return Error_Duplication;
  2130. }
  2131. //else
  2132. {
  2133. endpoint_call_callback_t cb = {0};
  2134. cb.on_call_state = &__on_call_state;
  2135. cb.user_data = this;
  2136. m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), remote_uri, m_pEntity->m_localip,m_pEntity->m_eDeviceType,m_pEntity->m_nCallType,&cb);
  2137. if (m_pCall)
  2138. {
  2139. g_IsExternalTerminalted = FALSE;
  2140. Dbg("g_IsExternalTerminalted = FALSE");
  2141. LOG_TRACE("create call endpoint ok!");
  2142. if (endpoint_call_start(m_pCall) == 0)
  2143. {
  2144. LOG_TRACE("start call ok!");
  2145. return Error_Succeed;
  2146. }
  2147. else
  2148. {
  2149. LOG_TRACE("start call failed! and endpoint destroy call.");
  2150. endpoint_call_destroy(m_pCall);
  2151. m_pCall = NULL;
  2152. return Error_Unexpect;
  2153. }
  2154. }
  2155. else
  2156. {
  2157. g_IsExternalTerminalted = TRUE;
  2158. Dbg("g_IsExternalTerminalted = TRUE");
  2159. LOG_TRACE("create call endpoint failed!");
  2160. m_pEntity->m_SipErrorCode = Error_InvalidState;
  2161. m_pEntity->RealSelfCheck();
  2162. return Error_Unexpect;
  2163. }
  2164. }
  2165. }
  2166. void CSIPPhoneSession::control_video( ControlVideoCommand *pCmd )
  2167. {
  2168. LOG_FUNCTION();
  2169. if (m_pCall)
  2170. {
  2171. if (pCmd->start)
  2172. {
  2173. endpoint_call_param_t callparam = { 0 };
  2174. callparam.remote_ip = pCmd->remote_ip;
  2175. callparam.remote_port = pCmd->remote_port;
  2176. callparam.local_ip = pCmd->local_ip;
  2177. callparam.local_port = pCmd->local_port;
  2178. callparam.remote_width = pCmd->remote_width;
  2179. callparam.remote_height = pCmd->remote_height;
  2180. callparam.local_view_x = pCmd->local_view_x;
  2181. callparam.local_view_y = pCmd->local_view_y;
  2182. callparam.local_view_cx = pCmd->local_view_cx;
  2183. callparam.local_view_cy = pCmd->local_view_cy;
  2184. callparam.remote_view_x = pCmd->remote_view_x;
  2185. callparam.remote_view_y = pCmd->remote_view_y;
  2186. callparam.remote_view_cx = pCmd->remote_view_cx;
  2187. callparam.remote_view_cy = pCmd->remote_view_cy;
  2188. callparam.local_hwd_move = pCmd->local_hwd_move;
  2189. callparam.remote_hwd_move = pCmd->remote_hwd_move;
  2190. callparam.local_fresh_time = pCmd->local_fresh_time;
  2191. callparam.remote_fresh_time = pCmd->remote_fresh_time;
  2192. endpoint_call_start_video(m_pCall, &callparam, &m_cb_video_box_move);
  2193. }
  2194. else
  2195. {
  2196. //双录第一阶段结束录像,销毁call资源
  2197. if ((eOnly_Local_Video == m_VideoWindowPlayType) || (eBoth_Local_Remote_Video == m_VideoWindowPlayType && m_pEntity->m_nCallType != DOUBLERECORD_CALLTYPE ))
  2198. {
  2199. Dbg("stop record play.");
  2200. local_play_stop_video(m_pCall);
  2201. m_IsLocalPlay = FALSE;
  2202. endpoint_call_destroy(m_pCall);
  2203. m_pCall = NULL;
  2204. }
  2205. else
  2206. {
  2207. endpoint_call_stop_video(m_pCall);
  2208. }
  2209. }
  2210. }
  2211. else
  2212. {
  2213. if (pCmd->start)
  2214. {
  2215. endpoint_call_callback_t cb = {0};
  2216. cb.on_call_state = &__on_call_state;
  2217. cb.user_data = this;
  2218. m_pCall = endpoint_call_create(m_pEntity->GetEndpoint(), "test",m_pEntity->m_localip,m_pEntity->m_eDeviceType,m_pEntity->m_nCallType, &cb);
  2219. if (eOnly_Local_Video == m_VideoWindowPlayType){
  2220. Dbg("start local play mode record.");
  2221. local_play_start_video(m_pCall,pCmd->local_view_x, pCmd->local_view_y, pCmd->local_view_cx, pCmd->local_view_cy, pCmd->local_hwd_move, &m_cb_video_box_move);
  2222. }
  2223. else if (eBoth_Local_Remote_Video == m_VideoWindowPlayType){
  2224. Dbg("start local and remote video play mode record.");
  2225. 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);
  2226. }
  2227. }
  2228. else{
  2229. #ifdef RVC_OS_WIN
  2230. Dbg("record call remote agent timeout, close video session.");
  2231. endpoint_call_stop_double_record_broadcast_video();
  2232. #endif
  2233. }
  2234. }
  2235. }
  2236. int CSIPPhoneSession::on_video_box_move(int imessageType, int ivideotype, int ileft, int ibottom)
  2237. {
  2238. int iret = -1;
  2239. if (0 == imessageType){
  2240. VideoBoxStartMove evt;
  2241. evt.videoboxflag = ivideotype;
  2242. evt.leftlowerx = ileft;
  2243. evt.leftlowery = ibottom;
  2244. iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStartMove), SP_MSG_SIG_OF(VideoBoxStartMove), evt);
  2245. Dbg("VideoBoxStartMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
  2246. }
  2247. else{
  2248. VideoBoxStopMove evt;
  2249. evt.videoboxflag = ivideotype;
  2250. evt.leftlowerx = ileft;
  2251. evt.leftlowery = ibottom;
  2252. iret = SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(VideoBoxStopMove), SP_MSG_SIG_OF(VideoBoxStopMove), evt);
  2253. Dbg("VideoBoxStopMove broadcast sent, video type is %d, left is %d, bottom is %d.", ivideotype, ileft, ibottom);
  2254. }
  2255. return iret;
  2256. }
  2257. ChannelSipphoneClient::ChannelSipphoneClient( CSIPEntity *pEntity ) : ChannelService_ClientBase(pEntity)
  2258. {
  2259. }
  2260. void ChannelSipphoneClient::OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData)
  2261. {
  2262. if (Error == Error_Succeed)
  2263. {
  2264. CSIPEntity *pEntity = static_cast<CSIPEntity*>(m_pEntityBase);
  2265. if (Msg.state == eChannelState_Connected)
  2266. {
  2267. #ifdef RVC_OS_WIN
  2268. if (pEntity->m_pKeeperIn[DEV_HANDFREE])
  2269. #else
  2270. if (pEntity->m_pAudioMgr)
  2271. #endif
  2272. {
  2273. pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_IN);
  2274. }
  2275. #ifdef RVC_OS_WIN
  2276. if (pEntity->m_pKeeperOut[DEV_HANDFREE])
  2277. #else
  2278. if (pEntity->m_pAudioMgr)
  2279. #endif
  2280. {
  2281. pEntity->SendAudioDeviceVolumn(DEVICE_HANDFREE_OUT);
  2282. }
  2283. #ifdef RVC_OS_WIN
  2284. if (pEntity->m_pKeeperOut[DEV_PICKUP])
  2285. #else
  2286. if (pEntity->m_pAudioMgr)
  2287. #endif
  2288. {
  2289. pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_OUT);
  2290. }
  2291. #ifdef RVC_OS_WIN
  2292. if (pEntity->m_pKeeperIn[DEV_PICKUP])
  2293. #else
  2294. if (pEntity->m_pAudioMgr)
  2295. #endif
  2296. {
  2297. pEntity->SendAudioDeviceVolumn(DEVICE_PICKUP_IN);
  2298. }
  2299. }
  2300. }
  2301. }
  2302. void ChannelSipphoneClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
  2303. {
  2304. //LOG_FUNCTION();
  2305. if (Error == Error_Succeed)
  2306. {
  2307. CSIPEntity *pEntity = static_cast<CSIPEntity*>(m_pEntityBase);
  2308. pEntity->OnReceivePkt(Msg.type,Msg.sub_type, (const char*)Msg.data.m_pData, Msg.data.m_iLength);
  2309. }
  2310. }
  2311. SelfChekerClient::SelfChekerClient( CSIPEntity *pEntity ) : SelfCheckerService_ClientBase(pEntity)
  2312. {
  2313. }
  2314. SP_BEGIN_ENTITY_MAP()
  2315. SP_ENTITY(CSIPEntity)
  2316. SP_END_ENTITY_MAP()