From 64f20b5ef8b2d1938b6aa10fb4014475a81474e1 Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Wed, 1 May 2019 12:55:14 +0100 Subject: [PATCH] htsp: Allow basic htsp format, fixes #5630 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 | 8 +++++ src/access.c | 24 +++++++++++++ src/access.h | 7 ++++ src/htsp_server.c | 56 ++++++++++++++++------------- src/webui/static/app/acleditor.js | 2 +- 5 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 docs/property/htsp_output_format.md diff --git a/docs/property/htsp_output_format.md b/docs/property/htsp_output_format.md new file mode 100644 index 000000000..7ef2353f6 --- /dev/null +++ b/docs/property/htsp_output_format.md @@ -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). diff --git a/src/access.c b/src/access.c index 1d8138338..be0fd7ab1 100644 --- a/src/access.c +++ b/src/access.c @@ -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", diff --git a/src/access.h b/src/access.h index 545ebec6f..a188b0eb3 100644 --- a/src/access.h +++ b/src/access.h @@ -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; diff --git a/src/htsp_server.c b/src/htsp_server.c index a7f8a79e0..d61b45eb3 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -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); diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index 68c1a928a..a6bb992e9 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -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', -- 2.47.2