mod_screenshot.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. #include "stdafx.h"
  2. #include "SpBase.h"
  3. #include "screencapture.h"
  4. #include <screencodec.h>
  5. #include "../..//Other/libvideoframework/videoutil.h"
  6. #include "../../Other/rvcmediacommon/rvc_media_common.h"
  7. #include "mod_assistantchannel/AssistantChannel_client_g.h"
  8. using namespace AssistantChannel;
  9. #include "mod_assistantchannel/chan_protocol.h"
  10. #include "mod_assistantchannel/VideoDesc.h"
  11. // add by ly 20150514
  12. #include "jpeg2k.h"
  13. #include "ScreenShot_server_g.h"
  14. #include "cv.h"
  15. #include "highgui.h"
  16. #include "cxcore.h"
  17. #include "CommEntityUtil.hpp"
  18. using namespace ScreenShot;
  19. #define LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE 0x50500001 //协助通道重启
  20. // step 1 screen capture
  21. // step 2 compress using libpng
  22. // step 3 split to 56k each chunk to send out
  23. // future improvement:
  24. // 1. adding 8bit depth color options
  25. // 2. adding business zone options
  26. class CScreenCaptureEntity;
  27. // add by ly 20150514
  28. class CScreenShotSession: public ScreenShotService_ServerSessionBase
  29. {
  30. public:
  31. CScreenShotSession(CScreenCaptureEntity* pEntity, int id) : m_id(id), m_pEntity(pEntity)
  32. {
  33. }
  34. virtual void Handle_StartScreenShot(SpReqAnsContext<ScreenShotService_StartScreenShot_Req, ScreenShotService_StartScreenShot_Ans>::Pointer ctx);
  35. virtual void OnClose( ErrorCodeEnum eErrorCode );
  36. private:
  37. int m_id;
  38. CScreenCaptureEntity* m_pEntity;
  39. };
  40. class ChannelClient : public ChannelService_ClientBase
  41. {
  42. public:
  43. ChannelClient(CScreenCaptureEntity *pEntity);
  44. virtual void OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData);
  45. virtual void OnMessage(ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData);
  46. };
  47. // 旋转180度
  48. int RotationDown(unsigned char* src, int srcW, int srcH, int channel)
  49. {
  50. unsigned char* tempSrc = NULL;
  51. int mSize = srcW * srcH * sizeof(char) * channel;
  52. int i = 0;
  53. int j = 0;
  54. int k = 0;
  55. int desW = 0;
  56. int desH = 0;
  57. desW = srcW;
  58. desH = srcH;
  59. tempSrc = (unsigned char*)malloc(sizeof(char) * srcW * srcH * channel);
  60. memcpy(tempSrc, src, mSize);
  61. for (i = 0; i < desH; i++)
  62. {
  63. for (j = 0; j < desW; j++)
  64. {
  65. for (k = 0; k < channel; k++)
  66. {
  67. //src[(i * desW + j) * channel + k] = tempSrc[((srcH - 1 - i) * srcW + srcW - 1 - j) * channel + k];
  68. src[(i * desW + j) * channel + k] = tempSrc[((srcH - 1 - i) * srcW + j) * channel + k];
  69. }
  70. }
  71. }
  72. free(tempSrc);
  73. return 0;
  74. }
  75. class CScreenCaptureEntity : public CEntityBase,public ILogListener
  76. {
  77. public:
  78. CScreenCaptureEntity() : m_enc_session(NULL), m_id_seq(0) {}
  79. virtual ~CScreenCaptureEntity() {}
  80. virtual const char *GetEntityName() const { return "ScreenShot"; }
  81. // add by ly 20150514
  82. virtual bool IsService() const { return true; }
  83. // add by ly 20150514
  84. virtual CServerSessionBase *OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
  85. {
  86. LOG_FUNCTION();
  87. LOG_TRACE("%s connected class = %s!", pszRemoteEntityName, pszClass);
  88. return new CScreenShotSession(this, m_id_seq++);
  89. }
  90. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  91. {
  92. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  93. pTransactionContext->SendAnswer(Error);
  94. }
  95. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  96. {
  97. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  98. pTransactionContext->SendAnswer(Error);
  99. }
  100. virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  101. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  102. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage)
  103. {
  104. if (dwUserCode == LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE)
  105. {
  106. Dbg("recv LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE");
  107. if (m_pChannelClient!=NULL)
  108. {
  109. m_pChannelClient->GetFunction()->CloseSession();
  110. m_pChannelClient = NULL;
  111. Dbg("Close AssistChannel Session ");
  112. }
  113. if (m_pChannelClient == NULL)
  114. {
  115. Dbg("ReConnection AssistChannel Session");
  116. m_pChannelClient = new ChannelClient(this);
  117. ErrorCodeEnum Error = m_pChannelClient->Connect();
  118. if (Error != Error_Succeed)
  119. {
  120. m_pChannelClient->SafeDelete();
  121. m_pChannelClient = NULL;
  122. Dbg("AssistChannelClient connect fail!");
  123. }
  124. if (Error == Error_Succeed)
  125. {
  126. ChannelService_BeginRecv_Sub Sub;
  127. Sub.type = ACM_TYPE_SRN;
  128. Error = m_pChannelClient->BeginRecv(Sub);
  129. if (Error != Error_Succeed)
  130. {
  131. m_pChannelClient->GetFunction()->CloseSession();
  132. m_pChannelClient = NULL;
  133. }
  134. }
  135. if (Error == Error_Succeed)
  136. {
  137. ChannelService_BeginState_Sub Sub;
  138. Error = m_pChannelClient->BeginState(Sub);
  139. if (Error != Error_Succeed)
  140. {
  141. LOG_TRACE("BeginState biz channel failed!");
  142. m_pChannelClient->GetFunction()->CloseSession();
  143. m_pChannelClient = NULL;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  150. {
  151. if (Test_ShakeHand == eTestType)
  152. {
  153. pTransactionContext->SendAnswer(Error_Succeed);
  154. }
  155. }
  156. ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
  157. {
  158. LOG_FUNCTION();
  159. CSmartPointer<IEntityFunction> pFunc = GetFunction();
  160. int i = 0;
  161. m_arrListener.Init(1);
  162. pFunc->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE,NULL,false);
  163. if (preOperationError != Error_Succeed)
  164. return preOperationError;
  165. //is Pad Version
  166. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  167. CSystemStaticInfo stStaticinfo;
  168. spFunction->GetSystemStaticInfo(stStaticinfo);
  169. if (stricmp(stStaticinfo.strMachineType,"RVC.WALL")==0)
  170. {
  171. m_bIsWallMachine = TRUE;
  172. Dbg("the machine type is rvc.wall");
  173. }
  174. else
  175. {
  176. m_bIsWallMachine = FALSE;
  177. }
  178. ErrorCodeEnum Error;
  179. m_pChannelClient = new ChannelClient(this);
  180. Error = m_pChannelClient->Connect();
  181. if (Error != Error_Succeed) {
  182. m_pChannelClient->SafeDelete();
  183. return Error;
  184. }
  185. if (Error == Error_Succeed) {
  186. ChannelService_BeginRecv_Sub Sub;
  187. Sub.type = ACM_TYPE_SRN;
  188. Error = m_pChannelClient->BeginRecv(Sub);
  189. if (Error != Error_Succeed) {
  190. m_pChannelClient->GetFunction()->CloseSession();
  191. m_pChannelClient = NULL;
  192. return Error;
  193. }
  194. }
  195. if (Error == Error_Succeed) {
  196. ChannelService_BeginState_Sub Sub;
  197. Error = m_pChannelClient->BeginState(Sub);
  198. if (Error != Error_Succeed) {
  199. LOG_TRACE("BeginState biz channel failed!");
  200. m_pChannelClient->GetFunction()->CloseSession();
  201. m_pChannelClient = NULL;
  202. }
  203. }
  204. return Error;
  205. }
  206. ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
  207. {
  208. LOG_FUNCTION();
  209. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  210. for (int i = 0; i < m_arrListener.GetCount(); ++i)
  211. {
  212. spFunction->UnsubscribeLog(m_arrListener[i]);
  213. }
  214. if (preOperationError != Error_Succeed)
  215. return preOperationError;
  216. m_pChannelClient->GetFunction()->CloseSession();
  217. m_pChannelClient = NULL;
  218. return Error_Succeed;
  219. }
  220. void DumpCaptureDat(const char *buf, int n)
  221. {
  222. char tmp[MAX_PATH];
  223. static int seq = 0;
  224. sprintf(tmp, ".%scapture_%08d.dat", SPLIT_SLASH_STR, seq++);
  225. FILE *fp = fopen(tmp, "wb");
  226. if (fp)
  227. {
  228. fwrite(buf,1,n, fp);
  229. fclose(fp);
  230. }
  231. }
  232. ErrorCodeEnum InitCapture()
  233. {
  234. if (m_enc_session) {
  235. screen_encoder_session_destroy(m_enc_session);
  236. m_enc_session = NULL;
  237. }
  238. #ifdef RVC_OS_WIN
  239. int cx = GetSystemMetrics(SM_CXSCREEN);
  240. int cy = GetSystemMetrics(SM_CYSCREEN);
  241. #else
  242. int cx, cy;
  243. getScreenSize(&cx, &cy);
  244. #endif
  245. if (m_bIsWallMachine)
  246. {
  247. cy = cy-640;
  248. }
  249. screen_encoder_session_create(cx, cy, &m_enc_session);
  250. return Error_Succeed;
  251. }
  252. void ExitCapture()
  253. {
  254. if (m_enc_session) {
  255. screen_encoder_session_destroy(m_enc_session);
  256. m_enc_session = NULL;
  257. }
  258. }
  259. void Capture(int id)
  260. {
  261. CSystemStaticInfo SysInfo;
  262. #ifdef RVC_OS_WIN
  263. int cx = GetSystemMetrics(SM_CXSCREEN);
  264. int cy = GetSystemMetrics(SM_CYSCREEN);
  265. #else
  266. int cx, cy;
  267. getScreenSize(&cx, &cy);
  268. #endif
  269. RECT rc = {0, 0, cx, cy};
  270. int size = 0;
  271. int err = screencapture_capture(&rc, NULL, &size);
  272. if (err != 0) {
  273. LOG_TRACE("capture screen failed! %d", err);
  274. return;
  275. }
  276. Dbg("capture screen, cx: %d, cy: %d, size: %d", cx, cy, size);
  277. void *buf = malloc(size);
  278. err = screencapture_capture(&rc, buf, &size);
  279. if (err != 0) {
  280. free(buf);
  281. LOG_TRACE("capture screen failed! %d", err);
  282. return;
  283. }
  284. if((SysInfo.eScreen == 1)&&!m_bIsWallMachine)
  285. {
  286. CSimpleStringA strValue;
  287. ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
  288. if (Error == Error_Succeed)
  289. {
  290. int local_view_x;
  291. int local_view_y;
  292. int local_view_cx;
  293. int local_view_cy;
  294. int remote_view_x;
  295. int remote_view_y;
  296. int remote_view_cx;
  297. int remote_view_cy;
  298. ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
  299. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  300. RECT rcs[] = {
  301. {local_view_x, cy - local_view_y - local_view_cy, local_view_x+local_view_cx, cy - local_view_y},
  302. {remote_view_x, cy - remote_view_y - remote_view_cy, remote_view_x+remote_view_cx, cy - remote_view_y},
  303. };
  304. screencapture_clipoff(cx, cy, buf, 2, rcs);
  305. }
  306. }
  307. #ifndef RVC_OS_WIN
  308. {
  309. //linux需翻转图像
  310. int width = rc.right - rc.left;
  311. int height = rc.bottom - rc.top;
  312. Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
  313. RotationDown((unsigned char*)buf, width, height, 3);
  314. }
  315. #endif
  316. ChannelService_Send_Info Info;
  317. Info.compress = false;
  318. Info.encrypt = false;
  319. Info.type = ACM_TYPE_SRN;
  320. Info.id = id;
  321. Info.sub_type = ACM_SRN_ANS | ACM_SRN_SNAPSHOT;
  322. if (m_bIsWallMachine)
  323. {
  324. int width = rc.right - rc.left;
  325. int height = rc.bottom - 640;
  326. int linesize = (width * 3 + 3) & 0xfffffffc;
  327. int newsize = linesize * height;
  328. Info.data.Alloc(newsize);
  329. Dbg("width = %d,height = %d,linesize = %d,newsize = %d",width,height,linesize,newsize);
  330. void *buftmp = malloc(newsize);
  331. memcpy(buftmp,buf,newsize);
  332. screen_encoder_session_encode(m_enc_session, buftmp, Info.data.m_pData, &Info.data.m_iLength);
  333. m_pChannelClient->Send(Info);
  334. free(buftmp);
  335. }
  336. else
  337. {
  338. Info.data.Alloc(size);
  339. screen_encoder_session_encode(m_enc_session, buf, Info.data.m_pData, &Info.data.m_iLength);
  340. m_pChannelClient->Send(Info);
  341. }
  342. #if 0
  343. int linesize = size / cy;
  344. video_frame tmp_frame;
  345. video_frame_alloc(linesize/3, cy, VIDEO_FORMAT_RGB24, &tmp_frame);
  346. video_frame_fill_black(&tmp_frame);
  347. memcpy(tmp_frame.data[0], buf, size);
  348. video_frame_save_bmpfile("screenshot_abc.bmp", &tmp_frame);
  349. video_frame_free(&tmp_frame);
  350. //video_frame_save_bmpfile("d:\\ab.bmp", &rtp_frame);
  351. Dbg("capture screen, linesize: %d.", linesize);
  352. #endif
  353. free(buf);
  354. LOG_TRACE("encode size = %d Bytes, time = %d", Info.data.m_iLength, SP::Module::Comm::RVCGetTickCount());
  355. }
  356. void Capture1(int id)
  357. {
  358. CSystemStaticInfo SysInfo;
  359. #ifdef RVC_OS_WIN
  360. int cx = GetSystemMetrics(SM_CXSCREEN);
  361. int cy = GetSystemMetrics(SM_CYSCREEN);
  362. #else
  363. int cx, cy;
  364. getScreenSize(&cx, &cy);
  365. #endif
  366. RECT rc = {0, 0, cx, cy};
  367. int size = 0;
  368. int err = screencapture_capture(&rc, NULL, &size);
  369. if (err != 0) {
  370. LOG_TRACE("capture screen failed! %d", err);
  371. return;
  372. }
  373. void *buf = malloc(size);
  374. err = screencapture_capture(&rc, buf, &size);
  375. if (err != 0) {
  376. free(buf);
  377. LOG_TRACE("capture screen failed! %d", err);
  378. return;
  379. }
  380. if (SysInfo.eScreen == 1) {
  381. CSimpleStringA strValue;
  382. ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
  383. if (Error == Error_Succeed) {
  384. int local_view_x;
  385. int local_view_y;
  386. int local_view_cx;
  387. int local_view_cy;
  388. int remote_view_x;
  389. int remote_view_y;
  390. int remote_view_cx;
  391. int remote_view_cy;
  392. ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
  393. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  394. RECT rcs[] = {
  395. {local_view_x, cy - local_view_y - local_view_cy, local_view_x+local_view_cx, cy - local_view_y},
  396. {remote_view_x, cy - remote_view_y - remote_view_cy, remote_view_x+remote_view_cx, cy - remote_view_y},
  397. };
  398. screencapture_clipoff(cx, cy, buf, 2, rcs);
  399. }
  400. }
  401. #ifndef RVC_OS_WIN
  402. //linux需翻转图像
  403. int width = rc.right - rc.left;
  404. int height = rc.bottom - rc.top;
  405. Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
  406. RotationDown((unsigned char*)buf, width, height, 3);
  407. #endif
  408. ChannelService_Send_Info Info;
  409. Info.compress = false;
  410. Info.encrypt = false;
  411. Info.type = ACM_TYPE_SRN;
  412. Info.id = id;
  413. Info.sub_type = ACM_SRN_ANS | ACM_SRN_SNAPSHOT;
  414. Info.data.Alloc(size);
  415. screencapture_encode(cx, cy, buf, Info.data.m_pData, &Info.data.m_iLength);
  416. //DumpCaptureDat((const char*)Info.data.m_pData, Info.data.m_iLength);
  417. m_pChannelClient->Send(Info);
  418. free(buf);
  419. LOG_TRACE("encode size = %d Bytes, time = %d", Info.data.m_iLength, SP::Module::Comm::RVCGetTickCount());
  420. }
  421. void Capture2(RECT *lprc, CBlob &image)
  422. {
  423. int width = lprc->right-lprc->left;
  424. int height = lprc->bottom-lprc->top;
  425. int size = 0;
  426. int err = screencapture_capture(lprc, NULL, &size);
  427. if (err != 0) {
  428. LOG_TRACE("capture screen failed! %d", err);
  429. return;
  430. }
  431. void *buf = malloc(size);
  432. err = screencapture_capture(lprc, buf, &size);
  433. if (err != 0) {
  434. free(buf);
  435. LOG_TRACE("capture screen failed! %d", err);
  436. return;
  437. }
  438. #ifndef RVC_OS_WIN
  439. //linux需翻转图像
  440. Dbg("size = %d, 3*width*height= %d", size, 3*width*height);
  441. RotationDown((unsigned char*)buf, width, height, 3);
  442. #endif
  443. // encode with jpeg2k
  444. jpeg2k_coded_image codec_image = {0};
  445. jpeg2k_raw_image raw_image;
  446. raw_image.data = (BYTE*)buf;
  447. raw_image.width = width;
  448. raw_image.height = height;
  449. raw_image.len = raw_image.width * raw_image.height * 3;
  450. int nRet = jpeg2k_encode(&raw_image, &codec_image, 30); // ratio越小质量越好
  451. if (nRet == 0 || nRet == Error_TimeOut)
  452. {
  453. size = codec_image.len;
  454. image.Alloc(size);
  455. memmove(image.m_pData, codec_image.data, size);
  456. //char tmp[MAX_PATH];
  457. //static int seq = 0;
  458. //sprintf(tmp, ".\\jietu_%08d.jp2", seq++);
  459. //FILE *fp = fopen(tmp, "wb");
  460. //if (fp) {
  461. // fwrite(codec_image.data,1,size, fp);
  462. // fclose(fp);
  463. //}
  464. image.Resize(size);
  465. jpeg2k_encode_free(&codec_image);
  466. }
  467. free(buf);
  468. }
  469. private:
  470. screen_encoder_session_t *m_enc_session;
  471. ChannelClient *m_pChannelClient;
  472. CAutoArray<CUUID> m_arrListener;
  473. // add by ly 20150514
  474. int m_id_seq;
  475. BOOL m_bIsWallMachine;
  476. };
  477. // add by ly 20150514
  478. void CScreenShotSession::Handle_StartScreenShot(SpReqAnsContext<ScreenShotService_StartScreenShot_Req, ScreenShotService_StartScreenShot_Ans>::Pointer ctx)
  479. {
  480. Dbg("accepted params: %d, %d, %d, %d", ctx->Req.Left, ctx->Req.Top, ctx->Req.Width, ctx->Req.Height);
  481. #ifdef RVC_OS_WIN
  482. int cx = GetSystemMetrics(SM_CXSCREEN);
  483. int cy = GetSystemMetrics(SM_CYSCREEN);
  484. #else
  485. int cx, cy;
  486. getScreenSize(&cx, &cy);
  487. #endif
  488. if (ctx->Req.Left < 0 || ctx->Req.Left > cx || ctx->Req.Width <= 0 || ctx->Req.Width > cx ||
  489. ctx->Req.Top < 0 || ctx->Req.Top > cy || ctx->Req.Height <= 0 || ctx->Req.Height > cy)
  490. {
  491. ctx->Answer(Error_Unexpect);
  492. }
  493. RECT rc = {ctx->Req.Left, ctx->Req.Top, ctx->Req.Left + ctx->Req.Width, ctx->Req.Top + ctx->Req.Height};
  494. m_pEntity->Capture2(&rc, ctx->Ans.Image);
  495. if (ctx->Ans.Image.m_iLength == 0)
  496. {
  497. ctx->Answer(Error_Unexpect);
  498. }
  499. else
  500. {
  501. ctx->Answer(Error_Succeed);
  502. }
  503. }
  504. // add by ly 20150514
  505. void CScreenShotSession::OnClose( ErrorCodeEnum eErrorCode )
  506. {
  507. LOG_FUNCTION();
  508. }
  509. void ChannelClient::OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData)
  510. {
  511. if (Error == Error_Succeed) {
  512. CScreenCaptureEntity *pEntity = static_cast<CScreenCaptureEntity*>(m_pEntityBase);
  513. if (Msg.state == eChannelState_Idle) {
  514. pEntity->ExitCapture();
  515. } else if (Msg.state == eChannelState_Connected) {
  516. pEntity->InitCapture();
  517. }
  518. }
  519. }
  520. void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
  521. {
  522. LOG_FUNCTION();
  523. if (Error == Error_Succeed) {
  524. CScreenCaptureEntity *pEntity = static_cast<CScreenCaptureEntity*>(m_pEntityBase);
  525. int cat = ACM_SRN_CAT(Msg.sub_type);
  526. if (cat == ACM_SRN_REQ) {
  527. //SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
  528. pEntity->Capture(Msg.id);
  529. //SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
  530. } else {
  531. _ASSERT(0);
  532. }
  533. }
  534. }
  535. ChannelClient::ChannelClient( CScreenCaptureEntity *pEntity ) : ChannelService_ClientBase(pEntity)
  536. {
  537. }
  538. SP_BEGIN_ENTITY_MAP()
  539. SP_ENTITY(CScreenCaptureEntity)
  540. SP_END_ENTITY_MAP()