|
@@ -133,6 +133,7 @@ static int player_deinit(player_stat_t *is)
|
|
|
is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d is->img_convert_ctx[%d] = 0x%0x", __FUNCTION__, __LINE__, index, is->img_convert_ctx[index]);
|
|
|
if (NULL != is->img_convert_ctx[index]) {
|
|
|
sws_freeContext(is->img_convert_ctx[index]);
|
|
|
+ is->img_convert_ctx[index] = NULL;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -145,6 +146,7 @@ static int player_deinit(player_stat_t *is)
|
|
|
}
|
|
|
is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "av_free player_stat_t.");
|
|
|
av_free(is);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -191,18 +193,37 @@ CMediaPlayer::CMediaPlayer(CMediaHostApi* pHostApi)
|
|
|
else {
|
|
|
m_hostapi->Debug(MEDIA_LOG_DEBUG, "new CMediaPlayer failed!");
|
|
|
}
|
|
|
+
|
|
|
+ Uint32 uRet = SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
|
|
|
+
|
|
|
+ if (0 == uRet){
|
|
|
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
|
|
|
+ {
|
|
|
+ m_hostapi->Debug(MEDIA_LOG_ERROR, "Could not initialize SDL - %s", SDL_GetError());
|
|
|
+ m_hostapi->Debug(MEDIA_LOG_ERROR, "(Did you set the DISPLAY variable?)");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ uRet = SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
|
|
|
+ m_hostapi->Debug(MEDIA_LOG_DEBUG, "initialize SDL success, and init ret = %d.", uRet);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
CMediaPlayer::~CMediaPlayer()
|
|
|
{
|
|
|
- if (NULL != m_player_stat){
|
|
|
+ if (NULL != m_player_stat) {
|
|
|
player_deinit(m_player_stat);
|
|
|
m_player_stat = NULL;
|
|
|
}
|
|
|
|
|
|
- if(NULL != m_piconpath){
|
|
|
+ if (NULL != m_piconpath) {
|
|
|
av_free(m_piconpath);
|
|
|
}
|
|
|
+
|
|
|
+ Uint32 uRet = SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
|
|
|
+ if (0 != uRet) {
|
|
|
+ SDL_Quit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -214,6 +235,20 @@ static int audio_volume_callback(int* audiovolume, void* userdata)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int audio_play_finished_callback(void* userdata)
|
|
|
+{
|
|
|
+ CMediaPlayer* player = (CMediaPlayer*)userdata;
|
|
|
+ player->SetFinishedFlag();
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+bool CMediaPlayer::SetFinishedFlag()
|
|
|
+{
|
|
|
+ m_player_stat->abort_request = 1;
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
uint8_t CMediaPlayer::GetVolume()
|
|
|
{
|
|
|
return m_uvolume;
|
|
@@ -237,14 +272,18 @@ int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
+ m_player_stat->bread_finished = false;
|
|
|
m_player_stat->rvc_hostapi = m_hostapi;
|
|
|
m_player_stat->prvc_cb = pMedia_Player->cb;
|
|
|
m_player_stat->eMType = pMedia_Player->eType;
|
|
|
m_player_stat->eWindType = pMedia_Player->eWindType;
|
|
|
m_player_stat->bvice_monitor = pMedia_Player->bvicemonitor;
|
|
|
- m_player_stat->iDisplayCx = pMedia_Player->udisplaycx;
|
|
|
- m_player_stat->iDisplayCy = pMedia_Player->udisplaycy;
|
|
|
+ m_player_stat->iDisplayCx = pMedia_Player->idisplaycx;
|
|
|
+ m_player_stat->iDisplayCy = pMedia_Player->idisplaycy;
|
|
|
+ m_player_stat->iDisplayWidth = pMedia_Player->idisplaywidth;
|
|
|
+ m_player_stat->iDisplayHeight = pMedia_Player->idisplayheight;
|
|
|
m_player_stat->on_audio_volume = &audio_volume_callback;
|
|
|
+ m_player_stat->on_audio_play_finished = &audio_play_finished_callback;
|
|
|
m_player_stat->user_data = this;
|
|
|
if (NULL != m_piconpath){
|
|
|
m_player_stat->piconpath = av_strdup(m_piconpath);
|
|
@@ -272,7 +311,7 @@ int CMediaPlayer::GetViceVideoDisplayInfo(int* icx, int* icy, int* iwidth, int*
|
|
|
int iRet = -1;
|
|
|
size_t uCount = SDL_GetNumVideoDisplays();
|
|
|
m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays Number is %d.", uCount);
|
|
|
- SDL_DisplayMode dispalymode[RVC_MAX_DISPLAYNUM] = {0};
|
|
|
+ SDL_DisplayMode dispalymode[RVC_MAX_DISPLAYNUM] = { 0 };
|
|
|
for (size_t i = 0; i < uCount && i < RVC_MAX_DISPLAYNUM; i++) {
|
|
|
SDL_GetDesktopDisplayMode(i, &dispalymode[i]);
|
|
|
m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} format = %d", i, dispalymode[i].format);
|
|
@@ -280,7 +319,7 @@ int CMediaPlayer::GetViceVideoDisplayInfo(int* icx, int* icy, int* iwidth, int*
|
|
|
m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} h = %d", i, dispalymode[i].h);
|
|
|
m_hostapi->Debug(MEDIA_LOG_DEBUG, "VideoDisplays{%d} refresh_rate = %d", i, dispalymode[i].refresh_rate);
|
|
|
}
|
|
|
- if (uCount > 1){
|
|
|
+ if (uCount > 1) {
|
|
|
*icx = dispalymode[0].w;
|
|
|
*icy = 0;
|
|
|
*iwidth = dispalymode[1].w;
|
|
@@ -345,24 +384,11 @@ int CMediaPlayer::Init(rvc_media_player_param_t* pMedia_Player)
|
|
|
|
|
|
m_player_stat->abort_request = 0;
|
|
|
|
|
|
- uint32_t usdl_flag = SDL_INIT_AUDIO | SDL_INIT_TIMER;
|
|
|
- if (eVideo_Type == m_player_stat->eMType){
|
|
|
- usdl_flag |= SDL_INIT_VIDEO;
|
|
|
- }
|
|
|
-
|
|
|
- if (SDL_Init(usdl_flag))
|
|
|
- {
|
|
|
- m_hostapi->Debug(MEDIA_LOG_DEBUG, "Could not initialize SDL - %s", SDL_GetError());
|
|
|
- m_hostapi->Debug(MEDIA_LOG_DEBUG, "(Did you set the DISPLAY variable?)");
|
|
|
- }
|
|
|
- else {
|
|
|
- iRet = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (eVideo_Type == m_player_stat->eMType && m_player_stat->bvice_monitor){
|
|
|
+ if (m_player_stat->bvice_monitor){
|
|
|
if (0 == GetViceVideoDisplayInfo(&m_player_stat->iDisplayCx, &m_player_stat->iDisplayCy, &m_player_stat->iDisplayWidth, &m_player_stat->iDisplayHeight)){
|
|
|
- m_hostapi->Debug(MEDIA_LOG_DEBUG, "display cx is %d, cy is %d, width is %d, height is %d.", m_player_stat->iDisplayCx, m_player_stat->iDisplayCy, m_player_stat->iDisplayWidth, m_player_stat->iDisplayHeight);
|
|
|
+ m_hostapi->Debug(MEDIA_LOG_DEBUG,"display cx is %d, cy is %d, width is %d, height is %d.", m_player_stat->iDisplayCx, m_player_stat->iDisplayCy, m_player_stat->iDisplayWidth, m_player_stat->iDisplayHeight);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
iRet = 0;
|
|
@@ -476,7 +502,7 @@ int CMediaPlayer::ExitMediaPlayingThread()
|
|
|
|
|
|
avformat_network_deinit();
|
|
|
|
|
|
- SDL_Quit();
|
|
|
+ //SDL_Quit();
|
|
|
|
|
|
iRet = 0;
|
|
|
|