From 11ec21681958baea5adea8ba33ff53f0f1366e60 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Mon, 13 Apr 2020 18:07:59 +0200 Subject: [PATCH] 5.5.0 Add support for recording file size --- pvr.hts/addon.xml.in | 2 +- pvr.hts/changelog.txt | 3 +++ src/Tvheadend.cpp | 8 ++++++++ src/client.cpp | 3 +++ src/tvheadend/entity/Recording.h | 7 ++++++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pvr.hts/addon.xml.in b/pvr.hts/addon.xml.in index bc28f16c..db14f51f 100644 --- a/pvr.hts/addon.xml.in +++ b/pvr.hts/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index 44084daf..84885fd1 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -1,3 +1,6 @@ +5.5.0 +- Add support for recording file size (HTSP v35) + 5.4.8 - Update PVR API 6.5.0 diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp index f5180696..9eec249a 100644 --- a/src/Tvheadend.cpp +++ b/src/Tvheadend.cpp @@ -469,6 +469,9 @@ PVR_ERROR CTvheadend::GetRecordings(ADDON_HANDLE handle) rec.recordingTime = static_cast(start); rec.iDuration = static_cast(stop - start); + /* File size */ + rec.sizeInBytes = recording.GetFilesSize(); + /* Priority */ rec.iPriority = recording.GetPriority(); @@ -2297,6 +2300,7 @@ void CTvheadend::ParseRecordingAddOrUpdate(htsmsg_t* msg, bool bAdd) start = 0; stop = 0; + int64_t size = 0; htsmsg_field_t* file = nullptr; HTSMSG_FOREACH(file, files) // Loop through all files @@ -2333,11 +2337,15 @@ void CTvheadend::ParseRecordingAddOrUpdate(htsmsg_t* msg, bool bAdd) if (!htsmsg_get_s64(&file->hmf_msg, "stop", &s64) && stop < s64) stop = s64; + + if (!htsmsg_get_s64(&file->hmf_msg, "size", &s64)) + size += s64; } // Set the times the recording actually started/stopped. They may differ from the scheduled start/stop. rec.SetFilesStart(start); rec.SetFilesStop(stop); + rec.SetFilesSize(size); /* Channel type fallback (in case channel was deleted) */ if (needChannelType) diff --git a/src/client.cpp b/src/client.cpp index a429f109..c722b268 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -185,6 +185,9 @@ PVR_ERROR GetCapabilities(PVR_ADDON_CAPABILITIES* pCapabilities) ++i; } } + + pCapabilities->bSupportsRecordingSize = tvh->GetProtocol() >= 35; + return PVR_ERROR_NO_ERROR; } diff --git a/src/tvheadend/entity/Recording.h b/src/tvheadend/entity/Recording.h index c8ddd5dc..19190052 100644 --- a/src/tvheadend/entity/Recording.h +++ b/src/tvheadend/entity/Recording.h @@ -53,6 +53,7 @@ class Recording : public Entity m_stopExtra(0), m_filesStart(0), m_filesStop(0), + m_filesSize(0), m_state(PVR_TIMER_STATE_ERROR), m_lifetime(0), m_priority(50), // Kodi default - "normal" @@ -72,7 +73,7 @@ class Recording : public Entity m_eventId == other.m_eventId && m_start == other.m_start && m_stop == other.m_stop && m_startExtra == other.m_startExtra && m_stopExtra == other.m_stopExtra && m_filesStart == other.m_filesStart && m_filesStop == other.m_filesStop && - m_title == other.m_title && m_path == other.m_path && + m_filesSize == other.m_filesSize && m_title == other.m_title && m_path == other.m_path && m_description == other.m_description && m_image == other.m_image && m_fanartImage == other.m_fanartImage && m_timerecId == other.m_timerecId && m_autorecId == other.m_autorecId && m_state == other.m_state && @@ -148,6 +149,9 @@ class Recording : public Entity int64_t GetFilesStop() const { return m_filesStop; } void SetFilesStop(int64_t stop) { m_filesStop = stop; } + int64_t GetFilesSize() const { return m_filesSize; } + void SetFilesSize(int64_t size) { m_filesSize = size; } + const std::string& GetTitle() const { return m_title; } void SetTitle(const std::string& title) { m_title = title; } @@ -218,6 +222,7 @@ class Recording : public Entity int64_t m_stopExtra; int64_t m_filesStart; int64_t m_filesStop; + int64_t m_filesSize; std::string m_title; std::string m_subtitle; std::string m_path;