Skip to content

Commit e07040d

Browse files
author
Mark Kendall
committed
Bluray: Improved chapter handling.
libbluray adds an extra chapter marker for the end of the title - so ignore this for our own purposes - and use the libbluray functionality for determining the current chapter. This aligns our presentation with the disc menu structure. I still intend to convert the chapter seeks to use the libbluray methods but this requires a little more work. N.B. Position information can go wrong with 'series/season' discs. libbluray presents us with a 'super' title that is an amalgamation of all of the episodes on a disc. Once you've navigated beyond the first actual title, however, all positioning is relative to the current title.
1 parent 74ebeae commit e07040d

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

mythtv/libs/libmythtv/bdringbuffer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ long long BDRingBuffer::GetReadPosition(void) const
432432
uint32_t BDRingBuffer::GetNumChapters(void)
433433
{
434434
if (m_currentTitleInfo)
435-
return m_currentTitleInfo->chapter_count;
435+
return m_currentTitleInfo->chapter_count - 1;
436+
return 0;
437+
}
438+
439+
uint32_t BDRingBuffer::GetCurrentChapter(void)
440+
{
441+
if (bdnav)
442+
return bd_get_current_chapter(bdnav);
436443
return 0;
437444
}
438445

@@ -516,7 +523,7 @@ bool BDRingBuffer::UpdateTitleInfo(uint32_t index)
516523
m_currentTitleAngleCount = m_currentTitleInfo->angle_count;
517524
m_currentAngle = 0;
518525
m_titlesize = bd_get_title_size(bdnav);
519-
uint32_t chapter_count = m_currentTitleInfo->chapter_count;
526+
uint32_t chapter_count = GetNumChapters();
520527
VERBOSE(VB_IMPORTANT, LOC + QString("Selected title/playlist: index %1. "
521528
"Duration: %2 (%3 mins) "
522529
"Number of Chapters: %4 Number of Angles: %5 "

mythtv/libs/libmythtv/bdringbuffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class MPUBLIC BDRingBuffer : public RingBuffer
7575
virtual long long GetReadPosition(void) const; // RingBuffer
7676
uint64_t GetTotalReadPosition(void);
7777
uint32_t GetNumChapters(void);
78+
uint32_t GetCurrentChapter(void);
7879
uint64_t GetNumAngles(void) { return m_currentTitleAngleCount; }
7980
uint64_t GetChapterStartTime(uint32_t chapter);
8081
uint64_t GetChapterStartFrame(uint32_t chapter);

mythtv/libs/libmythtv/mythbdplayer.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,16 @@ void MythBDPlayer::EventStart(void)
9595

9696
int MythBDPlayer::GetNumChapters(void)
9797
{
98-
int num = 0;
9998
if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen())
100-
num = player_ctx->buffer->BD()->GetNumChapters();
101-
if (num > 1)
102-
return num;
103-
return 0;
99+
return player_ctx->buffer->BD()->GetNumChapters();
100+
return -1;
104101
}
105102

106103
int MythBDPlayer::GetCurrentChapter(void)
107104
{
108-
uint total = GetNumChapters();
109-
if (!total)
110-
return 0;
111-
112-
for (int i = (total - 1); i > -1 ; i--)
113-
{
114-
uint64_t frame = player_ctx->buffer->BD()->GetChapterStartFrame(i);
115-
if (framesPlayed >= frame)
116-
{
117-
VERBOSE(VB_PLAYBACK, LOC +
118-
QString("GetCurrentChapter(selected chapter %1 framenum %2)")
119-
.arg(i + 1).arg(frame));
120-
return i + 1;
121-
}
122-
}
123-
return 0;
105+
if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen())
106+
return player_ctx->buffer->BD()->GetCurrentChapter() + 1;
107+
return -1;
124108
}
125109

126110
int64_t MythBDPlayer::GetChapter(int chapter)

0 commit comments

Comments
 (0)