Skip to content

Commit

Permalink
enable support for recording file size
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Mar 29, 2020
1 parent 38c293b commit 1f378e6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/client.cpp
Expand Up @@ -732,7 +732,9 @@ PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities)
pCapabilities->bSupportsRecordingEdl = true;
pCapabilities->bSupportsRecordingsRename = false;
pCapabilities->bSupportsRecordingsLifetimeChange = false;
pCapabilities->bSupportsDescrambleInfo = false;
pCapabilities->bSupportsDescrambleInfo = false;
pCapabilities->bSupportsAsyncEPGTransfer = false;
pCapabilities->bSupportsRecordingSize = true;

return PVR_ERROR_NO_ERROR;
}
Expand Down Expand Up @@ -966,6 +968,13 @@ PVR_ERROR DeleteAllRecordingsFromTrash()
return g_client->PurgeDeletedRecordings();
}

PVR_ERROR GetRecordingSize(const PVR_RECORDING* recording, int64_t* sizeInBytes)
{
if (g_client == NULL)
return PVR_ERROR_SERVER_ERROR;
return g_client->GetRecordingSize(*recording, sizeInBytes);
};

/*
* PVR Timer Functions
*/
Expand Down Expand Up @@ -1169,7 +1178,6 @@ PVR_ERROR GetDescrambleInfo(PVR_DESCRAMBLE_INFO*) { return PVR_ERROR_NOT_IMPLEME
PVR_ERROR SetRecordingLifetime(const PVR_RECORDING*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetChannelStreamProperties(const PVR_CHANNEL*, PVR_NAMED_VALUE*, unsigned int*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetRecordingStreamProperties(const PVR_RECORDING*, PVR_NAMED_VALUE*, unsigned int*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetRecordingSize(const PVR_RECORDING* recording, int64_t* sizeInBytes) { return PVR_ERROR_NOT_IMPLEMENTED; };
PVR_ERROR IsEPGTagRecordable(const EPG_TAG*, bool*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR IsEPGTagPlayable(const EPG_TAG*, bool*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetEPGTagStreamProperties(const EPG_TAG*, PVR_NAMED_VALUE*, unsigned int*) { return PVR_ERROR_NOT_IMPLEMENTED; }
Expand Down
5 changes: 5 additions & 0 deletions src/cppmyth/MythProgramInfo.cpp
Expand Up @@ -339,6 +339,11 @@ bool MythProgramInfo::IsDamaged() const
return ((m_proginfo && (m_proginfo->videoProps & 0x0020)) ? true : false);
}

int64_t MythProgramInfo::FileSize() const
{
return (m_proginfo ? m_proginfo->fileSize : 0);
}

std::string MythProgramInfo::GroupingTitle() const
{
if (!m_proginfo || !m_groupingTitle.empty())
Expand Down
1 change: 1 addition & 0 deletions src/cppmyth/MythProgramInfo.h
Expand Up @@ -84,6 +84,7 @@ class MythProgramInfo
uint16_t Episode() const;
std::string Airdate() const;
bool IsDamaged() const;
int64_t FileSize() const;

std::string GroupingTitle() const;

Expand Down
31 changes: 25 additions & 6 deletions src/pvrclient-mythtv.cpp
Expand Up @@ -994,6 +994,10 @@ PVR_ERROR PVRClientMythTV::GetRecordings(ADDON_HANDLE handle)
tag.iLifetime = 0;
tag.iPriority = 0;
PVR_STRCPY(tag.strPlotOutline, "");
tag.sizeInBytes = it->second.FileSize();
tag.iFlags = PVR_RECORDING_FLAG_UNDEFINED;
if (!it->second.GetPropsSerie())
tag.iFlags |= PVR_RECORDING_FLAG_IS_SERIES;

PVR->TransferRecordingEntry(handle, &tag);
}
Expand Down Expand Up @@ -1113,12 +1117,8 @@ PVR_ERROR PVRClientMythTV::GetDeletedRecordings(ADDON_HANDLE handle)
tag.iLifetime = 0;
tag.iPriority = 0;
PVR_STRCPY(tag.strPlotOutline, "");

/* TODO: PVR API 5.0.0: Implement this */
tag.iChannelUid = PVR_CHANNEL_INVALID_UID;

/* TODO: PVR API 5.1.0: Implement this */
tag.channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN;
tag.sizeInBytes = it->second.FileSize();
tag.iFlags = PVR_RECORDING_FLAG_UNDEFINED;

PVR->TransferRecordingEntry(handle, &tag);
}
Expand Down Expand Up @@ -1595,6 +1595,25 @@ PVR_ERROR PVRClientMythTV::PurgeDeletedRecordings()
return PVR_ERROR_NO_ERROR;
}

PVR_ERROR PVRClientMythTV::GetRecordingSize(const PVR_RECORDING &recording, int64_t *bytes)
{
if (!m_control)
return PVR_ERROR_SERVER_ERROR;
*bytes = 0;
if (g_bExtraDebug)
XBMC->Log(LOG_DEBUG, "%s: %s", __FUNCTION__, recording.strTitle);
// Check recording
Myth::OS::CLockGuard lock(*m_recordingsLock);
ProgramInfoMap::iterator it = m_recordings.find(recording.strRecordingId);
if (it == m_recordings.end())
{
XBMC->Log(LOG_ERROR, "%s: Recording %s does not exist", __FUNCTION__, recording.strRecordingId);
return PVR_ERROR_INVALID_PARAMETERS;
}
*bytes = it->second.FileSize();
return PVR_ERROR_NO_ERROR;
}

MythChannel PVRClientMythTV::FindRecordingChannel(const MythProgramInfo& programInfo) const
{
return FindChannel(programInfo.ChannelID());
Expand Down
3 changes: 2 additions & 1 deletion src/pvrclient-mythtv.h
Expand Up @@ -101,8 +101,9 @@ class PVRClientMythTV : public Myth::EventSubscriber
PVR_ERROR SetRecordingLastPlayedPosition(const PVR_RECORDING &recording, int lastplayedposition);
int GetRecordingLastPlayedPosition(const PVR_RECORDING &recording);
PVR_ERROR GetRecordingEdl(const PVR_RECORDING &recording, PVR_EDL_ENTRY entries[], int *size);
PVR_ERROR UndeleteRecording(const PVR_RECORDING& recording);
PVR_ERROR UndeleteRecording(const PVR_RECORDING &recording);
PVR_ERROR PurgeDeletedRecordings();
PVR_ERROR GetRecordingSize(const PVR_RECORDING &recording, int64_t *bytes);

// Timers
int GetTimersAmount();
Expand Down

0 comments on commit 1f378e6

Please sign in to comment.