]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
htsp: Allow basic htsp format, fixes #5630
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 1 May 2019 11:55:14 +0000 (12:55 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 15 Oct 2019 07:04:12 +0000 (09:04 +0200)
The tvguide can be very large for very low memory devices. So allow
a basic format which excludes the long description fields, thus
reducing memory overhead.

docs/property/htsp_output_format.md [new file with mode: 0644]
src/access.c
src/access.h
src/htsp_server.c
src/webui/static/app/acleditor.js

diff --git a/docs/property/htsp_output_format.md b/docs/property/htsp_output_format.md
new file mode 100644 (file)
index 0000000..7ef2353
--- /dev/null
@@ -0,0 +1,8 @@
+:
+
+Option                           | Description
+---------------------------------|------------
+**All**                          | Include all information.
+**Basic**                        | Limited information for low memory devices.
+
+This setting can be overridden on a per-user basis, see [Access Entries](class/access).
index 1d8138338318a9f909ef9e337e0429f2efe4a9dc..be0fd7ab10c327cbfa39618fb14760afb96033f5 100644 (file)
@@ -293,6 +293,7 @@ access_copy(access_t *src)
   if (src->aa_auth)
     dst->aa_auth = strdup(src->aa_auth);
   dst->aa_xmltv_output_format = src->aa_xmltv_output_format;
+  dst->aa_htsp_output_format = src->aa_htsp_output_format;
   return dst;
 }
 
@@ -690,6 +691,7 @@ access_update(access_t *a, access_entry_t *ae)
   }
 
   a->aa_xmltv_output_format = ae->ae_xmltv_output_format;
+  a->aa_htsp_output_format = ae->ae_htsp_output_format;
 }
 
 /**
@@ -1427,6 +1429,17 @@ access_entry_xmltv_output_format_enum ( void *p, const char *lang )
   return strtab2htsmsg(xmltv_output_format_tab, 1, lang);
 }
 
+static htsmsg_t *
+access_entry_htsp_output_format_enum ( void *p, const char *lang )
+{
+  static struct strtab
+  htsp_output_format_tab[] = {
+    { N_("All"),                           ACCESS_HTSP_OUTPUT_FORMAT_ALL },
+    { N_("Basic"),                         ACCESS_HTSP_OUTPUT_FORMAT_BASIC },
+  };
+  return strtab2htsmsg(htsp_output_format_tab, 1, lang);
+}
+
 htsmsg_t *
 language_get_list ( void *obj, const char *lang )
 {
@@ -1672,6 +1685,7 @@ PROP_DOC(persistent_viewlevel)
 PROP_DOC(streaming_profile)
 PROP_DOC(change_parameters)
 PROP_DOC(xmltv_output_format)
+PROP_DOC(htsp_output_format)
 
 const idclass_t access_entry_class = {
   .ic_class      = "access",
@@ -1929,6 +1943,16 @@ const idclass_t access_entry_class = {
       .list     = access_entry_xmltv_output_format_enum,
       .opts     = PO_ADVANCED | PO_DOC_NLIST,
     },
+    {
+      .type     = PT_INT,
+      .id       = "htsp_output_format",
+      .name     = N_("Format for htsp output"),
+      .desc     = N_("Specify format for htsp output."),
+      .doc      = prop_doc_htsp_output_format,
+      .off      = offsetof(access_entry_t, ae_htsp_output_format),
+      .list     = access_entry_htsp_output_format_enum,
+      .opts     = PO_ADVANCED | PO_DOC_NLIST,
+    },
     {
       .type     = PT_STR,
       .id       = "comment",
index 545ebec6fb63decf1370a1869d25f7f260dcaa4c..a188b0eb346ddaf2e298051ffb572ffbf5817d4e 100644 (file)
@@ -100,6 +100,11 @@ enum {
   ACCESS_XMLTV_OUTPUT_FORMAT_BASIC_NO_HASH,
 };
 
+enum {
+  ACCESS_HTSP_OUTPUT_FORMAT_ALL = 0,
+  ACCESS_HTSP_OUTPUT_FORMAT_BASIC,
+};
+
 typedef struct access_entry {
   idnode_t ae_id;
 
@@ -131,6 +136,7 @@ typedef struct access_entry {
   uint32_t ae_conn_limit;
   int ae_change_conn_limit;
   int ae_xmltv_output_format;
+  int ae_htsp_output_format;
 
   int ae_dvr;
   int ae_htsp_dvr;
@@ -179,6 +185,7 @@ typedef struct access {
   int       aa_match;
   uint32_t  aa_conn_limit;
   uint32_t  aa_xmltv_output_format;
+  uint32_t  aa_htsp_output_format;
   uint32_t  aa_conn_limit_streaming;
   uint32_t  aa_conn_limit_dvr;
   uint32_t  aa_conn_streaming;
index a7f8a79e06ab51f7e058eddaf2ede90c2d5e731b..d61b45eb30437e3865e8a83f59cb1690f64d1e24 100644 (file)
@@ -1237,6 +1237,7 @@ htsp_build_event
   epg_episode_num_t epnum;
   const char *str;
   char buf[512];
+  const int of = htsp->htsp_granted_access->aa_htsp_output_format;
 
   /* Ignore? */
   if (update && e->updated <= update) return NULL;
