Skip to content

Commit

Permalink
dvdplayer: use time of frame on screen for displayed time
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed May 2, 2015
1 parent e832d3f commit ccff24f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xbmc/Application.cpp
Expand Up @@ -4560,10 +4560,10 @@ double CApplication::GetTime() const
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
{
long startOfCurrentFile = (m_currentStackPosition > 0) ? (*m_currentStack)[m_currentStackPosition-1]->m_lEndOffset : 0;
rc = (double)startOfCurrentFile + m_pPlayer->GetTime() * 0.001;
rc = (double)startOfCurrentFile + m_pPlayer->GetDisplayTime() * 0.001;
}
else
rc = static_cast<double>(m_pPlayer->GetTime() * 0.001f);
rc = static_cast<double>(m_pPlayer->GetDisplayTime() * 0.001f);
}

return rc;
Expand Down
9 changes: 9 additions & 0 deletions xbmc/ApplicationPlayer.cpp
Expand Up @@ -296,6 +296,15 @@ int64_t CApplicationPlayer::GetTime() const
return 0;
}

int64_t CApplicationPlayer::GetDisplayTime() const
{
std::shared_ptr<IPlayer> player = GetInternal();
if (player)
return player->GetDisplayTime();
else
return 0;
}

bool CApplicationPlayer::IsCaching() const
{
std::shared_ptr<IPlayer> player = GetInternal();
Expand Down
1 change: 1 addition & 0 deletions xbmc/ApplicationPlayer.h
Expand Up @@ -114,6 +114,7 @@ class CApplicationPlayer
bool GetSubtitleVisible();
TextCacheStruct_t* GetTeletextCache();
int64_t GetTime() const;
int64_t GetDisplayTime() const;
int64_t GetTotalTime() const;
void GetVideoInfo(std::string& strVideoInfo);
void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
Expand Down
4 changes: 4 additions & 0 deletions xbmc/cores/IPlayer.h
Expand Up @@ -204,6 +204,10 @@ class IPlayer
\brief current time in milliseconds
*/
virtual int64_t GetTime() { return 0; }
/*!
\brief time of frame on screen in milliseconds
*/
virtual int64_t GetDisplayTime() { return GetTime(); }
/*!
\brief total time in milliseconds
*/
Expand Down
27 changes: 27 additions & 0 deletions xbmc/cores/dvdplayer/DVDPlayer.cpp
Expand Up @@ -3254,6 +3254,22 @@ int64_t CDVDPlayer::GetTime()
return llrint(m_State.time + DVD_TIME_TO_MSEC(offset));
}

// return the time in milliseconds
int64_t CDVDPlayer::GetDisplayTime()
{
CSingleLock lock(m_StateSection);
double offset = 0;
const double limit = DVD_MSEC_TO_TIME(200);
if(m_State.timestamp > 0)
{
offset = CDVDClock::GetAbsoluteClock() - m_State.timestamp;
offset *= m_playSpeed / DVD_PLAYSPEED_NORMAL;
if(offset > limit) offset = limit;
if(offset < -limit) offset = -limit;
}
return llrint(m_State.disptime + DVD_TIME_TO_MSEC(offset));
}

// return length in msec
int64_t CDVDPlayer::GetTotalTimeInMsec()
{
Expand Down Expand Up @@ -4478,6 +4494,7 @@ void CDVDPlayer::UpdatePlayState(double timeout)
state.time = 0;
else
state.time = DVD_TIME_TO_MSEC(state.dts + m_offset_pts);

state.time_total = m_pDemuxer->GetStreamLength();
state.time_src = ETIMESOURCE_CLOCK;
}
Expand Down Expand Up @@ -4529,6 +4546,16 @@ void CDVDPlayer::UpdatePlayState(double timeout)
state.time_total = (double) m_Edl.RemoveCutTime(llrint(state.time_total));
}

state.disptime = state.time;
if (m_CurrentVideo.id >= 0 && state.time_src == ETIMESOURCE_CLOCK)
{
double pts = m_dvdPlayerVideo->GetCurrentPts();
if (pts != DVD_NOPTS_VALUE)
{
state.disptime = DVD_TIME_TO_MSEC(pts + m_offset_pts);
}
}

if(state.time_total <= 0)
state.canseek = false;

Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/dvdplayer/DVDPlayer.h
Expand Up @@ -269,6 +269,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
virtual void SeekTime(int64_t iTime);
virtual bool SeekTimeRelative(int64_t iTime);
virtual int64_t GetTime();
virtual int64_t GetDisplayTime();
virtual int64_t GetTotalTime();
virtual void ToFFRW(int iSpeed);
virtual bool OnAction(const CAction &action);
Expand Down Expand Up @@ -497,6 +498,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
double time_offset; // difference between time and pts

double time; // current playback time
double disptime; // current time of frame on screen
double time_total; // total playback time
ETimeSource time_src; // current time source
double dts; // last known dts
Expand Down

0 comments on commit ccff24f

Please sign in to comment.