123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #include "libpictureplayer.h"
- #include "CPicturePlayer.h"
- #include "SpBase.h"
- void __dbg(const char* fmt, ...)
- {
- Dbg(fmt);
- }
- class libpictureplayer_impl
- {
- private:
- CPicPlayConfig m_stPlayConfig;
- CPicHostApi* m_pHostApi;
- CPicturePlayer* m_Player;
- bool m_bIsPlay;
- public:
- libpictureplayer_impl(CPicHostApi* pHostApi) {
- m_bIsPlay = false;
- m_pHostApi = pHostApi;
- memset(&m_stPlayConfig, 0, sizeof(m_stPlayConfig));
- m_Player = new CPicturePlayer();
- if (NULL != m_Player) {
- pHostApi->PicDebug(" new PicturePlayer success!");
- }
- else {
- pHostApi->PicDebug(" new PicturePlayer failed!");
- }
- }
- ~libpictureplayer_impl()
- {
- m_pHostApi = NULL;
- delete m_Player;
- m_Player = NULL;
- m_bIsPlay = false;
- }
- bool isStop()
- {
- return !m_bIsPlay;
- }
- bool CheckIsPlay(void* pthreadid)
- {
- bool bret = false;
- int64_t iThreadId = m_Player->GetPicPlayingThreadId();
- if (0 != iThreadId)
- {
- bret = true;
- pthreadid = &iThreadId;
- }
- }
- bool StartPlayMedia(CPicPlayConfig& config)
- {
- if (m_bIsPlay)
- {
- return true;
- }
- memcpy(&m_stPlayConfig, &config, sizeof(CPicPlayConfig));
- rvc_picture_player_param_t tplayer_param;
- tplayer_param.icx = m_stPlayConfig.nWndX;
- tplayer_param.icy = m_stPlayConfig.nWndY;
- tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth;
- tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight;
- tplayer_param.stricon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
- tplayer_param.rvc_log = __dbg;
- 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.");
- }
- }
- return true;
- }
- bool StartPlay(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
- {
- m_stPlayConfig.nWndX = nWndX;
- m_stPlayConfig.nWndY = nWndY;
- m_stPlayConfig.nWndWidth = nWndWidth;
- m_stPlayConfig.nWndHeight = nWndHeight;
- int iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
- if (0 != iRet)
- {
- m_pHostApi->PicDebug("Load ImgConfiguration failed!");
- return false;
- }
- else
- {
- m_pHostApi->PicDebug("Load ImgConfiguration succeeded while play local image!");
- m_pHostApi->PicDebug("m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
- }
- rvc_picture_player_param_t tplayer_param;
- tplayer_param.icx = nWndX;
- tplayer_param.icy = nWndY;
- tplayer_param.uwindow_width = nWndWidth;
- tplayer_param.uwindow_height = nWndHeight;
- tplayer_param.stricon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
- tplayer_param.rvc_log = __dbg;
- 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.");
- }
- }
- return true;
- }
- bool StopPlay()
- {
- if (NULL != m_Player)
- {
- if (m_Player->GetPicPlayingFlag())
- {
- m_Player->StopPicPlay();
- m_bIsPlay = false;
- }
- }
- return true;
- }
- };
- Clibpictureplayer::Clibpictureplayer(CPicHostApi* pHostApi)
- {
- m_pImpl = new libpictureplayer_impl(pHostApi);
- }
- Clibpictureplayer::~Clibpictureplayer()
- {
- delete m_pImpl;
- m_pImpl = NULL;
- }
- void Clibpictureplayer::Play(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
- {
- m_pImpl->StartPlay(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
- }
- void Clibpictureplayer::PlayMedia(CPicPlayConfig& config)
- {
- m_pImpl->StartPlayMedia(config);
- }
- bool Clibpictureplayer::checkIsStop() {
- return m_pImpl->isStop();
- }
- bool Clibpictureplayer::checkIsPlay(void* pthreadid)
- {
- return m_pImpl->CheckIsPlay(pthreadid);
- }
- void Clibpictureplayer::Close()
- {
- m_pImpl->StopPlay();
- }
|