@@ -1253,35 +1254,40 @@ htsp_build_event
   htsmsg_add_s64(out, "stop", e->stop);
   if ((str = epg_broadcast_get_title(e, lang)))
     htsmsg_add_str(out, "title", str);
-  if (htsp->htsp_version < 32) {
-    if ((str = epg_broadcast_get_description(e, lang))) {
-      htsmsg_add_str(out, "description", str);
-      if ((str = epg_broadcast_get_summary(e, lang)))
-        htsmsg_add_str(out, "summary", str);
-      if ((str = epg_broadcast_get_subtitle(e, lang)))
-        htsmsg_add_str(out, "subtitle", str);
-    } else if ((str = epg_broadcast_get_summary(e, lang))) {
-      htsmsg_add_str(out, "description", str);
+  /* For basic format, we want to skip the large text fields
+   * and go straight to doing the low-overhead fields.
+   */
+  if (of != ACCESS_HTSP_OUTPUT_FORMAT_BASIC) {
+    if (htsp->htsp_version < 32) {
+      if ((str = epg_broadcast_get_description(e, lang))) {
+        htsmsg_add_str(out, "description", str);
+        if ((str = epg_broadcast_get_summary(e, lang)))
+          htsmsg_add_str(out, "summary", str);
+        if ((str = epg_broadcast_get_subtitle(e, lang)))
+          htsmsg_add_str(out, "subtitle", str);
+      } else if ((str = epg_broadcast_get_summary(e, lang))) {
+        htsmsg_add_str(out, "description", str);
+        if ((str = epg_broadcast_get_subtitle(e, lang)))
+          htsmsg_add_str(out, "subtitle", str);
+      } else if ((str = epg_broadcast_get_subtitle(e, lang))) {
+        htsmsg_add_str(out, "description", str);
+      }
+    } else {
       if ((str = epg_broadcast_get_subtitle(e, lang)))
         htsmsg_add_str(out, "subtitle", str);
-    } else if ((str = epg_broadcast_get_subtitle(e, lang))) {
-      htsmsg_add_str(out, "description", str);
+      if ((str = epg_broadcast_get_summary(e, lang)))
+        htsmsg_add_str(out, "summary", str);
+      if ((str = epg_broadcast_get_description(e, lang)))
+        htsmsg_add_str(out, "description", str);
     }
-  } else {
-    if ((str = epg_broadcast_get_subtitle(e, lang)))
-      htsmsg_add_str(out, "subtitle", str);
-    if ((str = epg_broadcast_get_summary(e, lang)))
-      htsmsg_add_str(out, "summary", str);
-    if ((str = epg_broadcast_get_description(e, lang)))
-      htsmsg_add_str(out, "description", str);
-  }
 
-  if (e->credits)
-    htsmsg_add_msg(out, "credits", htsmsg_copy(e->credits));
-  if (e->category)
-    string_list_serialize(e->category, out, "category");
-  if (e->keyword)
-    string_list_serialize(e->keyword, out, "keyword");
+    if (e->credits)
+      htsmsg_add_msg(out, "credits", htsmsg_copy(e->credits));
+    if (e->category)
+      string_list_serialize(e->category, out, "category");
+    if (e->keyword)
+      string_list_serialize(e->keyword, out, "keyword");
+  }
 
   if (e->serieslink)
     htsmsg_add_str(out, "serieslinkUri", e->serieslink->uri);
index 68c1a928abc61c97d8ad1e57ce84de7aa946c021..a6bb992e9215522a81174522ef814a71c2baa0c2 100644 (file)
@@ -15,7 +15,7 @@ tvheadend.acleditor = function(panel, index)
                 'streaming,profile,conn_limit_type,conn_limit,' +
                 'dvr,htsp_anonymize,dvr_config,' +
                 'channel_min,channel_max,channel_tag_exclude,' +
-                'channel_tag,xmltv_output_format,comment';
+                'channel_tag,xmltv_output_format,htsp_output_format,comment';
 
     tvheadend.idnode_grid(panel, {
         id: 'access_entry',