mod_localmediaplay.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. #include "stdafx.h"
  2. #include "mod_localmediaplay.h"
  3. #include "LocalMediaPlay_msg_g.h"
  4. #include "fileutil.h"
  5. #include "y2k_time.h"
  6. #include "../../Other/rvcmediacommon/rvc_media_common.h"
  7. #include "../mod_interactivecontrol/Event.h"
  8. #define DEFAULT_SLEEP_TIME (60 * 1000)
  9. #define DEFAULT_ADVERT_TYPE 'A'
  10. bool IS_DEBUG = false;
  11. int scanTime = 600;
  12. int removeOldTime = 1800;
  13. #ifndef MAX_LOCAL_MEDIAS
  14. #define MAX_LOCAL_MEDIAS 128
  15. #endif // !MAX_LOCAL_MEDIAS
  16. #ifndef RVC_MIN_LOCALPLAYER_TIME
  17. #define RVC_MIN_LOCALPLAYER_TIME 6
  18. #endif
  19. //DWORD WINAPI clearOutdata(LPVOID lpv)
  20. //{
  21. // CLocalMediaPlayEntity* curEntity = (CLocalMediaPlayEntity*)lpv;
  22. // Sleep(removeOldTime * 1000);
  23. // curEntity->m_mediaManage.clearOutdataResource();
  24. // return 0;
  25. //}
  26. #ifdef RVC_OS_WIN
  27. DWORD WINAPI qryMedia(LPVOID lpv)
  28. {
  29. CLocalMediaPlayEntity* curEntity = (CLocalMediaPlayEntity*)lpv;
  30. Sleep(3000);
  31. while (true)
  32. {
  33. curEntity->m_mediaManage.InitResourceListByLocal();
  34. //curEntity->StartVideo(0, 0, 0, 0, 0);
  35. Sleep(3600 * 1000);
  36. }
  37. return 0;
  38. }
  39. #else
  40. void* queryMedia(void* param)
  41. {
  42. CLocalMediaPlayEntity* curEntity = (CLocalMediaPlayEntity*)param;
  43. sleep(3);
  44. while (false == curEntity->GetScanExitFlag())
  45. {
  46. curEntity->m_mediaManage.InitResourceListByLocal();
  47. sleep(3600);
  48. }
  49. return 0;
  50. }
  51. void sig_handler(int signum)
  52. {
  53. if (SIGTERM == signum){
  54. int ipid = getpid();
  55. kill(ipid, SIGKILL);
  56. }
  57. }
  58. #endif // RVC_OS_WIN
  59. CLocalMediaPlayEntity::CLocalMediaPlayEntity()
  60. : m_id_seq(0), m_connection(NULL)
  61. {
  62. //stopForDebug();
  63. m_defaultVolum = 50;
  64. #ifdef RVC_OS_WIN
  65. m_scanThread=NULL;
  66. m_pAudioPlayer = NULL;
  67. memset(m_pVideoPlayer, 0, sizeof(m_pVideoPlayer));
  68. memset(m_pImagePlayer, 0, sizeof(m_pImagePlayer));
  69. #else
  70. m_scanThreadId = 0;
  71. m_pMediaAudioPlayer = NULL;
  72. memset(m_pMediaPlayer, 0, sizeof(m_pMediaPlayer));
  73. memset(m_pPicturePlayer, 0, sizeof(m_pPicturePlayer));
  74. m_uMediaPlayThreadId = 0;
  75. m_uNoticePlayThreadId = 0;
  76. m_badplayflag = true;
  77. m_bgetflag = false;
  78. m_bgetico = false;
  79. m_remote_audio_queue = NULL;
  80. m_pFile = NULL;
  81. m_bRecordPCM = false;
  82. #endif // RVC_OS_WIN
  83. ZeroMemory(&m_mediaParam, sizeof(MediaPlayParam));
  84. }
  85. CLocalMediaPlayEntity::~CLocalMediaPlayEntity()
  86. {
  87. SecureClientRelease();
  88. DWORD exitCode = 0;
  89. #ifdef RVC_OS_WIN
  90. if (m_scanThread)
  91. {
  92. TerminateThread(m_scanThread, exitCode);
  93. m_scanThread = NULL;
  94. }
  95. #else
  96. m_scanexitflag = true;
  97. if (0 == pthread_join(m_scanThreadId, NULL)) {
  98. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pthread join scanThreadId success.");
  99. }
  100. m_bgetflag = false;
  101. m_bgetico = false;
  102. #endif // RVC_OS_WIN
  103. }
  104. void CLocalMediaPlayEntity::SecureClientRelease()
  105. {
  106. if (NULL != m_connection)
  107. {
  108. if (m_connection->IsConnectionOK())
  109. m_connection->Close();
  110. m_connection->DecRefCount();
  111. m_connection = NULL;
  112. }
  113. }
  114. bool CLocalMediaPlayEntity::SecureClientConnect()
  115. {
  116. if (NULL != m_connection && m_connection->IsConnectionOK())
  117. return true;
  118. SecureClientRelease();
  119. m_connection = new CAdvertSyncConnection(this);
  120. return m_connection->ConnectFromCentralSetting();
  121. }
  122. void CLocalMediaPlayEntity::setMediaPath()
  123. {
  124. CSimpleStringA downloadPath, mediaPath;
  125. GetFunction()->GetPath("Download", downloadPath);
  126. GetFunction()->GetPath("Ad", mediaPath);
  127. m_mediaManage.setDefaultDownloadPath(downloadPath.GetData());
  128. m_mediaManage.setDefaultAddvertPath(mediaPath.GetData());
  129. }
  130. CServerSessionBase* CLocalMediaPlayEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
  131. {
  132. LOG_FUNCTION();
  133. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
  134. return new CLocalMediaPlaySession(this, m_id_seq++);
  135. }
  136. void CLocalMediaPlayEntity::loadDefaultMedia()
  137. {
  138. #ifdef RVC_OS_WIN
  139. m_defaultImg.clear();
  140. m_defaultAudio.clear();
  141. m_defaultVideo.clear();
  142. #else
  143. m_defaultPic.clear();
  144. m_Audios.clear();
  145. m_Videos.clear();
  146. #endif // RVC_OS_WIN
  147. // 读取LocalMediaPlay.ini中的配置
  148. CSimpleStringA strRootPath;
  149. ErrorCodeEnum Error = Error_Succeed;
  150. Error = GetFunction()->GetPath("ADData", strRootPath);
  151. if (Error != Error_Succeed) {
  152. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Fail to get local media root path!");
  153. return;
  154. }
  155. //General
  156. IS_DEBUG = false;
  157. scanTime = 600;
  158. removeOldTime = 1800;
  159. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("runDebug:%s, scanTime:%d", IS_DEBUG ? "true" : "false", scanTime);
  160. CSimpleStringA imgPath = strRootPath + SPLIT_SLASH_STR + "Image" + SPLIT_SLASH_STR;
  161. //Image0
  162. do
  163. {
  164. #ifdef RVC_OS_WIN
  165. CImgPlayConfig curImg;
  166. ZeroMemory(&curImg, sizeof(CImgPlayConfig));
  167. #else
  168. CPicPlayConfig curImg;
  169. ZeroMemory(&curImg, sizeof(CPicPlayConfig));
  170. #endif // RVC_OS_WIN
  171. strncpy(curImg.strRootPath, (LPCSTR)imgPath, sizeof(curImg.strRootPath));
  172. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("curSection: %s, config.strRootPath: %s", "Image0", curImg.strRootPath);
  173. curImg.bFullScreen = true;
  174. curImg.bPrimMonitor = false;
  175. curImg.nPlayCnt = 0;
  176. curImg.nPlayInterval = 5000;
  177. curImg.nFileCnt = 4;
  178. strcpy(curImg.strFileNames[0], "Ad0/0.jpg");
  179. strcpy(curImg.strFileNames[1], "Ad0/1.jpg");
  180. strcpy(curImg.strFileNames[2], "Ad0/2.jpg");
  181. strcpy(curImg.strFileNames[3], "Ad0/3.jpg");
  182. #ifdef RVC_OS_WIN
  183. m_defaultImg.push_back(curImg);
  184. #else
  185. m_defaultPic.push_back(curImg);
  186. #endif // RVC_OS_WIN
  187. } while (false);
  188. //Image1
  189. do {
  190. #ifdef RVC_OS_WIN
  191. CImgPlayConfig curImg;
  192. ZeroMemory(&curImg, sizeof(CImgPlayConfig));
  193. #else
  194. CPicPlayConfig curImg;
  195. ZeroMemory(&curImg, sizeof(CPicPlayConfig));
  196. #endif // RVC_OS_WIN
  197. strncpy(curImg.strRootPath, (LPCSTR)imgPath, sizeof(curImg.strRootPath));
  198. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("curSection: %s, config.strRootPath: %s", "Image1", curImg.strRootPath);
  199. curImg.bFullScreen = false;
  200. curImg.bPrimMonitor = true;
  201. curImg.nPlayCnt = 6;
  202. curImg.nPlayInterval = 1000;
  203. curImg.nFileCnt = 4;
  204. strcpy(curImg.strFileNames[0], "Ad1/0.jpg");
  205. strcpy(curImg.strFileNames[1], "Ad1/1.jpg");
  206. strcpy(curImg.strFileNames[2], "Ad1/2.jpg");
  207. strcpy(curImg.strFileNames[3], "Ad1/3.jpg");
  208. #ifdef RVC_OS_WIN
  209. m_defaultImg.push_back(curImg);
  210. #else
  211. m_defaultPic.push_back(curImg);
  212. #endif // RVC_OS_WIN
  213. } while (false);
  214. CSimpleStringA videoPath = strRootPath + SPLIT_SLASH_STR + "Video" + SPLIT_SLASH_STR;
  215. CSimpleStringA strRunTime_S("09:00:00"), strRunTime_E("17:30:00");
  216. //Video0
  217. do
  218. {
  219. #ifdef RVC_OS_WIN
  220. CWmpPlayConfig curVideo;
  221. ZeroMemory(&curVideo, sizeof(CWmpPlayConfig));
  222. #else
  223. CMediaPlayConfig curVideo = { 0 };
  224. #endif // RVC_OS_WIN
  225. strcpy(curVideo.strRootPath, (LPCSTR)videoPath);
  226. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strRootPath: %s", curVideo.strRootPath);
  227. curVideo.bFullScreen = true;
  228. curVideo.bPrimMonitor = false;
  229. curVideo.bSimpleMode = true;
  230. curVideo.nPlayCnt = 1;
  231. curVideo.nPlayInterval = 2000;
  232. curVideo.nVolume = 50;
  233. CSmartPointer<IConfigInfo> tempConfig;
  234. Error = GetFunction()->OpenConfig(Config_Run, tempConfig);
  235. if (Error == Error_Succeed) {
  236. Error = tempConfig->ReadConfigValueInt("LocalVideo", "Volume", curVideo.nVolume);
  237. if (Error != Error_Succeed || curVideo.nVolume < 0 || curVideo.nVolume > 100)
  238. curVideo.nVolume = 50;
  239. m_defaultVolum = curVideo.nVolume;
  240. }
  241. strcpy(curVideo.strVideoRunTime_S, (LPCSTR)strRunTime_S);
  242. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strVideoRunTime_S: %s", (LPCSTR)strRunTime_S);
  243. strcpy(curVideo.strVideoRunTime_E, (LPCSTR)strRunTime_E);
  244. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strVideoRunTime_E: %s", (LPCSTR)strRunTime_E);
  245. curVideo.nFileCnt = 1;
  246. strcpy(curVideo.strFileNames[0], "可视柜台欢迎界面.wmv");
  247. #ifdef RVC_OS_WIN
  248. m_defaultVideo.push_back(curVideo);
  249. #else
  250. m_Videos.push_back(curVideo);
  251. #endif // RVC_OS_WIN
  252. } while (false);
  253. //Video1
  254. do {
  255. #ifdef RVC_OS_WIN
  256. CWmpPlayConfig curVideo;
  257. ZeroMemory(&curVideo, sizeof(CWmpPlayConfig));
  258. #else
  259. CMediaPlayConfig curVideo = { 0 };
  260. #endif // RVC_OS_WIN
  261. strcpy(curVideo.strRootPath, (LPCSTR)videoPath);
  262. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strRootPath: %s", curVideo.strRootPath);
  263. curVideo.bFullScreen = true;
  264. curVideo.bPrimMonitor = false;
  265. curVideo.bSimpleMode = true;
  266. curVideo.nPlayCnt = 0;
  267. curVideo.nPlayInterval = 10000;
  268. curVideo.nVolume = 50;
  269. CSmartPointer<IConfigInfo> tempConfig;
  270. Error = GetFunction()->OpenConfig(Config_Run, tempConfig);
  271. if (Error == Error_Succeed) {
  272. Error = tempConfig->ReadConfigValueInt("LocalVideo", "Volume", curVideo.nVolume);
  273. if (Error != Error_Succeed || curVideo.nVolume < 0 || curVideo.nVolume > 100)
  274. curVideo.nVolume = 50;
  275. m_defaultVolum = curVideo.nVolume;
  276. }
  277. strcpy(curVideo.strVideoRunTime_S, (LPCSTR)strRunTime_S);
  278. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strVideoRunTime_S: %s", (LPCSTR)strRunTime_S);
  279. strcpy(curVideo.strVideoRunTime_E, (LPCSTR)strRunTime_E);
  280. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strVideoRunTime_E: %s", (LPCSTR)strRunTime_E);
  281. curVideo.nFileCnt = 1;
  282. strcpy(curVideo.strFileNames[0], "可视柜台广告界面2.mp4");
  283. #ifdef RVC_OS_WIN
  284. m_defaultVideo.push_back(curVideo);
  285. #else
  286. m_Videos.push_back(curVideo);
  287. #endif // RVC_OS_WIN
  288. } while (false);
  289. CSimpleStringA audioPath = strRootPath + SPLIT_SLASH_STR + "Audio" + SPLIT_SLASH_STR;
  290. //Audio
  291. do
  292. {
  293. #ifdef RVC_OS_WIN
  294. CWmpPlayConfig curAudio;
  295. ZeroMemory(&curAudio, sizeof(CWmpPlayConfig));
  296. #else
  297. CMediaPlayConfig curAudio = { 0 };
  298. #endif // RVC_OS_WIN
  299. strcpy(curAudio.strRootPath, (LPCSTR)audioPath);
  300. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.strRootPath: %s", curAudio.strRootPath);
  301. curAudio.nPlayCnt = 1;
  302. curAudio.nPlayInterval = 5000;
  303. auto audioRet = GetLocalAudioVolume();
  304. if (audioRet.first)
  305. curAudio.nVolume = audioRet.second;
  306. else
  307. curAudio.nVolume = m_defaultVolum;
  308. #ifdef RVC_OS_WIN
  309. m_defaultAudio.push_back(curAudio);
  310. #else
  311. m_Audios.push_back(curAudio);
  312. #endif // RVC_OS_WIN
  313. } while (false);
  314. }
  315. #ifdef RVC_OS_WIN
  316. BOOL CLocalMediaPlayEntity::LoadPlayConfig(CWmpPlayConfig& config, int CfgInx)
  317. {
  318. if (CfgInx >= MAX_PLAY_CHANNELS || CfgInx < 0)
  319. {
  320. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while LoadConfig!");
  321. return FALSE;
  322. }
  323. if (config.eMode == LOCALAUDIO && CfgInx < m_defaultAudio.size())
  324. {
  325. memcpy(&config, &(m_defaultAudio[CfgInx]), sizeof(CWmpPlayConfig));
  326. }
  327. else if (config.eMode == LOCALVIDEO && CfgInx < m_defaultVideo.size())
  328. {
  329. memcpy(&config, &(m_defaultVideo[CfgInx]), sizeof(CWmpPlayConfig));
  330. }
  331. else {
  332. return FALSE;
  333. }
  334. return TRUE;
  335. }
  336. BOOL CLocalMediaPlayEntity::LoadPlayConfig(CImgPlayConfig& config, int CfgInx)
  337. {
  338. if (CfgInx >= m_defaultImg.size() || CfgInx < 0)
  339. {
  340. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while LoadConfig!");
  341. return FALSE;
  342. }
  343. memcpy(&config, &(m_defaultImg[CfgInx]), sizeof(CImgPlayConfig));
  344. return TRUE;
  345. }
  346. void CLocalMediaPlayEntity::WmpDebug(const char* fmt, ...)
  347. {
  348. va_list arg;
  349. va_start(arg, fmt);
  350. vDbg(fmt, arg);
  351. va_end(arg);
  352. }
  353. void CLocalMediaPlayEntity::ImgDebug(const char* fmt, ...)
  354. {
  355. va_list arg;
  356. va_start(arg, fmt);
  357. vDbg(fmt, arg);
  358. va_end(arg);
  359. }
  360. #else
  361. int CLocalMediaPlayEntity::LoadPlayConfig(CMediaPlayConfig& config, int CfgInx)
  362. {
  363. if (CfgInx >= MAX_PLAY_CHANNELS || CfgInx < 0)
  364. {
  365. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while LoadConfig!");
  366. return -1;
  367. }
  368. if (config.eMode == LOCALAUDIO && CfgInx < m_Audios.size())
  369. {
  370. memcpy(&config, &(m_Audios[CfgInx]), sizeof(CMediaPlayConfig));
  371. }
  372. else if (config.eMode == LOCALVIDEO && CfgInx < m_Videos.size())
  373. {
  374. memcpy(&config, &(m_Videos[CfgInx]), sizeof(CMediaPlayConfig));
  375. }
  376. else {
  377. return -1;
  378. }
  379. return 0;
  380. }
  381. int CLocalMediaPlayEntity::LoadPlayConfig(CPicPlayConfig& config, int CfgInx)
  382. {
  383. if (CfgInx >= m_defaultPic.size() || CfgInx < 0)
  384. {
  385. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while LoadConfig!");
  386. return -1;
  387. }
  388. memcpy(&config, &(m_defaultPic[CfgInx]), sizeof(CPicPlayConfig));
  389. return 0;
  390. }
  391. void CLocalMediaPlayEntity::Debug(media_loglevel log_level, const char* fmt, ...)
  392. {
  393. if (log_level >= MEDIA_LOG_ERROR){
  394. va_list arg;
  395. va_start(arg, fmt);
  396. int n = vsnprintf(NULL, 0, fmt, arg);
  397. if (n >= MAX_PATH) {
  398. char* buf = (char*)malloc((size_t)(n + 1));
  399. vsnprintf(buf, n + 1, fmt, arg);
  400. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
  401. free(buf);
  402. }
  403. else {
  404. char strlog[MAX_PATH] = { 0 };
  405. vsnprintf(strlog, MAX_PATH, fmt, arg);
  406. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
  407. }
  408. va_end(arg);
  409. }
  410. }
  411. void CLocalMediaPlayEntity::PicDebug(pic_loglevel log_level, const char* fmt, ...)
  412. {
  413. if (log_level >= PIC_LOG_ERROR){
  414. va_list arg;
  415. va_start(arg, fmt);
  416. int n = vsnprintf(NULL, 0, fmt, arg);
  417. if (n >= MAX_PATH) {
  418. char* buf = (char*)malloc((size_t)(n + 1));
  419. vsnprintf(buf, n + 1, fmt, arg);
  420. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
  421. free(buf);
  422. }
  423. else {
  424. char strlog[MAX_PATH] = { 0 };
  425. vsnprintf(strlog, MAX_PATH, fmt, arg);
  426. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
  427. }
  428. va_end(arg);
  429. }
  430. }
  431. void CLocalMediaPlayEntity::MediaPlayFinished(int iMediaType)
  432. {
  433. if (0 == iMediaType) {
  434. AudioPlayRet ret;
  435. ret.AudioNames = m_lastPlayAudio.c_str();
  436. ret.ret = true;
  437. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play audio %s success.", ret.AudioNames.GetData());
  438. if (false == m_buserstopaudio) {
  439. SpSendBroadcast(GetFunction(), eMsg_AudioPlayRet, eMsgSig_AudioPlayRet, ret);
  440. }
  441. else {
  442. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("user stop, not broadcast!");
  443. }
  444. }
  445. else {
  446. VideoPlayRet ret;
  447. ret.VideoNames = m_lastPlayVideo.c_str();
  448. ret.ret = true;
  449. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play video notice %s success.", ret.VideoNames.GetData());
  450. SpSendBroadcast(GetFunction(), eMsg_VideoPlayRet, eMsgSig_VideoPlayRet, ret);
  451. }
  452. }
  453. int CLocalMediaPlayEntity::GetMediaPlayerIcoPath(char* strPath, size_t uLen)
  454. {
  455. return GetPlayerIcoPath(strPath, uLen);
  456. }
  457. int CLocalMediaPlayEntity::GetAudioOutDevName(char* strDev, size_t uLen)
  458. {
  459. int iRet = -1;
  460. int idatalen = m_strAudioOutDev.GetLength();
  461. if (uLen > idatalen && idatalen > 0) {
  462. memcpy(strDev, m_strAudioOutDev.GetData(), idatalen);
  463. iRet = 0;
  464. if (false == m_bgetflag) {
  465. m_bgetflag = true;
  466. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d audio Out Device Name is %s.", __FUNCTION__, __LINE__, strDev);
  467. }
  468. }
  469. return iRet;
  470. }
  471. int CLocalMediaPlayEntity::PlayingAudioDataCallback(audio_param_t* param, const void* input, unsigned long uaudiolen)
  472. {
  473. int iRet = -1;
  474. if (m_bStartRecord) {
  475. if (false == m_bloged) {
  476. char strmsg[MAX_PATH * 2] = { 0 };
  477. snprintf(strmsg, MAX_PATH * 2, "audio param target (%d channels, %d Hz, channel_layout(%d), frame_size(%d), bytes_per_sec(%d)).", param->channels, param->freq, param->channel_layout, param->frame_size, param->bytes_per_sec);
  478. m_bloged = true;
  479. LogWarn(Severity_Low, Error_Debug, LOG_EVT_PLAYING_AUDIO_INFOS, strmsg);
  480. }
  481. if (8000 == param->freq && 1 == param->channels && 1 == param->fmt) {
  482. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d uaudiolen:%d", __FUNCTION__, __LINE__, uaudiolen);
  483. if (uaudiolen + m_leftlen <= RVC_AUDIO_BUFFER_LEN) {
  484. int icount = (uaudiolen + m_leftlen) / RVC_AUDIO_LEN;
  485. if (icount > 0) {
  486. memcpy(m_audiobuffer + m_leftlen, (char*)input, icount * RVC_AUDIO_LEN - m_leftlen);
  487. for (int i = 0; i < icount; i++) {
  488. audio_frame frm;
  489. char straudio[RVC_AUDIO_LEN] = { 0 };
  490. memcpy(straudio, m_audiobuffer + i * RVC_AUDIO_LEN, RVC_AUDIO_LEN);
  491. frm.bitspersample = 16;
  492. frm.format = param->fmt;
  493. frm.data = straudio;
  494. frm.framesize = RVC_AUDIO_LEN;
  495. frm.nchannels = param->channels;
  496. frm.samplespersec = param->freq;
  497. frm.iseriesnumber = m_iseriesnumber++;
  498. if (!m_remote_audio_queue->InsertAudio(&frm)) {
  499. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("InsertAudio failed! frameCount:%d", frm.framesize);
  500. }
  501. else {
  502. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d InsertAudio(seriesnumber = %d) success", __FUNCTION__, __LINE__, frm.iseriesnumber);
  503. if (m_bRecordPCM && m_pFile){
  504. fwrite(frm.data, RVC_AUDIO_LEN, 1, m_pFile);
  505. }
  506. }
  507. }
  508. memset(m_audiobuffer, 0, RVC_AUDIO_BUFFER_LEN);
  509. int ileftaudio = uaudiolen - (icount * RVC_AUDIO_LEN - m_leftlen);
  510. memcpy(m_audiobuffer, (char*)input + icount * RVC_AUDIO_LEN - m_leftlen, ileftaudio);
  511. m_leftlen = ileftaudio;
  512. }
  513. else {
  514. memcpy(m_audiobuffer + m_leftlen, (char*)input , uaudiolen);
  515. m_leftlen += uaudiolen;
  516. }
  517. }
  518. iRet = 0;
  519. }
  520. }
  521. return iRet;
  522. }
  523. int CLocalMediaPlayEntity::GetPicPlayerIcoPath(char* strPath, size_t uLen)
  524. {
  525. return GetPlayerIcoPath(strPath, uLen);
  526. }
  527. bool CLocalMediaPlayEntity::GetPlayFlag()
  528. {
  529. return m_badplayflag;
  530. }
  531. bool CLocalMediaPlayEntity::GetScanExitFlag()
  532. {
  533. return m_scanexitflag;
  534. }
  535. DeviceTypeEnum CLocalMediaPlayEntity::GetDeviceType()
  536. {
  537. return m_eDeviceType;
  538. }
  539. int CLocalMediaPlayEntity::GetPlayerIcoPath(char* strPath, size_t uLen)
  540. {
  541. int iRet = -1;
  542. if (NULL == strPath) {
  543. return iRet;
  544. }
  545. CSimpleStringA csBinPath;
  546. ErrorCodeEnum eErrPath = GetFunction()->GetPath("Bin", csBinPath);
  547. if (eErrPath != Error_Succeed) {
  548. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetBasePath failed (%d).", eErrPath);
  549. return iRet;
  550. }
  551. CSimpleStringA szIcoName("rvc_media_player_64px.bmp");
  552. szIcoName = csBinPath + SPLIT_SLASH_STR + szIcoName;
  553. if (m_bgetico == false) {
  554. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("media player ico full path is %s.", szIcoName.GetData());
  555. m_bgetico = true;
  556. }
  557. if (uLen > szIcoName.GetLength()) {
  558. memcpy(strPath, szIcoName.GetData(), szIcoName.GetLength());
  559. iRet = 0;
  560. m_bgetico = true;
  561. }
  562. return iRet;
  563. }
  564. int CLocalMediaPlayEntity::GetAudioOutDev()
  565. {
  566. int iRet = -1;
  567. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  568. CSmartPointer<IConfigInfo> spRootConfig;
  569. ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spRootConfig);
  570. if (Error == Error_Succeed) {
  571. SpIniMappingTable table;
  572. table.AddEntryString("audio", "handfree_out_dev", m_strAudioOutDev, "$");
  573. Error = table.Load(spRootConfig);
  574. if (Error == Error_Succeed) {
  575. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Audio Out Device name is %s.", m_strAudioOutDev.GetData());
  576. iRet = 0;
  577. }
  578. }
  579. return iRet;
  580. }
  581. #endif // RVC_OS_WIN
  582. void CLocalMediaPlayEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  583. const DWORD dwSysError, const DWORD dwUserCode, const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  584. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName, const char *pszMessage, const linkContext& pLinkInfo)
  585. {
  586. if (dwUserCode == LOG_EVT_SELFCHECK_IEBROWSER_IDLE){
  587. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("IEBrowser to idle, stop all media!");
  588. StopAll();
  589. }
  590. else if(LOG_EVT_UI_STARTREMOTERECORD == dwUserCode){
  591. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Start remote record.");
  592. HandleRemoteRecord(pszMessage);
  593. }
  594. else if (LOG_EVT_UI_STOPREMOTERECORD == dwUserCode) {
  595. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Stop remote record.");
  596. m_bStartRecord = false;
  597. m_iseriesnumber = 0;
  598. if (NULL != m_remote_audio_queue) {
  599. delete m_remote_audio_queue;
  600. m_remote_audio_queue = NULL;
  601. }
  602. if (m_pFile) {
  603. fclose(m_pFile);
  604. m_pFile = NULL;
  605. }
  606. }
  607. }
  608. void CLocalMediaPlayEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
  609. {
  610. LOG_FUNCTION();
  611. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  612. pTransactionContext->SendAnswer(Error);
  613. }
  614. ErrorCodeEnum CLocalMediaPlayEntity::__OnStart(ErrorCodeEnum preOperationError)
  615. {
  616. #ifdef RVC_OS_WIN
  617. //toolkit_setenv("SDL_AUDIODRIVER", "winmm");
  618. #else
  619. GetAudioOutDev();
  620. #endif // RVC_OS_WIN
  621. m_eDeviceType = eStand2sType;
  622. m_eDeviceType = RvcGetDeviceType();
  623. return Error_Succeed;
  624. }
  625. void CLocalMediaPlayEntity::OnStarted()
  626. {
  627. LogEvent(Severity_Middle, LOG_EVT_MOD_LOCALPLAYER_STARTED_SUCCESS, "local meida play entity started successfully.");
  628. for (int i = 0; i != MAX_PLAY_CHANNELS; ++i)
  629. {
  630. #ifdef RVC_OS_WIN
  631. m_pVideoPlayer[i] = new Clibwmpplayer(this);
  632. m_pImagePlayer[i] = new Clibimgplayer(this);
  633. #else
  634. mediaplayer_init();
  635. m_pMediaPlayer[i] = new Clibmediaplayer(this);
  636. m_pPicturePlayer[i] = new Clibpictureplayer(this);
  637. #endif
  638. }
  639. #ifdef RVC_OS_WIN
  640. m_pAudioPlayer = new Clibwmpplayer(this);
  641. #else
  642. m_pMediaAudioPlayer = new Clibmediaplayer(this);
  643. signal(SIGTERM, sig_handler);
  644. #endif // RVC_OS_WIN
  645. if (!IsRunConfigExist()){
  646. SetLocalVideoVolume(0, 50);
  647. SetLocalAudioVolume(50);
  648. }
  649. //setMediaPath();
  650. loadDefaultMedia();
  651. GetFunction()->SubscribeLog(m_SubIDIEIdle, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_SELFCHECK_IEBROWSER_IDLE, NULL, false);
  652. GetFunction()->SubscribeLog(m_SubIDStartRecord, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD, NULL, false);
  653. GetFunction()->SubscribeLog(m_SubIDStopRecord, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD, NULL, false);
  654. #ifdef RVC_OS_WIN
  655. m_scanThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)& qryMedia, this, 0, NULL);
  656. if (NULL != m_scanThread)
  657. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create qryMeia thread success, %d.", m_scanThread);
  658. #else
  659. int err = pthread_create(&m_scanThreadId, NULL, queryMedia, this);
  660. if (0 == err) {
  661. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create queryMedia thread success, %u.", m_scanThreadId);
  662. }
  663. else {
  664. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create queryMedia thread failed.");
  665. }
  666. GetPcmRecordFlag();
  667. #endif // RVC_OS_WIN
  668. }
  669. void CLocalMediaPlayEntity::OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext)
  670. {
  671. LOG_FUNCTION();
  672. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  673. pTransactionContext->SendAnswer(Error);
  674. }
  675. ErrorCodeEnum CLocalMediaPlayEntity::__OnClose(ErrorCodeEnum preOperationError)
  676. {
  677. for (int i = 0; i != MAX_PLAY_CHANNELS; ++i)
  678. {
  679. #ifdef RVC_OS_WIN
  680. delete m_pVideoPlayer[i]; m_pVideoPlayer[i] = NULL;
  681. delete m_pImagePlayer[i]; m_pImagePlayer[i] = NULL;
  682. #else
  683. delete m_pMediaPlayer[i]; m_pMediaPlayer[i] = NULL;
  684. delete m_pPicturePlayer[i]; m_pPicturePlayer[i] = NULL;
  685. #endif // RVC_OS_WIN
  686. }
  687. #ifdef RVC_OS_WIN
  688. delete m_pAudioPlayer; m_pAudioPlayer = NULL;
  689. #else
  690. delete m_pMediaAudioPlayer; m_pMediaAudioPlayer = NULL;
  691. mediaplayer_term();
  692. #endif // RVC_OS_WIN
  693. GetFunction()->UnsubscribeLog(m_SubIDIEIdle);
  694. GetFunction()->UnsubscribeLog(m_SubIDStartRecord);
  695. GetFunction()->UnsubscribeLog(m_SubIDStopRecord);
  696. return Error_Succeed;
  697. }
  698. #ifdef RVC_OS_WIN
  699. DWORD WINAPI CheckAudioThread(LPVOID param)
  700. {
  701. CLocalMediaPlayEntity *entity = (CLocalMediaPlayEntity*)param;
  702. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin CheckAudioThread");
  703. HANDLE playThread = NULL;
  704. if (!entity->m_pAudioPlayer->checkIsPlay(playThread))
  705. {
  706. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Create play audio Media Thread Failed!");
  707. return 0;
  708. }
  709. WaitForSingleObject(playThread, INFINITE);
  710. entity->m_pAudioPlayer->Close();
  711. AudioPlayRet ret;
  712. ret.AudioNames = entity->m_lastPlayAudio.c_str();
  713. ret.ret = true;
  714. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play audio %s success", ret.AudioNames);
  715. SpSendBroadcast(entity->GetFunction(), eMsg_AudioPlayRet, eMsgSig_AudioPlayRet, ret);
  716. return 0;
  717. }
  718. #else
  719. void* StartAudioPlayingThreadFunc(void* param)
  720. {
  721. CLocalMediaPlayEntity* entity = (CLocalMediaPlayEntity*)param;
  722. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter StartAudioPlayingThreadFunc");
  723. const char* pAudioNames = entity->m_lastPlayAudio.c_str();
  724. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin StartAudio, and Audio Info is %s.", pAudioNames);
  725. if (0 == entity->m_pMediaAudioPlayer->PlayLocalAudio(pAudioNames)) {
  726. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StartAudio, and Audio Info is %s.", pAudioNames);
  727. }
  728. else{
  729. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("StartAudio failed, for %s is not exsit.", pAudioNames);
  730. }
  731. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Leave StartAudioPlayingThreadFunc");
  732. entity->m_uMediaPlayThreadId = 0;
  733. return 0;
  734. }
  735. #endif // RVC_OS_WIN
  736. #ifdef RVC_OS_WIN
  737. DWORD WINAPI MediaPlayThread(LPVOID param)
  738. {
  739. CLocalMediaPlayEntity *entity = (CLocalMediaPlayEntity*)param;
  740. while (TRUE)
  741. {
  742. vector<ResourceParse> curParse;
  743. entity->m_mediaManage.GetPlayListByLocal(curParse);
  744. if (0 == curParse.size())
  745. {
  746. HANDLE playThread = NULL;
  747. CWmpPlayConfig config;
  748. ZeroMemory(&config, sizeof(CWmpPlayConfig));
  749. memcpy(&config, &(entity->m_defaultVideo[entity->m_mediaParam.nCfgInx]), sizeof(CWmpPlayConfig));
  750. config.nPlayCnt = 1; //can be change
  751. config.eMode = LOCALVIDEO;
  752. config.nWndX = entity->m_mediaParam.nWndX;
  753. config.nWndY = entity->m_mediaParam.nWndY;
  754. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  755. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  756. if (IS_DEBUG)
  757. {
  758. config.bFullScreen = false;
  759. config.bPrimMonitor = true;
  760. }
  761. // add by ly@2018/07/30
  762. if (!entity->GetLocalVideoVolume(0, config.nVolume))
  763. {
  764. config.nVolume = entity->m_defaultVolum;
  765. }
  766. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.nVolume=%d while play local video.", config.nVolume);
  767. // 判断当前时间是否允许播放
  768. SYSTEMTIME st;
  769. GetLocalTime(&st);
  770. TCHAR strNow[TIME_LEN];
  771. sprintf(strNow, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond);
  772. if (strcmp(strNow, config.strVideoRunTime_S) < 0 || strcmp(strNow, config.strVideoRunTime_E) >= 0)
  773. {
  774. Sleep(10000);
  775. continue;
  776. }
  777. entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
  778. if (!entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->checkIsPlay(playThread))
  779. {
  780. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Create play Video Media Thread Failed!");
  781. return 0;
  782. }
  783. WaitForSingleObject(playThread, INFINITE);
  784. if (entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->checkIsStop())
  785. {
  786. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play video");
  787. return 0;
  788. }
  789. else
  790. entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->Close();
  791. }
  792. for (vector<ResourceParse>::iterator i = curParse.begin(); i != curParse.end(); i++)
  793. {
  794. HANDLE playThread = NULL;
  795. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin play extend %c:%s, %s", i->type, i->resourcePath.c_str(), i->videoNames.c_str());
  796. if ('V' == i->type)
  797. {//video
  798. CWmpPlayConfig config;
  799. ZeroMemory(&config, sizeof(CWmpPlayConfig));
  800. config.bFullScreen = IS_DEBUG ? false : i->fullScreen;
  801. config.bPrimMonitor = IS_DEBUG ? true : i->primMonitor;
  802. config.bSimpleMode = i->simpleMode;
  803. config.eMode = LOCALVIDEO;
  804. config.nFileCnt = 1;
  805. config.nPlayCnt = 1;
  806. config.nPlayInterval = i->playInterval;
  807. // add by ly@2018/07/30
  808. //config.nVolume = IS_DEBUG ? 0 : entity->m_defaultVolum;
  809. if (!entity->GetLocalVideoVolume(0, config.nVolume))
  810. {
  811. config.nVolume = entity->m_defaultVolum;
  812. }
  813. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.nVolume=%d while play local video.", config.nVolume);
  814. config.nWndX = entity->m_mediaParam.nWndX;
  815. config.nWndY = entity->m_mediaParam.nWndY;
  816. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  817. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  818. strncpy_s(config.strRootPath, i->resourcePath.c_str(), sizeof(config.strRootPath));
  819. strncpy_s(config.strFileNames[0], i->videoNames.c_str(), 256);
  820. strncpy_s(config.strVideoRunTime_S, "09:00:00", sizeof(config.strVideoRunTime_S));
  821. strncpy_s(config.strVideoRunTime_E, "17:30:00", sizeof(config.strVideoRunTime_E));
  822. CSimpleStringA strVideoPath = config.strRootPath;
  823. CSimpleStringA strVideoFileName = config.strFileNames[0];
  824. CSimpleStringA strVideoFullPath = strVideoPath + strVideoFileName;
  825. BOOL bRet = IsFileExisted(strVideoFullPath.GetData());
  826. if (FALSE == bRet && false == entity->GetLocalLogFlag()){
  827. char strmsg[MAX_PATH] = {0};
  828. snprintf(strmsg, MAX_PATH, "adv video file %s not exist!", strVideoFullPath.GetData());
  829. LogWarn(Severity_Low, Error_Debug, LOG_EVT_ADV_VIDEO_NOT_EXIST, strmsg);
  830. entity->SetLocalLogFlag(true);
  831. }
  832. entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
  833. if (!entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->checkIsPlay(playThread))
  834. {
  835. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Create play Video Media Thread Failed!");
  836. return 0;
  837. }
  838. WaitForSingleObject(playThread, INFINITE);
  839. if (entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->checkIsStop())
  840. {//ֹͣ����
  841. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play video");
  842. return 0;
  843. }
  844. else
  845. entity->m_pVideoPlayer[entity->m_mediaParam.nCfgInx]->Close();
  846. }
  847. else if ('P' == i->type)
  848. {//play Image
  849. CImgPlayConfig config;
  850. ZeroMemory(&config, sizeof(CImgPlayConfig));
  851. config.bFullScreen = IS_DEBUG ? false : i->fullScreen;
  852. config.bPrimMonitor = IS_DEBUG ? true : i->primMonitor;
  853. config.nFileCnt = 1;
  854. config.nPlayCnt = 1;
  855. config.nPlayInterval = i->playInterval;
  856. config.nWndX = entity->m_mediaParam.nWndX;
  857. config.nWndY = entity->m_mediaParam.nWndY;
  858. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  859. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  860. strncpy_s(config.strRootPath, i->resourcePath.c_str(), sizeof(config.strRootPath));
  861. strncpy_s(config.strFileNames[0], i->videoNames.c_str(), 256);
  862. CSimpleStringA strPicPath = config.strRootPath;
  863. CSimpleStringA strPicFileName = config.strFileNames[0];
  864. CSimpleStringA strPicFullPath = strPicPath + strPicFileName;
  865. BOOL bRet = IsFileExisted(strPicFullPath.GetData());
  866. if (FALSE == bRet && false == entity->GetLocalPicLogFlag()){
  867. char strmsg[MAX_PATH] = {0};
  868. snprintf(strmsg, MAX_PATH, "adv picture file %s not exist!", strPicFullPath.GetData());
  869. LogWarn(Severity_Low, Error_Debug, LOG_EVT_ADV_PIC_NOT_EXIST, strmsg);
  870. entity->SetLocalPicLogFlag(true);
  871. }
  872. entity->m_pImagePlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
  873. if (!entity->m_pImagePlayer[entity->m_mediaParam.nCfgInx]->checkIsPlay(playThread))
  874. {
  875. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Create play Image Media Thread Failed!");
  876. return 0;
  877. }
  878. WaitForSingleObject(playThread, i->playInterval);
  879. if (entity->m_pImagePlayer[entity->m_mediaParam.nCfgInx]->checkIsStop())
  880. {//ֹͣ����
  881. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play Image");
  882. return 0;
  883. }
  884. else
  885. entity->m_pImagePlayer[entity->m_mediaParam.nCfgInx]->Close();
  886. }
  887. }
  888. }
  889. return 0;
  890. }
  891. #else
  892. void* StartMediaPlayFunc(void* param)
  893. {
  894. int iRet = -1;
  895. if (NULL == param){
  896. return (void*)&iRet;
  897. }
  898. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter Media Play Function.");
  899. CLocalMediaPlayEntity* entity = (CLocalMediaPlayEntity*)param;
  900. while (entity->GetPlayFlag())
  901. {
  902. rvcResourceParse_t ResourceList[MAX_LOCAL_MEDIAS] = { 0 };
  903. size_t uCount = entity->m_mediaManage.GetPlayListByLocal(ResourceList, MAX_LOCAL_MEDIAS);
  904. unsigned int ustart_time = y2k_time_now();
  905. if (0 == uCount){
  906. int64_t playThreadId = 0;
  907. CMediaPlayConfig config = {0};
  908. memcpy(&config, &(entity->m_Videos[entity->m_mediaParam.nCfgInx]), sizeof(CMediaPlayConfig));
  909. config.nPlayCnt = 1; //can be change
  910. config.eMode = LOCALVIDEO;
  911. config.nWndX = entity->m_mediaParam.nWndX;
  912. config.nWndY = entity->m_mediaParam.nWndY;
  913. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  914. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  915. if (IS_DEBUG){
  916. config.bFullScreen = false;
  917. config.bPrimMonitor = true;
  918. }
  919. if (!entity->GetLocalVideoVolume(0, config.nVolume)){
  920. config.nVolume = entity->m_defaultVolum;
  921. }
  922. struct tm* ptm = NULL;
  923. time_t t = time(NULL);
  924. ptm = localtime(&t);
  925. TCHAR strNow[TIME_LEN] = {0};
  926. sprintf(strNow, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
  927. if (strcmp(strNow, config.strVideoRunTime_S) < 0 || strcmp(strNow, config.strVideoRunTime_E) >= 0){
  928. Sleep(10000);
  929. continue;
  930. }
  931. if (-1 == entity->m_pMediaPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config)){
  932. Sleep(30*DEFAULT_SLEEP_TIME);
  933. }
  934. Sleep(800);
  935. }
  936. for (int i = 0; i < uCount && i < MAX_LOCAL_MEDIAS && entity->GetPlayFlag(); i++)
  937. {
  938. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ResourceList[%d] address is 0x%0x", i, ResourceList[i]);
  939. int64_t playThreadId = 0;
  940. rvcResourceParse_t item = ResourceList[i];
  941. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin play extend %c:%s, %s", item.type, item.strResourcePath, item.strvideoNames);
  942. if ('V' == item.type)
  943. {//video
  944. CMediaPlayConfig config = {0};
  945. config.bFullScreen = IS_DEBUG ? false : item.fullScreen;
  946. config.bPrimMonitor = IS_DEBUG ? true : item.primMonitor;
  947. config.bSimpleMode = item.simpleMode;
  948. config.eMode = LOCALVIDEO;
  949. config.nFileCnt = 1;
  950. config.nPlayCnt = 1;
  951. config.nPlayInterval = item.playInterval;
  952. // add by ly@2018/07/30
  953. //config.nVolume = IS_DEBUG ? 0 : entity->m_defaultVolum;
  954. if (!entity->GetLocalVideoVolume(0, config.nVolume)){
  955. config.nVolume = entity->m_defaultVolum;
  956. }
  957. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("config.nVolume=%d while play local video.", config.nVolume);
  958. config.nWndX = entity->m_mediaParam.nWndX;
  959. config.nWndY = entity->m_mediaParam.nWndY;
  960. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  961. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  962. strncpy(config.strRootPath, item.strResourcePath, strlen(item.strResourcePath));
  963. strncpy(config.strFileNames[0], item.strvideoNames, strlen(item.strvideoNames));
  964. strncpy(config.strVideoRunTime_S, "09:00:00", sizeof(config.strVideoRunTime_S));
  965. strncpy(config.strVideoRunTime_E, "17:30:00", sizeof(config.strVideoRunTime_E));
  966. int iPlayRet = entity->m_pMediaPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
  967. if (-2 == iPlayRet){
  968. Sleep(DEFAULT_SLEEP_TIME);
  969. continue;
  970. }
  971. if (-3 == iPlayRet) {
  972. Sleep(DEFAULT_SLEEP_TIME/6);
  973. }
  974. Sleep(800);
  975. }
  976. else if ('P' == item.type)
  977. {//play Image
  978. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin new Image play, entity->m_mediaParam.nCfgInx = %d.", entity->m_mediaParam.nCfgInx);
  979. CPicPlayConfig config = {0};
  980. config.bFullScreen = IS_DEBUG ? false : item.fullScreen;
  981. config.bPrimMonitor = IS_DEBUG ? true : item.primMonitor;
  982. config.nFileCnt = 1;
  983. config.nPlayCnt = 1;
  984. config.nPlayInterval = item.playInterval;
  985. config.nWndX = entity->m_mediaParam.nWndX;
  986. config.nWndY = entity->m_mediaParam.nWndY;
  987. config.nWndWidth = entity->m_mediaParam.nWndWidth;
  988. config.nWndHeight = entity->m_mediaParam.nWndHeight;
  989. strncpy(config.strRootPath, item.strResourcePath, strlen(item.strResourcePath));
  990. strncpy(config.strFileNames[0], item.strvideoNames, strlen(item.strvideoNames));
  991. if (entity->m_pPicturePlayer[entity->m_mediaParam.nCfgInx]->checkIsStop()){
  992. entity->m_pPicturePlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
  993. if (!entity->m_pPicturePlayer[entity->m_mediaParam.nCfgInx]->checkIsPlay(&playThreadId)) {
  994. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Create play Image Media Thread Failed!");
  995. iRet = -1;
  996. return (void*)& iRet;
  997. }
  998. else {
  999. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Image Media Player Thread id is %u.", playThreadId);
  1000. }
  1001. if (0 == pthread_join(playThreadId, NULL)) {
  1002. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pthread join thread id %u success.", playThreadId);
  1003. iRet = 0;
  1004. }
  1005. else {
  1006. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pthread join thread id %u failed for %s.", playThreadId, strerror(errno));
  1007. iRet = -1;
  1008. }
  1009. }
  1010. Sleep(100);
  1011. }
  1012. }
  1013. unsigned int uend_time = y2k_time_now();
  1014. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("uend_time - ustart_time = %u.", uend_time - ustart_time);
  1015. if (uend_time - ustart_time < RVC_MIN_LOCALPLAYER_TIME) {
  1016. Sleep(30*DEFAULT_SLEEP_TIME);
  1017. }
  1018. }
  1019. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Leave Media Play Function.");
  1020. entity->m_uMediaPlayThreadId = 0;
  1021. return (void*)&iRet;
  1022. }
  1023. #endif // RVC_OS_WIN
  1024. void* StartNoticePlayThreadFunc(void* param)
  1025. {
  1026. int iRet = -1;
  1027. CLocalMediaPlayEntity* entity = (CLocalMediaPlayEntity*)param;
  1028. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter NoticePlayThreadFunc");
  1029. const char* pVideoName = entity->m_lastPlayVideo.c_str();
  1030. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin Start Notice Play, and Video Notice Info is %s.", pVideoName);
  1031. Clibmediaplayer* player = entity->m_pMediaPlayer[entity->m_mediaParam.nCfgInx];
  1032. player->PlayVideoNotice(entity->m_mediaParam.nWndX, entity->m_mediaParam.nWndY, entity->m_mediaParam.nWndWidth, entity->m_mediaParam.nWndHeight, pVideoName);
  1033. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to Start Notice Play, and Video Notice Info is %s.", pVideoName);
  1034. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Leave NoticePlayThreadFunc");
  1035. entity->m_uNoticePlayThreadId = 0;
  1036. iRet = 0;
  1037. return (void*)& iRet;
  1038. }
  1039. void CLocalMediaPlayEntity::StartVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
  1040. {
  1041. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0)
  1042. {
  1043. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while StartVideo!");
  1044. return;
  1045. }
  1046. m_mediaParam.nCfgInx = nCfgInx;
  1047. m_mediaParam.nWndX = nWndX;
  1048. m_mediaParam.nWndY = nWndY;
  1049. m_mediaParam.nWndWidth = nWndWidth;
  1050. m_mediaParam.nWndHeight = nWndHeight;
  1051. #ifdef RVC_OS_WIN // RVC_OS_WIN
  1052. if (NULL != m_playThread)
  1053. {
  1054. WaitForSingleObject(m_playThread, 5000);
  1055. m_playThread = NULL;
  1056. }
  1057. if (NULL == m_playThread)
  1058. m_playThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)& MediaPlayThread, this, 0, NULL);
  1059. #else
  1060. m_badplayflag = true;
  1061. int err = pthread_create(&m_uMediaPlayThreadId, NULL, StartMediaPlayFunc, this);
  1062. if (0 == err) {
  1063. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create media play thread[%u] success.", m_uMediaPlayThreadId);
  1064. }
  1065. else {
  1066. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create media play thread failed.");
  1067. }
  1068. #endif
  1069. }
  1070. void CLocalMediaPlayEntity::StartAudio(const char *pAudioNames)
  1071. {
  1072. #ifdef RVC_OS_WIN
  1073. static HANDLE audioPlayThread = NULL;
  1074. if (audioPlayThread)//�ر����ڲ��ŵ���Ƶ
  1075. {
  1076. DWORD exitCode = 0;
  1077. if (WAIT_TIMEOUT == WaitForSingleObject(audioPlayThread, 50))
  1078. {
  1079. TerminateThread(audioPlayThread, exitCode);
  1080. m_pAudioPlayer->Close();
  1081. }
  1082. audioPlayThread = NULL;
  1083. }
  1084. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin StartAudio, and Audio Info is %s.", pAudioNames);
  1085. m_pAudioPlayer->PlayLocalAudio(pAudioNames);
  1086. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StartAudio, and Audio Info is %s.", pAudioNames);
  1087. auto audioRet = GetLocalAudioVolume();
  1088. m_pAudioPlayer->SetVolume(audioRet.second);
  1089. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to set audio volume %d!", audioRet.second);
  1090. m_lastPlayAudio = pAudioNames;
  1091. audioPlayThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)& CheckAudioThread, this, 0, NULL);
  1092. #else
  1093. if (m_pMediaAudioPlayer->checkIsPlay()) {
  1094. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("current is playing, close it.");
  1095. if (0 != m_uMediaPlayThreadId){
  1096. m_pMediaAudioPlayer->Close();
  1097. m_uMediaPlayThreadId = 0;
  1098. Sleep(500);
  1099. }
  1100. }
  1101. m_lastPlayAudio = pAudioNames;
  1102. int err = pthread_create(&m_uMediaPlayThreadId, NULL, StartAudioPlayingThreadFunc, this);
  1103. if (0 == err) {
  1104. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create audio play thread[%u] success.", m_uMediaPlayThreadId);
  1105. }
  1106. else {
  1107. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create audio play thread failed.");
  1108. }
  1109. m_buserstopaudio = false;
  1110. auto audioRet = GetLocalAudioVolume();
  1111. m_pMediaAudioPlayer->SetVolume(audioRet.second);
  1112. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to set audio volume %d!", audioRet.second);
  1113. #endif // RVC_OS_WIN
  1114. }
  1115. void CLocalMediaPlayEntity::StartImage(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
  1116. {
  1117. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0)
  1118. {
  1119. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while StartImage!");
  1120. return;
  1121. }
  1122. #ifdef RVC_OS_WIN
  1123. m_pImagePlayer[nCfgInx]->Play(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
  1124. #else
  1125. m_pPicturePlayer[nCfgInx]->Play(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
  1126. #endif // RVC_OS_WIN
  1127. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StartImage!");
  1128. }
  1129. void CLocalMediaPlayEntity::StopVideo(int nCfgInx)
  1130. {
  1131. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0)
  1132. {
  1133. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while StopVideo!");
  1134. return;
  1135. }
  1136. #ifdef RVC_OS_WIN
  1137. m_pVideoPlayer[nCfgInx]->Close();
  1138. m_pImagePlayer[nCfgInx]->Close();
  1139. if (m_playThread)
  1140. {
  1141. TerminateThread(m_playThread, -1);
  1142. m_playThread = NULL;
  1143. }
  1144. #else
  1145. m_pMediaPlayer[nCfgInx]->Close();
  1146. m_pPicturePlayer[nCfgInx]->Close();
  1147. m_badplayflag = false;
  1148. #endif // RVC_OS_WIN
  1149. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StopVideo!");
  1150. }
  1151. void CLocalMediaPlayEntity::StopAudio()
  1152. {
  1153. #ifdef RVC_OS_WIN
  1154. m_pAudioPlayer->Close();
  1155. #else
  1156. m_pMediaAudioPlayer->Close();
  1157. m_buserstopaudio = true;
  1158. #endif
  1159. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StopAudio!");
  1160. }
  1161. void CLocalMediaPlayEntity::StopImage(int nCfgInx)
  1162. {
  1163. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0)
  1164. {
  1165. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while StopImage!");
  1166. return;
  1167. }
  1168. #ifdef RVC_OS_WIN
  1169. m_pImagePlayer[nCfgInx]->Close();
  1170. #else
  1171. m_pPicturePlayer[nCfgInx]->Close();
  1172. #endif // RVC_OS_WIN
  1173. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Succeed to StopImage!");
  1174. }
  1175. void CLocalMediaPlayEntity::StopAll()
  1176. {
  1177. StopAudio(); // �ر���Ƶ
  1178. for (int i = 0; i < MAX_PLAY_CHANNELS; ++i)
  1179. {
  1180. StopVideo(i); // �ر���Ƶ
  1181. StopImage(i); // �ر�ͼ��
  1182. }
  1183. }
  1184. bool CLocalMediaPlayEntity::GetLocalVideoVolume(int nCfgInx, int &nVolume)
  1185. {
  1186. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get local video volume req.");
  1187. CSmartPointer<IConfigInfo> spConfig;
  1188. ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_Run, spConfig);
  1189. if (Error == Error_Succeed)
  1190. {
  1191. Error = spConfig->ReadConfigValueInt("LocalVideo", "Volume", nVolume);
  1192. if (Error == Error_Succeed && nVolume >= 0 && nVolume <= 100)
  1193. {
  1194. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("succeed to get local video volume with nCfgInx:%d, nVolume:%d", nCfgInx, nVolume);
  1195. return true;
  1196. }
  1197. }
  1198. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail to get local video volume!");
  1199. return false;
  1200. }
  1201. std::pair<bool, int> CLocalMediaPlayEntity::GetLocalAudioVolume()
  1202. {
  1203. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get local audio volume req.");
  1204. CSmartPointer<IConfigInfo> spConfig;
  1205. int nVolume = 0;
  1206. ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_Run, spConfig);
  1207. if (Error == Error_Succeed)
  1208. {
  1209. Error = spConfig->ReadConfigValueInt("LocalAudio", "Volume", nVolume);
  1210. //if (nVolume == 0)
  1211. //{
  1212. // nVolume = 50;
  1213. // spConfig->WriteConfigValueInt("LocalAudio", "Volume", nVolume);
  1214. // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("read nVolume 0, set default 50");
  1215. //}
  1216. if (Error == Error_Succeed && nVolume >= 0 && nVolume <= 100)
  1217. {
  1218. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("succeed to get local audio volume with nVolume:%d", nVolume);
  1219. return std::make_pair(true, nVolume);
  1220. }
  1221. }
  1222. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail to get local audio volume!");
  1223. return std::make_pair(false, nVolume);
  1224. }
  1225. bool CLocalMediaPlayEntity::SetLocalAudioVolume(int nVolume)
  1226. {
  1227. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set local video audio req.");
  1228. if (nVolume < 0 || nVolume > 100)
  1229. {
  1230. return false;
  1231. }
  1232. CSmartPointer<IConfigInfo> spConfig;
  1233. ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_Run, spConfig);
  1234. if (Error == Error_Succeed)
  1235. {
  1236. Error = spConfig->WriteConfigValueInt("LocalAudio", "Volume", nVolume);
  1237. if (Error == Error_Succeed)
  1238. {
  1239. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("succeed to set local audio volume with nVolume:%d!", nVolume);
  1240. #ifdef RVC_OS_WIN
  1241. m_pAudioPlayer->SetVolume(nVolume);
  1242. #else
  1243. m_pMediaAudioPlayer->SetVolume(nVolume);
  1244. #endif // RVC_OS_WIN
  1245. return true;
  1246. }
  1247. }
  1248. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail to set local video volume!");
  1249. return false;
  1250. }
  1251. bool CLocalMediaPlayEntity::SetLocalVideoVolume(int nCfgInx, int nVolume)
  1252. {
  1253. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set local video volume req.");
  1254. if (nVolume < 0 || nVolume > 100)
  1255. {
  1256. return false;
  1257. }
  1258. CSmartPointer<IConfigInfo> spConfig;
  1259. ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_Run, spConfig);
  1260. if (Error == Error_Succeed)
  1261. {
  1262. Error = spConfig->WriteConfigValueInt("LocalVideo", "Volume", nVolume);
  1263. if (Error == Error_Succeed)
  1264. {
  1265. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("succeed to set local video volume with nCfgInx:%d, nVolume:%d!", nCfgInx, nVolume);
  1266. for (int i = 0; i < MAX_PLAY_CHANNELS; ++i)
  1267. {
  1268. #ifdef RVC_OS_WIN
  1269. m_pVideoPlayer[i]->SetVolume(nVolume);
  1270. #else
  1271. m_pMediaPlayer[i]->SetVolume(nVolume);
  1272. #endif
  1273. }
  1274. return true;
  1275. }
  1276. }
  1277. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail to set local video volume!");
  1278. return false;
  1279. }
  1280. bool CLocalMediaPlayEntity::IsRunConfigExist()
  1281. {
  1282. CSimpleStringA strPath;
  1283. ErrorCodeEnum eErr;
  1284. if ((eErr = GetFunction()->GetPath("RunInfo", strPath)) != Error_Succeed)
  1285. {
  1286. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get runinfo path failed(%d)", eErr);
  1287. return false;
  1288. }
  1289. #ifdef RVC_OS_WIN
  1290. CSimpleStringA strRuninfoFile;
  1291. strRuninfoFile = CSimpleStringA::Format("%s\\runcfg\\%s.ini", (LPCTSTR)strPath, GetEntityName());
  1292. WIN32_FIND_DATA findData;
  1293. if (FindFirstFileA((LPCTSTR)strRuninfoFile, &findData) != INVALID_HANDLE_VALUE) return true;
  1294. return false;
  1295. #else
  1296. CSimpleStringA strRuninfoFile;
  1297. strRuninfoFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "%s.ini", (LPCTSTR)strPath, GetEntityName());
  1298. if (ExistsFileA(strRuninfoFile)) {
  1299. return true;
  1300. }
  1301. else{
  1302. return false;
  1303. }
  1304. #endif // RVC_OS_WIN
  1305. }
  1306. void CLocalMediaPlayEntity::OnSelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext)
  1307. {
  1308. if (Test_ShakeHand == eTestType)
  1309. {
  1310. pTransactionContext->SendAnswer(Error_Succeed);
  1311. }
  1312. }
  1313. void CLocalMediaPlayEntity::CStringSplit(char *str, char **result, const char *del)
  1314. {
  1315. char* ptr = NULL;
  1316. char* p = strtok_r(str, del, &ptr);
  1317. while (p != NULL)
  1318. {
  1319. *result++ = p;
  1320. p = strtok_r(NULL, del, &ptr);
  1321. }
  1322. }
  1323. ErrorCodeEnum CLocalMediaPlayEntity::StartNotice(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoName)
  1324. {
  1325. ErrorCodeEnum Error = Error_Succeed;
  1326. if (eStand2sType == m_eDeviceType || eDesk2SType == m_eDeviceType || eMobilePadType == m_eDeviceType || ePadtype == m_eDeviceType) {
  1327. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0 || NULL == pVideoName){
  1328. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid param CfgInx or video name while StartNotice!");
  1329. return Error_Param;
  1330. }
  1331. if (m_pMediaAudioPlayer->checkIsPlay()) {
  1332. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio current is playing, close it.");
  1333. if (0 != m_uMediaPlayThreadId) {
  1334. m_pMediaAudioPlayer->Close();
  1335. m_uMediaPlayThreadId = 0;
  1336. Sleep(500);
  1337. }
  1338. }
  1339. if (m_pMediaPlayer[nCfgInx]->checkIsPlay()) {
  1340. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video current is playing, close it.");
  1341. if (0 != m_uNoticePlayThreadId) {
  1342. m_pMediaPlayer[nCfgInx]->Close();
  1343. m_uNoticePlayThreadId = 0;
  1344. Sleep(500);
  1345. }
  1346. }
  1347. m_mediaParam.nCfgInx = nCfgInx;
  1348. m_mediaParam.nWndX = 1280;
  1349. m_mediaParam.nWndY = 0;
  1350. m_mediaParam.nWndWidth = nWndWidth;
  1351. m_mediaParam.nWndHeight = nWndHeight;
  1352. CSimpleStringA strPath = DEFAULT_RESOURSE_PATH;
  1353. if (!ExistsDir(strPath.GetData())) {
  1354. strPath = DEFAULT_RESOURSE_PATH_C;
  1355. }
  1356. CSimpleStringA VideoPath = strPath + SPLIT_SLASH_STR;
  1357. CSimpleStringA strNoticeFileName = VideoPath + CSimpleStringA(pVideoName);
  1358. BOOL bRet = ExistsFile(strNoticeFileName.GetData());
  1359. if (bRet) {
  1360. int iVolume = 60;
  1361. GetLocalVideoVolume(nCfgInx, iVolume);
  1362. m_pMediaPlayer[nCfgInx]->SetVolume(iVolume);
  1363. m_lastPlayVideo = strNoticeFileName.GetData();
  1364. int err = pthread_create(&m_uNoticePlayThreadId, NULL, StartNoticePlayThreadFunc, this);
  1365. if (0 == err) {
  1366. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create notice play thread[%u] success.", m_uNoticePlayThreadId);
  1367. char strinfo[MAX_PATH] = { 0 };
  1368. snprintf(strinfo, MAX_PATH, "start play video notice %s", strNoticeFileName.GetData());
  1369. LogWarn(Severity_Low, Error_Debug, LOG_EVT_START_NOTICE_PLAY, strinfo);
  1370. }
  1371. else {
  1372. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create notice play thread failed.");
  1373. }
  1374. }
  1375. else {
  1376. Error = Error_InvalidState;
  1377. char strmsg[MAX_PATH] = { 0 };
  1378. snprintf(strmsg, MAX_PATH, "play notice failed for %s not exist!", strNoticeFileName.GetData());
  1379. LogWarn(Severity_Low, Error_Debug, LOG_EVT_NOTICE_FILE_NOT_EXIST, strmsg);
  1380. }
  1381. }
  1382. return Error;
  1383. }
  1384. ErrorCodeEnum CLocalMediaPlayEntity::StopNotice(int nCfgInx)
  1385. {
  1386. ErrorCodeEnum ErrorCode = Error_Succeed;
  1387. if (eStand2sType == m_eDeviceType || eDesk2SType == m_eDeviceType || eMobilePadType == m_eDeviceType || ePadtype == m_eDeviceType) {
  1388. if (nCfgInx >= MAX_PLAY_CHANNELS || nCfgInx < 0) {
  1389. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CfgInx while StopNotice!");
  1390. return Error_Param;
  1391. }
  1392. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_pPlayer = 0x%08x while play!", m_pMediaPlayer[nCfgInx]);
  1393. m_pMediaPlayer[nCfgInx]->Close();
  1394. if (m_uNoticePlayThreadId > 0){
  1395. if (0 == pthread_join(m_uNoticePlayThreadId, NULL)) {
  1396. if (m_lastPlayVideo.length() > 0) {
  1397. char strmsg[MAX_PATH] = { 0 };
  1398. snprintf(strmsg, MAX_PATH, "%s%s", "success to stop play notice ", m_lastPlayVideo.c_str());
  1399. LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOP_NOTICE_PLAY, strmsg);
  1400. }
  1401. }
  1402. m_uNoticePlayThreadId = 0;
  1403. }
  1404. }
  1405. return ErrorCode;
  1406. }
  1407. ErrorCodeEnum CLocalMediaPlayEntity::StopPlayAllMedias()
  1408. {
  1409. ErrorCodeEnum ErrorCode = Error_Succeed;
  1410. StopAll();
  1411. return ErrorCode;
  1412. }
  1413. DeviceTypeEnum CLocalMediaPlayEntity::RvcGetDeviceType()
  1414. {
  1415. DeviceTypeEnum eType = eStand2sType;
  1416. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  1417. CSystemStaticInfo stStaticinfo;
  1418. spFunction->GetSystemStaticInfo(stStaticinfo);
  1419. if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
  1420. eType = eStand1SPlusType;
  1421. }
  1422. else if (stricmp(stStaticinfo.strMachineType, "RVC.PAD") == 0) {
  1423. if (stricmp(stStaticinfo.strSite, "CMB.FLB") == 0) {
  1424. eType = eMobilePadType;
  1425. }
  1426. else {
  1427. eType = ePadtype;
  1428. }
  1429. }
  1430. else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk2S") == 0) {
  1431. eType = eDesk2SType;
  1432. }
  1433. else if (stricmp(stStaticinfo.strMachineType, "RPM.Stand1S") == 0) {
  1434. eType = eRpm1sType;
  1435. }
  1436. else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk1S") == 0) {
  1437. eType = eDesk1SType;
  1438. }
  1439. else {
  1440. eType = eStand2sType;
  1441. }
  1442. if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
  1443. LOG_TRACE("device type is %s.", Device_Type_Table[eType]);
  1444. }
  1445. return eType;
  1446. }
  1447. ErrorCodeEnum CLocalMediaPlayEntity::GetPcmRecordFlag()
  1448. {
  1449. CSmartPointer<IConfigInfo> spConfig;
  1450. SpIniMappingTable table;
  1451. ErrorCodeEnum Error = GetFunction()->OpenConfig(Config_CenterSetting, spConfig);
  1452. if (Error == Error_Succeed){
  1453. table.AddEntryBoolean("SalesRecorder", "IsRecordPCM", m_bRecordPCM, false);
  1454. Error = table.Load(spConfig);
  1455. }
  1456. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("record pcm flag is %s.", m_bRecordPCM ? "true" : "false");
  1457. return Error;
  1458. }
  1459. ErrorCodeEnum CLocalMediaPlayEntity::HandleRemoteRecord(const char* pszMessage)
  1460. {
  1461. ErrorCodeEnum Error = Error_Succeed;
  1462. m_bStartRecord = true;
  1463. memset(m_audiobuffer, 0, RVC_AUDIO_LEN);
  1464. m_leftlen = 0;
  1465. m_remote_audio_queue = new Clibaudioqueue(REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
  1466. m_iseriesnumber = 0;
  1467. m_bloged = false;
  1468. if (true == m_bRecordPCM){
  1469. char strSwiftName[MAX_PATH] = { 0 };
  1470. if (NULL != pszMessage) {
  1471. size_t ulen = strlen(pszMessage);
  1472. char* tmp = new char[ulen + 1];
  1473. memset(tmp, 0, ulen + 1);
  1474. memcpy(tmp, pszMessage, ulen);
  1475. char* result[16] = { 0 };
  1476. auto arr1 = CSimpleStringA2W(tmp).Split('@');
  1477. auto arr2 = CAutoArray<CSimpleStringA>(arr1.GetCount());
  1478. for (int i = 0; i < arr1.GetCount(); ++i) {
  1479. arr2[i] = CSimpleStringW2A(arr1[i]);
  1480. result[i] = const_cast<LPSTR>(arr2[i].GetData());
  1481. }
  1482. if (arr1.GetCount() > 4) {
  1483. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("record swift number is %s.", result[4]);
  1484. snprintf(strSwiftName, MAX_PATH, "%s", result[4]);
  1485. }
  1486. delete tmp;
  1487. tmp = NULL;
  1488. }
  1489. char strName[MAX_PATH] = { 0 };
  1490. CSimpleStringA strTempDir;
  1491. if (Error_Succeed == GetFunction()->GetPath("Temp", strTempDir)) {
  1492. snprintf(strName, MAX_PATH, "%s/remote_audio_notice_%s.pcm", strTempDir.GetData(), strSwiftName);
  1493. }
  1494. else {
  1495. snprintf(strName, MAX_PATH, "remote_audio_notice_%s.pcm", strSwiftName);
  1496. }
  1497. m_pFile = fopen(strName, "wb+");
  1498. if (NULL != m_pFile) {
  1499. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fopen %s success.", strName);
  1500. }
  1501. else {
  1502. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fopen %s failed.", strName);
  1503. }
  1504. }
  1505. return Error;
  1506. }
  1507. void CLocalMediaPlaySession::Handle_StartPlayVideo(SpReqAnsContext<PlayService_StartPlayVideo_Req, PlayService_StartPlayVideo_Ans>::Pointer ctx)
  1508. {
  1509. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start play Video, Index:%d, WndX:%d, WndY:%d, WndWidth:%d, WndWidth:%d", ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight);
  1510. CSimpleStringA UpdateState = "";
  1511. ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("UpdateState", UpdateState);
  1512. if (Error == Error_Succeed && "1" == UpdateState)
  1513. {
  1514. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("detect current is upgrade, do not play the media");
  1515. ctx->Answer(Error_Stoped);
  1516. m_pEntity->StopAll();
  1517. return;
  1518. }
  1519. m_pEntity->StartVideo(ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight);
  1520. ctx->Answer(Error_Succeed);
  1521. }
  1522. void CLocalMediaPlaySession::Handle_StartPlayAudio(SpReqAnsContext<PlayService_StartPlayAudio_Req, PlayService_StartPlayAudio_Ans>::Pointer ctx)
  1523. {
  1524. CSimpleStringA AudioNames = CSimpleStringW2A(ctx->Req.AudioNames);
  1525. CSimpleStringA UpdateState = "";
  1526. ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("UpdateState", UpdateState);
  1527. if (Error == Error_Succeed && "1" == UpdateState)
  1528. {
  1529. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("detect current is upgrade, do not play the media");
  1530. ctx->Answer(Error_Stoped);
  1531. m_pEntity->StopAll();
  1532. return;
  1533. }
  1534. m_pEntity->StartAudio(AudioNames.GetData());
  1535. ctx->Answer(Error_Succeed);
  1536. }
  1537. void CLocalMediaPlaySession::Handle_StartPlayImage(SpReqAnsContext<PlayService_StartPlayImage_Req, PlayService_StartPlayImage_Ans>::Pointer ctx)
  1538. {
  1539. m_pEntity->StartImage(ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight);
  1540. ctx->Answer(Error_Succeed);
  1541. }
  1542. void CLocalMediaPlaySession::Handle_StopPlayVideo(SpReqAnsContext<PlayService_StopPlayVideo_Req, PlayService_StopPlayVideo_Ans>::Pointer ctx)
  1543. {
  1544. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play Video, Index:%d", ctx->Req.CfgInx);
  1545. m_pEntity->StopVideo(ctx->Req.CfgInx);
  1546. ctx->Answer(Error_Succeed);
  1547. }
  1548. void CLocalMediaPlaySession::Handle_StopPlayAudio(SpReqAnsContext<PlayService_StopPlayAudio_Req, PlayService_StopPlayAudio_Ans>::Pointer ctx)
  1549. {
  1550. m_pEntity->StopAudio();
  1551. ctx->Answer(Error_Succeed);
  1552. }
  1553. void CLocalMediaPlaySession::Handle_StopPlayImage(SpReqAnsContext<PlayService_StopPlayImage_Req, PlayService_StopPlayImage_Ans>::Pointer ctx)
  1554. {
  1555. m_pEntity->StopImage(ctx->Req.CfgInx);
  1556. ctx->Answer(Error_Succeed);
  1557. }
  1558. void CLocalMediaPlaySession::OnClose(ErrorCodeEnum)
  1559. {
  1560. LOG_FUNCTION();
  1561. }
  1562. void CLocalMediaPlaySession::Handle_GetLocalVideoVolume( SpReqAnsContext<PlayService_GetLocalVideoVolume_Req, PlayService_GetLocalVideoVolume_Ans>::Pointer ctx )
  1563. {
  1564. int volume = 0;
  1565. if (m_pEntity->GetLocalVideoVolume(ctx->Req.CfgInx, volume))
  1566. {
  1567. ctx->Ans.Volume = volume;
  1568. ctx->Answer(Error_Succeed);
  1569. }
  1570. else
  1571. {
  1572. ctx->Answer(Error_Unexpect);
  1573. }
  1574. }
  1575. void CLocalMediaPlaySession::Handle_SetLocalVideoVolume( SpReqAnsContext<PlayService_SetLocalVideoVolume_Req, PlayService_SetLocalVideoVolume_Ans>::Pointer ctx )
  1576. {
  1577. if (m_pEntity->SetLocalVideoVolume(ctx->Req.CfgInx, ctx->Req.Volume))
  1578. {
  1579. ctx->Answer(Error_Succeed);
  1580. }
  1581. else
  1582. {
  1583. ctx->Answer(Error_Unexpect);
  1584. }
  1585. }
  1586. void CLocalMediaPlaySession::Handle_GetLocalAudioVolume(SpReqAnsContext<PlayService_GetLocalAudioVolume_Req, PlayService_GetLocalAudioVolume_Ans>::Pointer ctx)
  1587. {
  1588. auto audioRet = m_pEntity->GetLocalAudioVolume();
  1589. if (audioRet.first)
  1590. {
  1591. ctx->Ans.Volume = audioRet.second;
  1592. ctx->Answer(Error_Succeed);
  1593. }
  1594. else
  1595. {
  1596. ctx->Answer(Error_Unexpect);
  1597. }
  1598. }
  1599. void CLocalMediaPlaySession::Handle_SetLocalAudioVolume(SpReqAnsContext<PlayService_SetLocalAudioVolume_Req, PlayService_SetLocalAudioVolume_Ans>::Pointer ctx)
  1600. {
  1601. if (m_pEntity->SetLocalAudioVolume(ctx->Req.Volume))
  1602. {
  1603. ctx->Answer(Error_Succeed);
  1604. }
  1605. else
  1606. {
  1607. ctx->Answer(Error_Unexpect);
  1608. }
  1609. }
  1610. void CLocalMediaPlaySession::Handle_StartPlayNotice(SpReqAnsContext<PlayService_StartPlayNotice_Req, PlayService_StartPlayNotice_Ans>::Pointer ctx)
  1611. {
  1612. CSimpleStringA UpdateState = "";
  1613. ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("UpdateState", UpdateState);
  1614. if (Error == Error_Succeed && "1" == UpdateState) {
  1615. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("detect current is upgrade, do not play the media");
  1616. ctx->Answer(Error_Stoped);
  1617. m_pEntity->StopAll();
  1618. return;
  1619. }
  1620. CSimpleStringA VideoName = CSimpleStringW2A(ctx->Req.VideoName);
  1621. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start play notice, CfgInx = %d, WndX = %d, WndY = %d, WndWidth = %d, WndHeight = %d, and video name is %s.", ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight, VideoName.GetData());
  1622. Error = m_pEntity->StartNotice(ctx->Req.CfgInx, ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight, VideoName.GetData());
  1623. ctx->Answer(Error);
  1624. }
  1625. void CLocalMediaPlaySession::Handle_StopPlayNotice(SpReqAnsContext<PlayService_StopPlayNotice_Req, PlayService_StopPlayNotice_Ans>::Pointer ctx)
  1626. {
  1627. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play notice, Index:%d", ctx->Req.CfgInx);
  1628. ErrorCodeEnum Error = m_pEntity->StopNotice(ctx->Req.CfgInx);
  1629. ctx->Answer(Error);
  1630. }
  1631. void CLocalMediaPlaySession::Handle_StopPlayAllMedias(SpReqAnsContext<PlayService_StopPlayAllMedias_Req, PlayService_StopPlayAllMedias_Ans>::Pointer ctx)
  1632. {
  1633. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop play all medias");
  1634. ErrorCodeEnum Error = m_pEntity->StopPlayAllMedias();
  1635. ctx->Answer(Error);
  1636. }
  1637. SP_BEGIN_ENTITY_MAP()
  1638. SP_ENTITY(CLocalMediaPlayEntity)
  1639. SP_END_ENTITY_MAP()