Skip to content

Commit

Permalink
Fixed display of playback position for DVD stills.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard committed Jun 28, 2013
1 parent 23d6d74 commit 4be52bd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 25 deletions.
29 changes: 23 additions & 6 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
Expand Up @@ -459,20 +459,37 @@ long long MythDVDPlayer::CalcMaxFFTime(long long ff, bool setjump) const
return MythPlayer::CalcMaxFFTime(ff, setjump);
}

int64_t MythDVDPlayer::GetSecondsPlayed(bool)
int64_t MythDVDPlayer::GetSecondsPlayed(bool) const
{
if (!player_ctx->buffer->IsDVD())
return 0;

return (m_stillFrameLength > 0) ?
(m_stillFrameTimer.elapsed() / 1000) :
(player_ctx->buffer->DVD()->GetCurrentTime());
int64_t played = player_ctx->buffer->DVD()->GetCurrentTime();

if (m_stillFrameLength > 0)
{
if (m_stillFrameLength == 255)
played = -1;
else
played = m_stillFrameTimer.elapsed() / 1000;
}

return played;
}

int64_t MythDVDPlayer::GetTotalSeconds(void) const
int64_t MythDVDPlayer::GetTotalSeconds(bool /*honorCutList*/) const
{
return (m_stillFrameLength > 0) ? m_stillFrameLength: totalLength;
int64_t total = totalLength;

if (m_stillFrameLength > 0)
{
if (m_stillFrameLength == 255)
total = -1;
else
total = m_stillFrameLength;
}

return total;
}

void MythDVDPlayer::SeekForScreenGrab(uint64_t &number, uint64_t frameNum,
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.h
Expand Up @@ -20,8 +20,8 @@ class MythDVDPlayer : public MythPlayer

// Gets
virtual uint64_t GetBookmark(void);
virtual int64_t GetSecondsPlayed(bool honorCutList);
virtual int64_t GetTotalSeconds(void) const;
virtual int64_t GetSecondsPlayed(bool honorCutList) const;
virtual int64_t GetTotalSeconds(bool honorCutList) const;

// DVD public stuff
virtual bool GoToMenu(QString str);
Expand Down
42 changes: 27 additions & 15 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -4693,14 +4693,19 @@ int MythPlayer::GetSecondsBehind(void) const
return (int)((float)(written - played) / video_frame_rate);
}

int64_t MythPlayer::GetSecondsPlayed(bool honorCutList)
int64_t MythPlayer::GetSecondsPlayed(bool honorCutList) const
{
return TranslatePositionFrameToMs(framesPlayed, honorCutList) / 1000;
}

int64_t MythPlayer::GetTotalSeconds(void) const
int64_t MythPlayer::GetTotalSeconds(bool honorCutList) const
{
return totalDuration;
uint64_t pos = totalFrames;

if (IsWatchingInprogress())
pos = (uint64_t)-1;

return TranslatePositionFrameToMs(pos, honorCutList) / 1000;
}

// Returns the total frame count, as totalFrames for a completed
Expand Down Expand Up @@ -4751,7 +4756,6 @@ void MythPlayer::calcSliderPos(osdInfo &info, bool paddedFields)
info.values.insert("progbefore", 0);
info.values.insert("progafter", 0);

uint64_t total_frames = totalFrames;
int playbackLen = 0;
bool fixed_playbacklen = false;

Expand All @@ -4771,7 +4775,6 @@ void MythPlayer::calcSliderPos(osdInfo &info, bool paddedFields)
}
else if (IsWatchingInprogress())
{
total_frames = -1;
islive = true;
}
else
Expand Down Expand Up @@ -4805,18 +4808,24 @@ void MythPlayer::calcSliderPos(osdInfo &info, bool paddedFields)
for (int i = 0; i < 2 ; ++i)
{
bool honorCutList = (i > 0);
bool stillFrame = false;
int pos = 0;

QString relPrefix = (honorCutList ? "rel" : "");
if (!fixed_playbacklen)
playbackLen =
TranslatePositionFrameToMs(total_frames, honorCutList)
/ 1000;
playbackLen = max(playbackLen, 1);
float secsplayed = GetSecondsPlayed(honorCutList);
secsplayed = min((float)playbackLen, max(secsplayed, 0.0f));

info.values.insert(relPrefix + "secondsplayed", (int)secsplayed);
playbackLen = GetTotalSeconds(honorCutList);
int secsplayed = GetSecondsPlayed(honorCutList);

stillFrame = (secsplayed < 0);
playbackLen = max(playbackLen, 0);
secsplayed = min(playbackLen, max(secsplayed, 0));

if (playbackLen > 0)
pos = (int)(1000.0f * (secsplayed / (float)playbackLen));

info.values.insert(relPrefix + "secondsplayed", secsplayed);
info.values.insert(relPrefix + "totalseconds", playbackLen);
info.values[relPrefix + "position"] = (int)(1000.0f * (secsplayed / (float)playbackLen));
info.values[relPrefix + "position"] = pos;

int phours = (int)secsplayed / 3600;
int pmins = ((int)secsplayed - phours * 3600) / 60;
Expand Down Expand Up @@ -4865,7 +4874,10 @@ void MythPlayer::calcSliderPos(osdInfo &info, bool paddedFields)
}
}

info.text[relPrefix + "description"] = tr("%1 of %2").arg(text1).arg(text2);
QString desc = stillFrame ? tr("Still Frame") :
tr("%1 of %2").arg(text1).arg(text2);

info.text[relPrefix + "description"] = desc;
info.text[relPrefix + "playedtime"] = text1;
info.text[relPrefix + "totaltime"] = text2;
info.text[relPrefix + "remainingtime"] = islive ? QString() : text3;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -182,8 +182,8 @@ class MTV_PUBLIC MythPlayer
uint64_t GetTotalFrameCount(void) const { return totalFrames; }
uint64_t GetCurrentFrameCount(void) const;
uint64_t GetFramesPlayed(void) const { return framesPlayed; }
virtual int64_t GetSecondsPlayed(bool honorCutList);
virtual int64_t GetTotalSeconds(void) const;
virtual int64_t GetSecondsPlayed(bool honorCutList) const;
virtual int64_t GetTotalSeconds(bool honorCutList) const;
virtual uint64_t GetBookmark(void);
QString GetError(void) const;
bool IsErrorRecoverable(void) const
Expand Down

0 comments on commit 4be52bd

Please sign in to comment.