|
@@ -2,14 +2,19 @@
|
|
|
#include "CPicturePlayer.h"
|
|
|
#include <unistd.h>
|
|
|
#include <string.h>
|
|
|
+#include <pthread.h>
|
|
|
+
|
|
|
+
|
|
|
+void* PicturePlayingFunc(void* param);
|
|
|
|
|
|
class libpictureplayer_impl
|
|
|
{
|
|
|
-private:
|
|
|
+public:
|
|
|
CPicPlayConfig m_stPlayConfig;
|
|
|
CPicHostApi* m_pHostApi;
|
|
|
CPicturePlayer* m_Player;
|
|
|
bool m_bIsPlay;
|
|
|
+ pthread_t m_PlayThreadId;
|
|
|
|
|
|
public:
|
|
|
libpictureplayer_impl(CPicHostApi* pHostApi) {
|
|
@@ -18,19 +23,22 @@ public:
|
|
|
memset(&m_stPlayConfig, 0, sizeof(m_stPlayConfig));
|
|
|
m_Player = new CPicturePlayer(pHostApi, "./rvc_media_player_64px.bmp");
|
|
|
if (NULL != m_Player) {
|
|
|
- pHostApi->PicDebug(" new PicturePlayer success!");
|
|
|
+ pHostApi->PicDebug("new PicturePlayer success!");
|
|
|
}
|
|
|
else {
|
|
|
- pHostApi->PicDebug(" new PicturePlayer failed!");
|
|
|
+ pHostApi->PicDebug("new PicturePlayer failed!");
|
|
|
}
|
|
|
+ m_PlayThreadId = 0;
|
|
|
}
|
|
|
|
|
|
~libpictureplayer_impl()
|
|
|
{
|
|
|
+ printf("~libpictureplayer_impl()\n");
|
|
|
m_pHostApi = NULL;
|
|
|
delete m_Player;
|
|
|
m_Player = NULL;
|
|
|
m_bIsPlay = false;
|
|
|
+ m_PlayThreadId = 0;
|
|
|
}
|
|
|
|
|
|
bool isStop()
|
|
@@ -102,7 +110,9 @@ public:
|
|
|
}
|
|
|
}
|
|
|
pParam->nfile_cnt = uValidCount;
|
|
|
- m_pHostApi->PicDebug("pParam uFilesCount = %d", uValidCount);
|
|
|
+ if (NULL != m_pHostApi) {
|
|
|
+ m_pHostApi->PicDebug("pParam uFilesCount = %d", uValidCount);
|
|
|
+ }
|
|
|
if (uValidCount > 0) {
|
|
|
iRet = 0;
|
|
|
}
|
|
@@ -112,6 +122,7 @@ public:
|
|
|
|
|
|
bool StartPlay(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
|
|
|
{
|
|
|
+ bool bRet = false;
|
|
|
m_stPlayConfig.nWndX = nWndX;
|
|
|
m_stPlayConfig.nWndY = nWndY;
|
|
|
m_stPlayConfig.nWndWidth = nWndWidth;
|
|
@@ -120,7 +131,7 @@ public:
|
|
|
if (0 != iRet)
|
|
|
{
|
|
|
m_pHostApi->PicDebug("Load ImgConfiguration failed!");
|
|
|
- return false;
|
|
|
+ return bRet;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -128,27 +139,16 @@ public:
|
|
|
m_pHostApi->PicDebug("m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
|
|
|
}
|
|
|
|
|
|
- rvc_picture_player_param_t tplayer_param = {0};
|
|
|
- tplayer_param.icx = nWndX;
|
|
|
- tplayer_param.icy = nWndY;
|
|
|
- tplayer_param.uwindow_width = nWndWidth;
|
|
|
- tplayer_param.uwindow_height = nWndHeight;
|
|
|
-
|
|
|
- if (0 != GetPicturePlayingParams(&tplayer_param)){
|
|
|
- return false;
|
|
|
+ int err = pthread_create(&m_PlayThreadId, NULL, PicturePlayingFunc, this);
|
|
|
+ if (0 == err) {
|
|
|
+ m_pHostApi->PicDebug("create picture play thread[%lu] success.", m_PlayThreadId);
|
|
|
+ bRet = true;
|
|
|
}
|
|
|
-
|
|
|
- if (0 == m_Player->Init(&tplayer_param))
|
|
|
- {
|
|
|
- m_pHostApi->PicDebug("Init Picture Player Success.");
|
|
|
- if (m_Player->StartPicPlay())
|
|
|
- {
|
|
|
- m_bIsPlay = true;
|
|
|
- m_pHostApi->PicDebug("Start Picture Play Success.");
|
|
|
- }
|
|
|
+ else {
|
|
|
+ m_pHostApi->PicDebug("create picture play thread failed.");
|
|
|
}
|
|
|
|
|
|
- return true;
|
|
|
+ return bRet;
|
|
|
}
|
|
|
|
|
|
bool StopPlay()
|
|
@@ -209,4 +209,33 @@ bool Clibpictureplayer::checkIsPlay(void* pthreadid)
|
|
|
void Clibpictureplayer::Close()
|
|
|
{
|
|
|
m_pImpl->StopPlay();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void* PicturePlayingFunc(void* param)
|
|
|
+{
|
|
|
+ printf("enter PicturePlayingFunc \n");
|
|
|
+ libpictureplayer_impl* is = (libpictureplayer_impl*)param;
|
|
|
+
|
|
|
+ rvc_picture_player_param_t tplayer_param = { 0 };
|
|
|
+ tplayer_param.icx = is->m_stPlayConfig.nWndX;
|
|
|
+ tplayer_param.icy = is->m_stPlayConfig.nWndY;
|
|
|
+ tplayer_param.uwindow_width = is->m_stPlayConfig.nWndWidth;
|
|
|
+ tplayer_param.uwindow_height = is->m_stPlayConfig.nWndHeight;
|
|
|
+
|
|
|
+ if (0 == is->GetPicturePlayingParams(&tplayer_param)) {
|
|
|
+ if (0 == is->m_Player->Init(&tplayer_param))
|
|
|
+ {
|
|
|
+ is->m_pHostApi->PicDebug("Init Picture Player Success.");
|
|
|
+ if (is->m_Player->StartPicPlay())
|
|
|
+ {
|
|
|
+ is->m_bIsPlay = true;
|
|
|
+ is->m_pHostApi->PicDebug("Start Picture Play Success.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ is->m_pHostApi->PicDebug("Get Picture Playing Params failed!");
|
|
|
+ }
|
|
|
+ printf("leave PicturePlayingFunc \n");
|
|
|
}
|