[SCM] kodi-pvr-hts/master: Parse channel type/channel name for recordings with deleted channels, htsp v25 addition

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


The following commit has been merged in the master branch:
commit 580ff33827f7fe733b07cb6e0f4bea94160dc5a3
Author: Glenn-1990 <g_christiaensen at msn.com>
Date:   Wed Jun 15 10:48:54 2016 +0200

    Parse channel type/channel name for recordings with deleted channels, htsp v25 addition

diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp
index 4c1b064..c7f41e6 100644
--- a/src/Tvheadend.cpp
+++ b/src/Tvheadend.cpp
@@ -418,16 +418,17 @@ PVR_ERROR CTvheadend::GetRecordings ( ADDON_HANDLE handle )
       PVR_RECORDING rec;
       memset(&rec, 0, sizeof(rec));
 
-      /* Channel name and icon */
+      /* Channel icon */
       if ((cit = m_channels.find(recording.GetChannel())) != m_channels.end())
       {
-        strncpy(rec.strChannelName, cit->second.GetName().c_str(),
-                sizeof(rec.strChannelName) - 1);
-
         strncpy(rec.strIconPath, cit->second.GetIcon().c_str(),
                 sizeof(rec.strIconPath) - 1);
       }
 
+      /* Channel name */
+      strncpy(rec.strChannelName, recording.GetChannelName().c_str(),
+              sizeof(rec.strChannelName) - 1);
+
       /* ID */
       snprintf(buf, sizeof(buf), "%i", recording.GetId());
       strncpy(rec.strRecordingId, buf, sizeof(rec.strRecordingId) - 1);
@@ -474,31 +475,18 @@ PVR_ERROR CTvheadend::GetRecordings ( ADDON_HANDLE handle )
       rec.iChannelUid = recording.GetChannel() > 0 ? recording.GetChannel() : PVR_CHANNEL_INVALID_UID;
 
       /* channel type */
-      if (rec.iChannelUid == PVR_CHANNEL_INVALID_UID)
-      {
-        rec.channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN;
-      }
-      else
+      switch (recording.GetChannelType())
       {
-        auto cit = m_channels.find(rec.iChannelUid);
-        if (cit == m_channels.cend())
+        case CHANNEL_TYPE_TV:
+          rec.channelType = PVR_RECORDING_CHANNEL_TYPE_TV;
+          break;
+        case CHANNEL_TYPE_RADIO:
+          rec.channelType = PVR_RECORDING_CHANNEL_TYPE_RADIO;
+          break;
+        case CHANNEL_TYPE_OTHER:
+        default:
           rec.channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN;
-        else
-        {
-          switch (cit->second.GetType())
-          {
-            case CHANNEL_TYPE_TV:
-              rec.channelType = PVR_RECORDING_CHANNEL_TYPE_TV;
-              break;
-            case CHANNEL_TYPE_RADIO:
-              rec.channelType = PVR_RECORDING_CHANNEL_TYPE_RADIO;
-              break;
-            case CHANNEL_TYPE_OTHER:
-            default:
-              rec.channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN;
-              break;
-          }
-        }
+          break;
       }
 
       recs.push_back(rec);
@@ -1932,8 +1920,63 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd )
 
   /* Channel is optional, it may not exist anymore */
   if (!htsmsg_get_u32(msg, "channel", &channel))
+  {
+    /* Channel Id */
     rec.SetChannel(channel);
 
+    auto cit = m_channels.find(rec.GetChannel());
+    if (cit != m_channels.cend())
+    {
+      /* Channel type */
+      rec.SetChannelType(cit->second.GetType());
+
+      /* Channel name */
+      rec.SetChannelName(cit->second.GetName());
+    }
+  }
+
+  /* Channel type fallback (in case channel was deleted) */
+  if (!rec.GetChannelType() && m_conn.GetProtocol() >= 25)
+  {
+    htsmsg_t *files, *streams;
+    if ((files = htsmsg_get_list(msg, "files")) != NULL)
+    {
+      htsmsg_field_t *file, *stream;
+      uint32_t hasAudio = 0, hasVideo = 0, u32;
+
+      HTSMSG_FOREACH(file, files) // Loop through all files
+      {
+        if (file->hmf_type != HMF_MAP)
+          continue;
+
+        if ((streams = htsmsg_get_list(&file->hmf_msg, "info")) != NULL)
+        {
+          HTSMSG_FOREACH(stream, streams) // Loop through all streams
+          {
+            if (stream->hmf_type != HMF_MAP)
+              continue;
+
+            if (!htsmsg_get_u32(&stream->hmf_msg, "audio_type", &u32)) // Only present for audio streams
+              hasAudio = 1;
+            if (!htsmsg_get_u32(&stream->hmf_msg, "aspect_num", &u32)) // Only present for video streams
+              hasVideo = 1;
+            if (hasAudio && hasVideo) // No need to parse the rest
+              break;
+          }
+        }
+      }
+      rec.SetChannelType(hasVideo ? CHANNEL_TYPE_TV :
+          (hasAudio ? CHANNEL_TYPE_RADIO : CHANNEL_TYPE_OTHER));
+    }
+  }
+
+  /* Channel name fallback (in case channel was deleted) */
+  if (rec.GetChannelName().empty() && m_conn.GetProtocol() >= 25)
+  {
+    if ((str = htsmsg_get_str(msg, "channelName")) != NULL)
+      rec.SetChannelName(str);
+  }
+
   if (!htsmsg_get_s64(msg, "startExtra", &startExtra))
     rec.SetStartExtra(startExtra);
   else if (bAdd)
diff --git a/src/tvheadend/entity/Recording.h b/src/tvheadend/entity/Recording.h
index e66ad87..ca6a2d5 100644
--- a/src/tvheadend/entity/Recording.h
+++ b/src/tvheadend/entity/Recording.h
@@ -55,6 +55,7 @@ namespace tvheadend
       Recording() :
         m_enabled(0),
         m_channel(0),
+        m_channelType(0),
         m_eventId(0),
         m_start(0),
         m_stop(0),
@@ -71,6 +72,8 @@ namespace tvheadend
         return m_id == other.m_id &&
                m_enabled == other.m_enabled &&
                m_channel == other.m_channel &&
+               m_channelType == other.m_channelType &&
+               m_channelName == other.m_channelName &&
                m_eventId == other.m_eventId &&
                m_start == other.m_start &&
                m_stop == other.m_stop &&
@@ -128,6 +131,12 @@ namespace tvheadend
       uint32_t GetChannel() const { return m_channel; }
       void SetChannel(uint32_t channel) { m_channel = channel; }
 
+      uint32_t GetChannelType() const { return m_channelType; }
+      void SetChannelType(uint32_t channelType) { m_channelType = channelType; }
+
+      const std::string& GetChannelName() const { return m_channelName; }
+      void SetChannelName(const std::string &channelName) { m_channelName = channelName; }
+
       uint32_t GetEventId() const { return m_eventId; }
       void SetEventId(uint32_t eventId) { m_eventId = eventId; }
 
@@ -181,6 +190,8 @@ namespace tvheadend
     private:
       uint32_t         m_enabled;
       uint32_t         m_channel;
+      uint32_t         m_channelType;
+      std::string      m_channelName;
       uint32_t         m_eventId;
       int64_t          m_start;
       int64_t          m_stop;

-- 
kodi-pvr-hts packaging



More information about the pkg-multimedia-commits mailing list