Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #170 from fetzerch/playposition
Browse files Browse the repository at this point in the history
Add iLastPlayedPosition to PVR_RECORDING
  • Loading branch information
Lars Op den Kamp committed Mar 7, 2013
2 parents 5ef7f7f + 80aedb1 commit aa3a4d2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
4 changes: 3 additions & 1 deletion addons/pvr.mythtv.cmyth/addon/changelog.txt
@@ -1,5 +1,7 @@
v1.7.9
- Bump after PVR API version bump
- Provide EDLs if available (commercial skip data cut lists)
Currently only works for videos with constant frame
- Disconnect from / reconnect to backend when XBMC goes to / resumes from standby

v1.6.9
- Added Live TV vs. recording conflict handling
Expand Down
50 changes: 30 additions & 20 deletions addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
Expand Up @@ -524,6 +524,7 @@ PVR_ERROR PVRClientMythTV::GetRecordings(ADDON_HANDLE handle)
tag.recordingTime = it->second.StartTime();
tag.iDuration = it->second.Duration();
tag.iPlayCount = it->second.IsWatched() ? 1 : 0;
tag.iLastPlayedPosition = GetRecordingLastPlayedPosition(it->second);

CStdString id = it->second.UID();
CStdString title = it->second.Title();
Expand Down Expand Up @@ -824,32 +825,25 @@ PVR_ERROR PVRClientMythTV::SetRecordingLastPlayedPosition(const PVR_RECORDING &r
return PVR_ERROR_FAILED;
}

int PVRClientMythTV::GetRecordingLastPlayedPosition(const PVR_RECORDING &recording)
int PVRClientMythTV::GetRecordingLastPlayedPosition(MythProgramInfo &programInfo)
{
// MythTV provides it's bookmarks as frame offsets whereas XBMC expects a time offset.
// The bookmark in seconds is calculated by: bookmark = frameOffset / frameRate.
int bookmark = 0;

if (g_bExtraDebug)
{
XBMC->Log(LOG_DEBUG, "%s - Reading Bookmark for: %s", __FUNCTION__, recording.strTitle);
}

CLockObject lock(m_recordingsLock);
ProgramInfoMap::iterator it = m_recordings.find(recording.strRecordingId);
if (it != m_recordings.end() && it->second.HasBookmark())
if (programInfo.HasBookmark())
{
long long frameOffset = m_con.GetBookmark(it->second); // returns 0 if no bookmark was found
long long frameOffset = m_con.GetBookmark(programInfo); // returns 0 if no bookmark was found
if (frameOffset > 0)
{
if (g_bExtraDebug)
{
XBMC->Log(LOG_DEBUG, "%s - FrameOffset: %lld)", __FUNCTION__, frameOffset);
}
// Pin framerate value
if (it->second.Framterate() <0)
it->second.SetFramerate(m_db.GetRecordingFrameRate(it->second));
float frameRate = (float)it->second.Framterate() / 1000.0f;
if (programInfo.Framterate() < 0)
programInfo.SetFramerate(m_db.GetRecordingFrameRate(programInfo));
float frameRate = (float)programInfo.Framterate() / 1000.0f;
if (frameRate > 0)
{
bookmark = (int)((float)frameOffset / frameRate);
Expand All @@ -862,15 +856,10 @@ int PVRClientMythTV::GetRecordingLastPlayedPosition(const PVR_RECORDING &recordi
}
else
{
if (it == m_recordings.end())
{
XBMC->Log(LOG_ERROR, "%s - Recording %s does not exist", __FUNCTION__, recording.strRecordingId);
}
else if (!it->second.HasBookmark() && g_bExtraDebug)
if (g_bExtraDebug)
{
XBMC->Log(LOG_DEBUG, "%s - Recording %s has no bookmark", __FUNCTION__, recording.strRecordingId);
XBMC->Log(LOG_DEBUG, "%s - Recording %s has no bookmark", __FUNCTION__, programInfo.Title().c_str());
}
return bookmark;
}

if (bookmark < 0) bookmark = 0;
Expand Down Expand Up @@ -934,6 +923,27 @@ PVR_ERROR PVRClientMythTV::GetRecordingEdl(const PVR_RECORDING &recording, PVR_E
return PVR_ERROR_NO_ERROR;
}

int PVRClientMythTV::GetRecordingLastPlayedPosition(const PVR_RECORDING &recording)
{
// MythTV provides it's bookmarks as frame offsets whereas XBMC expects a time offset.
// The bookmark in seconds is calculated by: bookmark = frameOffset / frameRate.
int bookmark = 0;

if (g_bExtraDebug)
{
XBMC->Log(LOG_DEBUG, "%s - Reading Bookmark for: %s", __FUNCTION__, recording.strTitle);
}

CLockObject lock(m_recordingsLock);
ProgramInfoMap::iterator it = m_recordings.find(recording.strRecordingId);
if (it != m_recordings.end())
bookmark = GetRecordingLastPlayedPosition(it->second);
else
XBMC->Log(LOG_ERROR, "%s - Recording %s does not exist", __FUNCTION__, recording.strRecordingId);

return bookmark;
}

int PVRClientMythTV::GetTimersAmount(void)
{
if (g_bExtraDebug)
Expand Down
1 change: 1 addition & 0 deletions addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.h
Expand Up @@ -149,6 +149,7 @@ class PVRClientMythTV : public MythEventObserver
void EventUpdateRecordings();
void ForceUpdateRecording(ProgramInfoMap::iterator it);
int FillRecordings();
int GetRecordingLastPlayedPosition(MythProgramInfo &programInfo);

// Timers
RecordingRuleList m_recordingRules;
Expand Down

0 comments on commit aa3a4d2

Please sign in to comment.