Skip to content

Commit

Permalink
Merge pull request #14429 from ace20022/bd_mouse_select
Browse files Browse the repository at this point in the history
[bluray] Improve menu and still mode handling.
  • Loading branch information
ace20022 committed Sep 14, 2018
2 parents f249897 + 0d198d2 commit b5da899
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 35 deletions.
110 changes: 78 additions & 32 deletions xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.cpp
Expand Up @@ -279,12 +279,12 @@ bool CDVDInputStreamBluray::Open()
if (URIUtils::HasExtension(filename, ".mpls"))
{
m_navmode = false;
m_title = GetTitleFile(filename);
m_titleInfo = GetTitleFile(filename);
}
else if (mode == BD_PLAYBACK_MAIN_TITLE)
{
m_navmode = false;
m_title = GetTitleLongest();
m_titleInfo = GetTitleLongest();
}
else
{
Expand All @@ -299,7 +299,7 @@ bool CDVDInputStreamBluray::Open()
}

if(!m_navmode)
m_title = GetTitleLongest();
m_titleInfo = GetTitleLongest();
}

if (m_navmode)
Expand All @@ -319,15 +319,15 @@ bool CDVDInputStreamBluray::Open()
}
else
{
if(!m_title)
if(!m_titleInfo)
{
CLog::Log(LOGERROR, "CDVDInputStreamBluray::Open - failed to get title info");
return false;
}

if(!bd_select_playlist(m_bd, m_title->playlist))
if(!bd_select_playlist(m_bd, m_titleInfo->playlist))
{
CLog::Log(LOGERROR, "CDVDInputStreamBluray::Open - failed to select playlist %d", m_title->idx);
CLog::Log(LOGERROR, "CDVDInputStreamBluray::Open - failed to select playlist %d", m_titleInfo->idx);
return false;
}
m_clip = nullptr;
Expand Down Expand Up @@ -358,10 +358,10 @@ void CDVDInputStreamBluray::Close()

void CDVDInputStreamBluray::FreeTitleInfo()
{
if (m_title)
bd_free_title_info(m_title);
if (m_titleInfo)
bd_free_title_info(m_titleInfo);

m_title = nullptr;
m_titleInfo = nullptr;
m_clip = nullptr;
}

Expand Down Expand Up @@ -426,6 +426,17 @@ void CDVDInputStreamBluray::ProcessEvent() {
case BD_EVENT_STILL:
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_STILL %d",
m_event.param);

pid = m_event.param;

if (pid == 1)
{
m_hold = HOLD_PAUSE;
}
else
m_hold = HOLD_HELD; //HOLD_NONE

m_player->OnDiscNavResult(static_cast<void*>(&pid), BD_EVENT_STILL);
break;

/* playback position */
Expand All @@ -438,7 +449,7 @@ void CDVDInputStreamBluray::ProcessEvent() {
if (m_playlist <= MAX_PLAYLIST_ID)
{
FreeTitleInfo();
m_title = bd_get_playlist_info(m_bd, m_playlist, m_angle);
m_titleInfo = bd_get_playlist_info(m_bd, m_playlist, m_angle);
}
break;

Expand All @@ -447,25 +458,46 @@ void CDVDInputStreamBluray::ProcessEvent() {
m_event.param);
/* when a title ends, playlist WILL eventually change */
FreeTitleInfo();
if (m_event.param == BLURAY_TITLE_TOP_MENU)
{
m_title = nullptr;
m_menu = false;
}
break;

case BD_EVENT_TITLE:
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_TITLE %d",
m_event.param);
break;
{
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_TITLE %d", m_event.param);
const BLURAY_DISC_INFO* disc_info = bd_get_disc_info(m_bd);

if (m_event.param == BLURAY_TITLE_TOP_MENU)
{
m_title = disc_info->top_menu;
m_menu = true;
break;
}
else if (m_event.param == BLURAY_TITLE_FIRST_PLAY)
m_title = disc_info->first_play;
else if (m_event.param <= disc_info->num_titles)
m_title = disc_info->titles[m_event.param];
else
m_title = nullptr;

m_menu = false;
break;
}
case BD_EVENT_PLAYLIST:
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_PLAYLIST %d",
m_event.param);
m_playlist = m_event.param;
FreeTitleInfo();
m_title = bd_get_playlist_info(m_bd, m_playlist, m_angle);
m_titleInfo = bd_get_playlist_info(m_bd, m_playlist, m_angle);
break;

case BD_EVENT_PLAYITEM:
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_PLAYITEM %d", m_event.param);
if (m_title && m_event.param < m_title->clip_count)
m_clip = &m_title->clips[m_event.param];
if (m_titleInfo && m_event.param < m_titleInfo->clip_count)
m_clip = &m_titleInfo->clips[m_event.param];
break;

