mod_sipphone.cpp 72 KB

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