[SCM] kodi-pvr-hts/master: Remove actual file when lifetime expires

tiber-guest at users.alioth.debian.org tiber-guest at users.alioth.debian.org
Wed Mar 2 23:01:49 UTC 2016


The following commit has been merged in the master branch:
commit bdcf14ff73b0eca883c03faecf34222538ec916f
Author: Glenn-1990 <g_christiaensen at msn.com>
Date:   Fri Nov 13 21:20:33 2015 +0100

    Remove actual file when lifetime expires

diff --git a/src/AutoRecordings.cpp b/src/AutoRecordings.cpp
index 87e12e2..ee61cb6 100644
--- a/src/AutoRecordings.cpp
+++ b/src/AutoRecordings.cpp
@@ -102,7 +102,7 @@ void AutoRecordings::GetAutorecTimers(std::vector<PVR_TIMER> &timers)
                               : PVR_TIMER_STATE_DISABLED;
     tmr.iTimerType         = TIMER_REPEATING_EPG;
     tmr.iPriority          = tit->second.GetPriority();
-    tmr.iLifetime          = tit->second.GetRetention();
+    tmr.iLifetime          = tit->second.GetLifetime();
     tmr.iMaxRecordings     = 0;                    // not supported by tvh
     tmr.iRecordingGroup    = 0;                    // not supported by tvh
 
@@ -156,7 +156,11 @@ PVR_ERROR AutoRecordings::SendAutorecAdd(const PVR_TIMER &timer)
 
   htsmsg_add_s64(m, "startExtra", timer.iMarginStart);
   htsmsg_add_s64(m, "stopExtra",  timer.iMarginEnd);
-  htsmsg_add_u32(m, "retention",  timer.iLifetime);
+  htsmsg_add_u32(m, "retention",  timer.iLifetime); // remove from tvh database
+
+  if (m_conn.GetProtocol() >= 24)
+    htsmsg_add_u32(m, "removal",  timer.iLifetime); // remove from disk
+
   htsmsg_add_u32(m, "daysOfWeek", timer.iWeekdays);
 
   if (m_conn.GetProtocol() >= 20)
@@ -331,6 +335,16 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
     return false;
   }
 
+  if (!htsmsg_get_u32(msg, "removal", &u32))
+  {
+    rec.SetRemoval(u32);
+  }
+  else if (bAdd && (m_conn.GetProtocol() >= 24))
+  {
+    tvherror("malformed autorecEntryAdd: 'removal' missing");
+    return false;
+  }
+
   if (!htsmsg_get_u32(msg, "daysOfWeek", &u32))
   {
     rec.SetDaysOfWeek(u32);
diff --git a/src/TimeRecordings.cpp b/src/TimeRecordings.cpp
index 2e83167..025ca3c 100644
--- a/src/TimeRecordings.cpp
+++ b/src/TimeRecordings.cpp
@@ -82,7 +82,7 @@ void TimeRecordings::GetTimerecTimers(std::vector<PVR_TIMER> &timers)
                               : PVR_TIMER_STATE_DISABLED;
     tmr.iTimerType         = TIMER_REPEATING_MANUAL;
     tmr.iPriority          = tit->second.GetPriority();
-    tmr.iLifetime          = tit->second.GetRetention();
+    tmr.iLifetime          = tit->second.GetLifetime();
     tmr.iMaxRecordings     = 0;                    // not supported by tvh
     tmr.iRecordingGroup    = 0;                    // not supported by tvh
     tmr.iPreventDuplicateEpisodes = 0;             // n/a for manual timers
@@ -128,7 +128,11 @@ PVR_ERROR TimeRecordings::SendTimerecAdd(const PVR_TIMER &timer)
   struct tm *tm_stop = localtime(&timer.endTime);
   htsmsg_add_u32(m, "stop",       tm_stop->tm_hour  * 60 + tm_stop->tm_min);  // end time in minutes from midnight
   htsmsg_add_u32(m, "channelId",  timer.iClientChannelUid);
-  htsmsg_add_u32(m, "retention",  timer.iLifetime);
+  htsmsg_add_u32(m, "retention",  timer.iLifetime); // remove from tvh database
+
+  if (m_conn.GetProtocol() >= 24)
+    htsmsg_add_u32(m, "removal",  timer.iLifetime); // remove from disk
+
   htsmsg_add_u32(m, "daysOfWeek", timer.iWeekdays);
   htsmsg_add_u32(m, "priority",   timer.iPriority);
   htsmsg_add_u32(m, "enabled",    timer.state == PVR_TIMER_STATE_DISABLED ? 0 : 1);
@@ -257,6 +261,16 @@ bool TimeRecordings::ParseTimerecAddOrUpdate(htsmsg_t *msg, bool bAdd)
     return false;
   }
 
