[SCM] kodi-pvr-hts/master: [API 5.0.0, 5.1.0] Async epg transfer: implement epg time frame support.

tiber-guest at users.alioth.debian.org tiber-guest at users.alioth.debian.org
Fri Nov 4 23:23:38 UTC 2016


The following commit has been merged in the master branch:
commit edc778e3ffcbd3434a9365426ef2ccb41b157c58
Author: Kai Sommerfeld <kai.sommerfeld at gmx.com>
Date:   Mon Mar 7 14:50:04 2016 +0100

    [API 5.0.0,5.1.0] Async epg transfer: implement epg time frame support.

diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp
index db4b28f..8f35f91 100644
--- a/src/Tvheadend.cpp
+++ b/src/Tvheadend.cpp
@@ -36,10 +36,10 @@ using namespace tvheadend;
 using namespace tvheadend::entity;
 using namespace tvheadend::utilities;
 
-CTvheadend::CTvheadend()
+CTvheadend::CTvheadend(PVR_PROPERTIES *pvrProps)
   : m_streamchange(false), m_vfs(m_conn),
     m_queue((size_t)-1), m_asyncState(Settings::GetInstance().GetResponseTimeout()),
-    m_timeRecordings(m_conn), m_autoRecordings(m_conn)
+    m_timeRecordings(m_conn), m_autoRecordings(m_conn), m_epgMaxDays(pvrProps->iEpgMaxDays)
 {
   for (int i = 0; i < 1 || i < Settings::GetInstance().GetTotalTuners(); i++)
   {
@@ -1293,6 +1293,21 @@ PVR_ERROR CTvheadend::GetEpg
   return PVR_ERROR_NO_ERROR;
 }
 
+PVR_ERROR CTvheadend::SetEPGTimeFrame(int iDays)
+{
+  if (m_epgMaxDays != iDays)
+  {
+    m_epgMaxDays = iDays;
+
+    if (Settings::GetInstance().GetAsyncEpg())
+    {
+      Logger::Log(LogLevel::LEVEL_TRACE, "reconnecting to synchronize epg data. epg max time: old = %d, new = %d", m_epgMaxDays, iDays);
+      m_conn.Disconnect(); // reconnect to synchronize epg data
+    }
+  }
+  return PVR_ERROR_NO_ERROR;
+}
+
 /* **************************************************************************
  * Connection
  * *************************************************************************/
@@ -1329,9 +1344,15 @@ bool CTvheadend::Connected ( void )
   m_asyncState.SetState(ASYNC_NONE);
   
   msg = htsmsg_create_map();
-  htsmsg_add_u32(msg, "epg", Settings::GetInstance().GetAsyncEpg());
-  //htsmsg_add_u32(msg, "epgMaxTime", 0);
-  //htsmsg_add_s64(msg, "lastUpdate", 0);
+  if (Settings::GetInstance().GetAsyncEpg())
+  {
+    htsmsg_add_u32(msg, "epg", 1);
+    if (m_epgMaxDays > EPG_TIMEFRAME_UNLIMITED)
+      htsmsg_add_s64(msg, "epgMaxTime", static_cast<int64_t>(time(NULL) + m_epgMaxDays * int64_t(24 * 60 *60)));
+  }
+  else
+    htsmsg_add_u32(msg, "epg", 0);
+
   if ((msg = m_conn.SendAndWait0("enableAsyncMetadata", msg)) == NULL)
     return false;
 
diff --git a/src/Tvheadend.h b/src/Tvheadend.h
index 3c5dc5d..34fcad2 100644
--- a/src/Tvheadend.h
+++ b/src/Tvheadend.h
@@ -337,7 +337,7 @@ class CTvheadend
   : public P8PLATFORM::CThread
 {
 public:
-  CTvheadend();
+  CTvheadend(PVR_PROPERTIES *pvrProps);
   ~CTvheadend();
 
   void Start ( void );
@@ -376,6 +376,7 @@ public:
 
   PVR_ERROR GetEpg            ( ADDON_HANDLE handle, const PVR_CHANNEL &chn,
                                 time_t start, time_t end );
+  PVR_ERROR SetEPGTimeFrame   ( int iDays );
 
 private:
   bool      CreateTimer       ( const tvheadend::entity::Recording &tvhTmr, PVR_TIMER &tmr );
@@ -425,6 +426,8 @@ private:
   TimeRecordings              m_timeRecordings;
   AutoRecordings              m_autoRecordings;
 
+  int                         m_epgMaxDays;
+
   /*
    * Predictive tuning
    */
diff --git a/src/client.cpp b/src/client.cpp
index d4dcd6c..f1178a2 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -63,11 +63,11 @@ void ADDON_ReadSettings(void)
   Settings::GetInstance().ReadSettings();
 }
 
-ADDON_STATUS ADDON_Create(void* hdl, void* _unused(props))
+ADDON_STATUS ADDON_Create(void* hdl, void* props)
 {
-  if (!hdl)
+  if (!hdl || !props)
     return m_CurStatus;
-  
+
   /* Instantiate helpers */
   XBMC  = new CHelper_libXBMC_addon;
   CODEC = new CHelper_libXBMC_codec;
@@ -114,7 +114,7 @@ ADDON_STATUS ADDON_Create(void* hdl, void* _unused(props))
 
   ADDON_ReadSettings();
 
-  tvh = new CTvheadend();
+  tvh = new CTvheadend(reinterpret_cast<PVR_PROPERTIES *>(props));
   tvh->Start();
 
   m_CurStatus = ADDON_STATUS_OK;
@@ -403,8 +403,7 @@ PVR_ERROR GetEPGForChannel
 
 PVR_ERROR SetEPGTimeFrame(int iDays)
 {
-  // TODO: implement filter for epg data push according to this value
-  return PVR_ERROR_NO_ERROR;
+  return tvh->SetEPGTimeFrame(iDays);
 }
 
 /* **************************************************************************

-- 
kodi-pvr-hts packaging



More information about the pkg-multimedia-commits mailing list