case BD_EVENT_CHAPTER:
Expand All @@ -476,7 +508,7 @@ void CDVDInputStreamBluray::ProcessEvent() {

case BD_EVENT_AUDIO_STREAM:
pid = -1;
if (m_title && m_clip && static_cast<uint32_t>(m_clip->audio_stream_count) > (m_event.param - 1))
if (m_titleInfo && m_clip && static_cast<uint32_t>(m_clip->audio_stream_count) > (m_event.param - 1))
pid = m_clip->audio_streams[m_event.param - 1].pid;
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_AUDIO_STREAM %d %d", m_event.param, pid);
m_player->OnDiscNavResult(static_cast<void*>(&pid), BD_EVENT_AUDIO_STREAM);
Expand All @@ -490,7 +522,7 @@ void CDVDInputStreamBluray::ProcessEvent() {

case BD_EVENT_PG_TEXTST_STREAM:
pid = -1;
if (m_title && m_clip && static_cast<uint32_t>(m_clip->pg_stream_count) > (m_event.param - 1))
if (m_titleInfo && m_clip && static_cast<uint32_t>(m_clip->pg_stream_count) > (m_event.param - 1))
pid = m_clip->pg_streams[m_event.param - 1].pid;
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - BD_EVENT_PG_TEXTST_STREAM %d, %d", m_event.param, pid);
m_player->OnDiscNavResult(static_cast<void*>(&pid), BD_EVENT_PG_TEXTST_STREAM);
Expand Down Expand Up @@ -556,8 +588,9 @@ int CDVDInputStreamBluray::Read(uint8_t* buf, int buf_size)
{
do {

if(m_hold == HOLD_HELD)
return 0;
if (m_hold == HOLD_PAUSE ||
m_hold == HOLD_HELD)
return 0;

if( m_hold == HOLD_ERROR
|| m_hold == HOLD_EXIT)
Expand Down Expand Up @@ -708,6 +741,10 @@ void CDVDInputStreamBluray::OverlayFlush(int64_t pts)
}

m_player->OnDiscNavResult(static_cast<void*>(group), BD_EVENT_MENU_OVERLAY);
if (group->m_overlays.empty())
m_menu = false;
else
m_menu = true;
group->Release();
#endif
}
Expand Down Expand Up @@ -843,8 +880,8 @@ void CDVDInputStreamBluray::OverlayCallbackARGB(const struct bd_argb_overlay_s *

int CDVDInputStreamBluray::GetTotalTime()
{
if(m_title)
return static_cast<int>(m_title->duration / 90);
if(m_titleInfo)
return static_cast<int>(m_titleInfo->duration / 90);
else
return 0;
}
Expand All @@ -867,23 +904,23 @@ bool CDVDInputStreamBluray::PosTime(int ms)

int CDVDInputStreamBluray::GetChapterCount()
{
if(m_title)
return static_cast<int>(m_title->chapter_count);
if(m_titleInfo)
return static_cast<int>(m_titleInfo->chapter_count);
else
return 0;
}

int CDVDInputStreamBluray::GetChapter()
{
if(m_title)
if(m_titleInfo)
return static_cast<int>(bd_get_current_chapter(m_bd) + 1);
else
return 0;
}

bool CDVDInputStreamBluray::SeekChapter(int ch)
{
if(m_title && bd_seek_chapter(m_bd, ch-1) < 0)
if(m_titleInfo && bd_seek_chapter(m_bd, ch-1) < 0)
return false;

while (bd_get_event(m_bd, &m_event))
Expand All @@ -897,8 +934,8 @@ int64_t CDVDInputStreamBluray::GetChapterPos(int ch)
if (ch == -1 || ch > GetChapterCount())
ch = GetChapter();

if (m_title && m_title->chapters)
return m_title->chapters[ch - 1].start / 90000;
if (m_titleInfo && m_titleInfo->chapters)
return m_titleInfo->chapters[ch - 1].start / 90000;
else
return 0;
}
Expand Down Expand Up @@ -959,7 +996,7 @@ static bool find_stream(int pid, BLURAY_STREAM_INFO *info, int count, std::strin

void CDVDInputStreamBluray::GetStreamInfo(int pid, std::string &language)
{
if(!m_title || !m_clip)
if(!m_titleInfo || !m_clip)
return;

if (pid == HDMV_PID_VIDEO)
Expand All @@ -984,7 +1021,7 @@ CDVDInputStream::ENextStream CDVDInputStreamBluray::NextStream()
while(bd_get_event(m_bd, &m_event))
ProcessEvent();

if(m_hold == HOLD_STILL)
if(m_hold == HOLD_STILL || m_hold == HOLD_PAUSE)
return NEXTSTREAM_RETRY;

m_hold = HOLD_DATA;
Expand Down Expand Up @@ -1014,6 +1051,10 @@ bool CDVDInputStreamBluray::MouseMove(const CPoint &point)
if (m_bd == nullptr || !m_navmode)
return false;

// Disable mouse selection for BD-J menus, since it's not implemented in libbluray as of version 1.0.2
if (m_title && m_title->bdj == 1)
return false;

if (bd_mouse_select(m_bd, -1, static_cast<uint16_t>(point.x), static_cast<uint16_t>(point.y)) < 0)
{
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray::MouseMove - mouse select failed");
Expand All @@ -1028,6 +1069,10 @@ bool CDVDInputStreamBluray::MouseClick(const CPoint &point)
if (m_bd == nullptr || !m_navmode)
return false;

// Disable mouse selection for BD-J menus, since it's not implemented in libbluray as of version 1.0.2
if (m_title && m_title->bdj == 1)
return false;

if (bd_mouse_select(m_bd, -1, static_cast<uint16_t>(point.x), static_cast<uint16_t>(point.y)) < 0)
{
CLog::Log(LOGDEBUG, "CDVDInputStreamBluray::MouseClick - mouse select failed");
Expand Down Expand Up @@ -1065,7 +1110,7 @@ bool CDVDInputStreamBluray::IsInMenu()
{
if(m_bd == nullptr || !m_navmode)
return false;
if(m_menu || !m_planes[BD_OVERLAY_IG].o.empty())
if(m_menu /*|| !m_planes[BD_OVERLAY_IG].o.empty()*/)
return true;
return false;
}
Expand All @@ -1075,7 +1120,8 @@ void CDVDInputStreamBluray::SkipStill()
if(m_bd == nullptr || !m_navmode)
return;

if(m_hold == HOLD_STILL)
if ( m_hold == HOLD_STILL
|| m_hold == HOLD_PAUSE)
{
m_hold = HOLD_HELD;
bd_read_skip_still(m_bd);
Expand Down
6 changes: 4 additions & 2 deletions xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamBluray.h
Expand Up @@ -131,7 +131,8 @@ class CDVDInputStreamBluray

IVideoPlayer* m_player = nullptr;
BLURAY* m_bd = nullptr;
BLURAY_TITLE_INFO* m_title = nullptr;
const BLURAY_TITLE* m_title = nullptr;
BLURAY_TITLE_INFO* m_titleInfo = nullptr;
uint32_t m_playlist = MAX_PLAYLIST_ID + 1;
BLURAY_CLIP_INFO* m_clip = nullptr;
uint32_t m_angle = 0;
Expand All @@ -156,7 +157,8 @@ class CDVDInputStreamBluray
HOLD_DATA,
HOLD_STILL,
HOLD_ERROR,
HOLD_EXIT
HOLD_EXIT,
HOLD_PAUSE
} m_hold = HOLD_NONE;
BD_EVENT m_event;
#ifdef HAVE_LIBBLURAY_BDJ
Expand Down
24 changes: 23 additions & 1 deletion xbmc/cores/VideoPlayer/VideoPlayer.cpp
Expand Up @@ -4013,9 +4013,12 @@ int CVideoPlayer::OnDiscNavResult(void* pData, int iMessage)
{
// else notify the player we have received a still frame

m_dvd.iDVDStillTime = *(int*)pData;
m_dvd.iDVDStillTime = *static_cast<int*>(pData);
m_dvd.iDVDStillStartTime = XbmcThreads::SystemClockMillis();

if (m_dvd.iDVDStillTime != 0)
m_dvd.iDVDStillTime *= 1000;

/* adjust for the output delay in the video queue */
unsigned int time = 0;
if (m_CurrentVideo.stream && m_dvd.iDVDStillTime > 0)
Expand All @@ -4031,6 +4034,25 @@ int CVideoPlayer::OnDiscNavResult(void* pData, int iMessage)
}
}
break;
case BD_EVENT_STILL:
{
bool on = static_cast<bool>(*static_cast<int*>(pData));
if (on && m_dvd.state != DVDSTATE_STILL)
{
m_dvd.state = DVDSTATE_STILL;
m_dvd.iDVDStillStartTime = XbmcThreads::SystemClockMillis();
m_dvd.iDVDStillTime = 0;
CLog::Log(LOGDEBUG, "CDVDPlayer::OnDVDNavResult - libbluray DVDSTATE_STILL start");
}
else if (!on && m_dvd.state == DVDSTATE_STILL)
{
m_dvd.state = DVDSTATE_NORMAL;
m_dvd.iDVDStillStartTime = 0;
m_dvd.iDVDStillTime = 0;
CLog::Log(LOGDEBUG, "CDVDPlayer::OnDVDNavResult - libbluray DVDSTATE_STILL end");
}
}
break;
case BD_EVENT_MENU_ERROR:
{
m_dvd.state = DVDSTATE_NORMAL;
Expand Down

0 comments on commit b5da899

Please sign in to comment.