+  if (!htsmsg_get_u32(msg, "removal", &u32))
+  {
+    rec.SetRemoval(u32);
+  }
+  else if (bAdd && (m_conn.GetProtocol() >= 24))
+  {
+    tvherror("malformed timerecEntryAdd: 'removal' missing");
+    return false;
+  }
+
   if (!htsmsg_get_u32(msg, "priority", &u32))
   {
     rec.SetPriority(u32);
diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp
index 5f78305..d65a2f0 100644
--- a/src/Tvheadend.cpp
+++ b/src/Tvheadend.cpp
@@ -454,8 +454,8 @@ PVR_ERROR CTvheadend::GetRecordings ( ADDON_HANDLE handle )
       /* Priority */
       rec.iPriority = recording.GetPriority();
 
-      /* Retention */
-      rec.iLifetime = recording.GetRetention();
+      /* Lifetime (based on retention and removal) */
+      rec.iLifetime = recording.GetLifetime();
 
       /* Directory */
       // TODO: Move this logic to GetPath(), alternatively GetMangledPath()
@@ -860,7 +860,7 @@ bool CTvheadend::CreateTimer ( const Recording &tvhTmr, PVR_TIMER &tmr )
     tmr.state            = tvhTmr.GetState();
 
   tmr.iPriority          = tvhTmr.GetPriority();
-  tmr.iLifetime          = tvhTmr.GetRetention();
+  tmr.iLifetime          = tvhTmr.GetLifetime();
   tmr.iTimerType         = tvhTmr.GetTimerType();
   tmr.iMaxRecordings     = 0;                // not supported by tvh
   tmr.iRecordingGroup    = 0;                // not supported by tvh
@@ -960,7 +960,11 @@ PVR_ERROR CTvheadend::AddTimer ( const PVR_TIMER &timer )
 
     htsmsg_add_s64(m, "startExtra", timer.iMarginStart);
     htsmsg_add_s64(m, "stopExtra",  timer.iMarginEnd);
-    htsmsg_add_u32(m, "retention",  timer.iLifetime);
+    htsmsg_add_u32(m, "retention",  timer.iLifetime); // remove from tvh database
+
+    if (m_conn.GetProtocol() >= 24)
+      htsmsg_add_u32(m, "removal",  timer.iLifetime); // remove from disk
+
     htsmsg_add_u32(m, "priority",   timer.iPriority);
 
     /* Send and Wait */
@@ -1076,7 +1080,11 @@ PVR_ERROR CTvheadend::UpdateTimer ( const PVR_TIMER &timer )
     htsmsg_add_str(m, "description",  timer.strSummary);
     htsmsg_add_s64(m, "startExtra",   timer.iMarginStart);
     htsmsg_add_s64(m, "stopExtra",    timer.iMarginEnd);
-    htsmsg_add_u32(m, "retention",    timer.iLifetime);
+    htsmsg_add_u32(m, "retention",    timer.iLifetime); // remove from tvh database
+
+    if (m_conn.GetProtocol() >= 24)
+      htsmsg_add_u32(m, "removal",    timer.iLifetime); // remove from disk
+
     htsmsg_add_u32(m, "priority",     timer.iPriority);
 
     return SendDvrUpdate(m);
@@ -1721,7 +1729,7 @@ void CTvheadend::ParseChannelDelete ( htsmsg_t *msg )
 void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd )
 {
   const char *state, *str;
-  uint32_t id, channel, eventId, retention, priority, enabled;
+  uint32_t id, channel, eventId, retention, removal, priority, enabled;
   int64_t start, stop, startExtra, stopExtra;
 
   /* Channels must be complete */
@@ -1788,6 +1796,14 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd )
     return;
   }
 
+  if (!htsmsg_get_u32(msg, "removal", &removal))
+    rec.SetRemoval(removal);
+  else if (bAdd && (m_conn.GetProtocol() >= 24))
+  {
+    tvherror("malformed dvrEntryAdd: 'removal' missing");
+    return;
+  }
+
   if (!htsmsg_get_u32(msg, "priority", &priority))
   {
     switch (priority)
diff --git a/src/Tvheadend.h b/src/Tvheadend.h
index 65a896a..9587b61 100644
--- a/src/Tvheadend.h
+++ b/src/Tvheadend.h
@@ -68,7 +68,7 @@ extern "C" {
  * Configuration defines
  */
 #define HTSP_MIN_SERVER_VERSION       (19) // Server must support at least this htsp version
-#define HTSP_CLIENT_VERSION           (23) // Client uses HTSP features up to this version. If the respective
+#define HTSP_CLIENT_VERSION           (24) // Client uses HTSP features up to this version. If the respective
                                            // addon feature requires htsp features introduced after
                                            // HTSP_MIN_SERVER_VERSION this feature will only be available if the
                                            // actual server HTSP version matches (runtime htsp version check).
diff --git a/src/tvheadend/entity/Recording.h b/src/tvheadend/entity/Recording.h
index 8492dbd..f96f569 100644
--- a/src/tvheadend/entity/Recording.h
+++ b/src/tvheadend/entity/Recording.h
@@ -61,7 +61,8 @@ namespace tvheadend
         m_stopExtra(0),
         m_state(PVR_TIMER_STATE_ERROR),
         m_retention(99), // Kodi default - "99 days"
-        m_priority(50) // Kodi default - "normal"
+        m_removal(-1),   // max value to stay compatible with older backends
+        m_priority(50)   // Kodi default - "normal"
       {
       }
 
@@ -83,6 +84,7 @@ namespace tvheadend
                m_state == other.m_state &&
                m_error == other.m_error &&
                m_retention == other.m_retention &&
+               m_removal == other.m_removal &&
                m_priority == other.m_priority;
       }
 
@@ -170,8 +172,10 @@ namespace tvheadend
       const std::string& GetError() const { return m_error; }
       void SetError(const std::string &error) { m_error = error; }
 
-      uint32_t GetRetention() const { return m_retention; }
+      // Lifetime = the smallest value
+      uint32_t GetLifetime() const { return std::min(m_removal, m_retention); }
       void SetRetention(uint32_t retention) { m_retention = retention; }
+      void SetRemoval(uint32_t removal) { m_removal = removal; }
 
       uint32_t GetPriority() const { return m_priority; }
       void SetPriority(uint32_t priority) { m_priority = priority; }
@@ -193,6 +197,7 @@ namespace tvheadend
       PVR_TIMER_STATE  m_state;
       std::string      m_error;
       uint32_t         m_retention;
+      uint32_t         m_removal;
       uint32_t         m_priority;
     };
   }
