From 723fa42ca7828d67b5a36502ae5552b8ddd96823 Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Fri, 12 Jun 2020 00:13:08 +0100 Subject: [PATCH 7/7] hdhomerun: Add device.xml API. --- src/webui/webui.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/webui/webui.c b/src/webui/webui.c index 122326efa..99b5e56c0 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -1746,6 +1746,53 @@ hdhomerun_server_lineup_status(http_connection_t *hc, const char *remain, void * +/** + * Needed for some clients. This contains much the same as discover, + * but in xml format. + */ +static int +hdhomerun_server_device_xml(http_connection_t *hc, const char *remain, void *opaque) +{ + const char *server_name = config.server_name ?: "TVHeadend"; + const char *hdhr_user = config.hdhomerun_server_username ?: ""; + access_t *perm = access_get_by_username(hdhr_user); + char http_ip[128]; + htsbuf_queue_t *hq; + const uint32_t deviceid = tvh_crc32((const uint8_t*)server_name, strlen(server_name), 0); + + if (access_verify2(perm, ACCESS_STREAMING)) { + access_destroy(perm); + return http_noaccess_code(hc); + } + hq = &hc->hc_reply; + + tcp_get_str_from_ip(hc->hc_self, http_ip, sizeof(http_ip)); + htsbuf_qprintf(hq, "" + "" + "1" + "0" + "" + "http://%s:%u" + "" + "urn:schemas-upnp-org:device:MediaServer:1" + "%s" + "Silicondust" + "HDTC-2US" + "HDTC-2US" + "" + /* Version 5 UUID (random) with top part as server id*/ + "%8.8x-745e-5d9a-8903-4a02327a7e09" + "" + "", + http_ip, tvheadend_webui_port, + server_name, + deviceid); + + http_output_content(hc, "application/xml"); + access_destroy(perm); + return 0; +} + /** * */ @@ -2286,6 +2333,7 @@ webui_init(int xspf) http_path_add("/discover.json", NULL, hdhomerun_server_discover, ACCESS_ANONYMOUS); http_path_add("/lineup.json", NULL, hdhomerun_server_lineup, ACCESS_ANONYMOUS); http_path_add("/lineup_status.json", NULL, hdhomerun_server_lineup_status, ACCESS_ANONYMOUS); + http_path_add("/device.xml", NULL, hdhomerun_server_device_xml, ACCESS_ANONYMOUS); http_path_add_modify("/play", NULL, page_play, ACCESS_ANONYMOUS, page_play_path_modify5); http_path_add_modify("/play/ticket", NULL, page_play_ticket, ACCESS_ANONYMOUS, page_play_path_modify12); -- 2.25.1