From 9eada6eb4f612c3474fe92ca96d9f1e9c9eb2a24 Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Thu, 11 Jun 2020 09:36:16 +0100 Subject: [PATCH 3/7] hdhomerun: Use servername as Friendly Name. (#4461) Also add helper function for adding name/value pairs to a JSON string. --- src/htsbuf.c | 9 +++++++++ src/htsbuf.h | 2 ++ src/webui/webui.c | 5 +++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/htsbuf.c b/src/htsbuf.c index 50f22a500..935f37ce6 100644 --- a/src/htsbuf.c +++ b/src/htsbuf.c @@ -539,6 +539,15 @@ htsbuf_append_and_escape_jsonstr(htsbuf_queue_t *hq, const char *str) +void htsbuf_append_and_escape_jsonstr_nv(htsbuf_queue_t *hq, const char *name, const char *value) +{ + htsbuf_append_and_escape_jsonstr(hq, name); + htsbuf_append_str(hq, ": "); + htsbuf_append_and_escape_jsonstr(hq, value); +} + + + /** * */ diff --git a/src/htsbuf.h b/src/htsbuf.h index 093299400..1b95e018c 100644 --- a/src/htsbuf.h +++ b/src/htsbuf.h @@ -82,6 +82,8 @@ void htsbuf_append_and_escape_url(htsbuf_queue_t *hq, const char *s); void htsbuf_append_and_escape_rfc8187(htsbuf_queue_t *hq, const char *s); void htsbuf_append_and_escape_jsonstr(htsbuf_queue_t *hq, const char *s); +/** Append a name and value JSON string */ +void htsbuf_append_and_escape_jsonstr_nv(htsbuf_queue_t *hq, const char *name, const char *value); void htsbuf_dump_raw_stderr(htsbuf_queue_t *hq); diff --git a/src/webui/webui.c b/src/webui/webui.c index 16cc5c03c..5e61ea2ff 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -1626,13 +1626,14 @@ hdhomerun_server_discover(http_connection_t *hc, const char *remain, void *opaqu tcp_get_str_from_ip(hc->hc_self, http_ip, sizeof(http_ip)); /* The contents below for the discovery message are based on tvhProxy */ - htsbuf_qprintf(hq, "{ " \ + htsbuf_append_str(hq, "{ "); + htsbuf_append_and_escape_jsonstr_nv(hq, "FriendlyName", server_name); + htsbuf_qprintf(hq, ", " \ "\"BaseURL\" : \"http://%s:%u\", " \ "\"DeviceAuth\": \"none\", " \ "\"DeviceID\": \"%08X\", " \ "\"FirmwareName\": \"hdhomerun_atsc\", " \ "\"FirmwareVersion\": \"20200101\", " \ - "\"FriendlyName\": \"tvheadend\", " \ "\"LineupURL\": \"http://%s:%u/lineup.json\", " \ "\"Manufacturer\": \"Silicondust\", " \ "\"ModelNumber\": \"HDTC-2US\", " \ -- 2.25.1