diff --git a/src/tvheadend/entity/RecordingBase.cpp b/src/tvheadend/entity/RecordingBase.cpp
index 0f766df..3c74731 100644
--- a/src/tvheadend/entity/RecordingBase.cpp
+++ b/src/tvheadend/entity/RecordingBase.cpp
@@ -28,6 +28,7 @@ RecordingBase::RecordingBase(const std::string &id /*= ""*/) :
     m_enabled(0),
     m_daysOfWeek(0),
     m_retention(0),
+    m_removal(-1), // max value to stay compatible with older backends
     m_priority(0),
     m_channel(0)
 {
@@ -40,6 +41,7 @@ bool RecordingBase::operator==(const RecordingBase &right)
          m_enabled     == right.m_enabled     &&
          m_daysOfWeek  == right.m_daysOfWeek  &&
          m_retention   == right.m_retention   &&
+         m_removal     == right.m_removal     &&
          m_priority    == right.m_priority    &&
          m_title       == right.m_title       &&
          m_name        == right.m_name        &&
@@ -84,9 +86,10 @@ void RecordingBase::SetDaysOfWeek(uint32_t daysOfWeek)
   m_daysOfWeek = daysOfWeek;
 }
 
-uint32_t RecordingBase::GetRetention() const
+// Lifetime = the smallest value
+uint32_t RecordingBase::GetLifetime() const
 {
-  return m_retention;
+  return std::min(m_removal, m_retention);
 }
 
 void RecordingBase::SetRetention(uint32_t retention)
@@ -94,6 +97,11 @@ void RecordingBase::SetRetention(uint32_t retention)
   m_retention = retention;
 }
 
+void RecordingBase::SetRemoval(uint32_t removal)
+{
+  m_removal = removal;
+}
+
 uint32_t RecordingBase::GetPriority() const
 {
   return m_priority;
@@ -175,4 +183,4 @@ unsigned int RecordingBase::GetNextIntId()
 {
   static unsigned int intId = 0;
   return ++intId;
-}
\ No newline at end of file
+}
diff --git a/src/tvheadend/entity/RecordingBase.h b/src/tvheadend/entity/RecordingBase.h
index c14f197..f179703 100644
--- a/src/tvheadend/entity/RecordingBase.h
+++ b/src/tvheadend/entity/RecordingBase.h
@@ -47,8 +47,9 @@ namespace tvheadend
       int GetDaysOfWeek() const;
       void SetDaysOfWeek(uint32_t daysOfWeek);
 
-      uint32_t GetRetention() const;
+      uint32_t GetLifetime() const;
       void SetRetention(uint32_t retention);
+      void SetRemoval(uint32_t removal);
 
       uint32_t GetPriority() const;
       void SetPriority(uint32_t priority);
@@ -77,7 +78,8 @@ namespace tvheadend
       std::string m_sid;        // ID (string!) of dvr[Time|Auto]recEntry.
       uint32_t m_enabled;       // If [time|auto]rec entry is enabled (activated).
       uint32_t m_daysOfWeek;    // Bitmask - Days of week (0x01 = Monday, 0x40 = Sunday, 0x7f = Whole Week, 0 = Not set).
-      uint32_t m_retention;     // Retention time (in days).
+      uint32_t m_retention;     // Lifetime time of database entry (in days).
+      uint32_t m_removal;       // Lifetime time of actual file on disk (in days).
       uint32_t m_priority;      // Priority (0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant).
       std::string m_title;      // Title (pattern) for the recording files.
       std::string m_name;       // Name.

-- 
kodi-pvr-hts packaging



More information about the pkg-multimedia-commits mailing list